mozreview: clear impromptu review flags in bugzilla (bug 1277849); r=mcote draft
authorbyron jones <glob@mozilla.com>
Tue, 07 Jun 2016 22:31:05 +0800
changeset 8419 005b600c233af0f7909d0a53d35a326fd2b02176
parent 8416 da9c69b8e19bdf3d5398d3e1a24a795e68d433b0
push id906
push userbjones@mozilla.com
push dateTue, 07 Jun 2016 16:48:53 +0000
reviewersmcote
bugs1277849
mozreview: clear impromptu review flags in bugzilla (bug 1277849); r=mcote When a new revision is pushed for review, clear any attachment flags in Bugzilla that were set by people not targetted by the current review. This ensures that "impromptu" reviewers are not requested to review followup commits. MozReview-Commit-ID: KZ7N6Cp2Tt1
pylib/mozreview/mozreview/bugzilla/attachments.py
--- a/pylib/mozreview/mozreview/bugzilla/attachments.py
+++ b/pylib/mozreview/mozreview/bugzilla/attachments.py
@@ -66,27 +66,36 @@ def update_bugzilla_attachments(bugzilla
                 # local database is up to date.
                 users = get_or_create_bugzilla_users(user_data)
                 email = users[0].email
                 user_email_cache[bum.bugzilla_user_id] = email
 
             carry_forward[email] = False
 
         for review in gen_latest_reviews(review_request):
-            # Determine which flags should be carried forward.
-            # If the code (diffset) hasn't been changed by this draft (ie. this
-            # is a change to meta data only), then carry forward all flags.
-            # If the diffset was updated, carry forward just r+'s.  All other
-            # flags should be reset to r?.
             if review_request_draft.diffset:
+                # The code has changed, we need to determine what needs to
+                # happen to the flags.
+
+                # Don't set carry_forward values for reviewers that are not in
+                # the target_people list (eg. impromptu reviews).  This will
+                # result in the attachment flag being cleared in Bugzilla.
+                if review.user.email not in carry_forward:
+                    continue
+
+                # Carry forward just r+'s.  All other flags should be reset
+                # to r?.
                 review_flag = review.extra_data.get(REVIEW_FLAG_KEY)
                 carry_forward[review.user.email] = review_flag == 'r+' or (
                     # Older reviews didn't set review_flag.
                     review_flag is None and review.ship_it)
+
             else:
+                # This is a meta data only change, don't touch any existing
+                # flags.
                 carry_forward[review.user.email] = True
 
         rr_url = get_obj_url(review_request)
         diff_url = '%sdiff/#index_header' % rr_url
 
         # Only post a comment if the diffset has actually changed
         comment = ''
         if review_request_draft.get_latest_diffset():