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
--- 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():