mozreview: Mirror comments on parents to just the bug of the first child (bug 1226080); r?glob draft
authorMark Cote <mcote@mozilla.com>
Fri, 22 Jul 2016 15:52:27 -0400
changeset 9110 df7e88018d34408749060e1fe9b1f1e9650b75b1
parent 9109 f0af120be88cc9dfbea1f37dd5cb750e68b14958
child 9111 f02dfc230e50950736123944a03db198d6e99c04
push id1083
push usermcote@mozilla.com
push dateWed, 03 Aug 2016 20:51:40 +0000
reviewersglob
bugs1226080
mozreview: Mirror comments on parents to just the bug of the first child (bug 1226080); r?glob This should have no real effect now because all commits in a single series are currently associated with a single bug. Regardless, we need to choose only a single bug so that we can later associate the comment with a single attachment. If we later do allow multiple bugs in a single series, we'll have to pick one attachment for each unique bug. There is a TODO to that effect. MozReview-Commit-ID: 1MkfDlhJMuR
pylib/mozreview/mozreview/signal_handlers.py
--- a/pylib/mozreview/mozreview/signal_handlers.py
+++ b/pylib/mozreview/mozreview/signal_handlers.py
@@ -648,24 +648,29 @@ def on_review_publishing(user, review, *
     siteconfig = SiteConfiguration.objects.get_current()
     comment = build_plaintext_review(review,
                                      get_obj_url(review, site,
                                                  siteconfig),
                                      {"user": user})
     b = Bugzilla(get_bugzilla_api_key(user))
 
     if is_parent(review_request):
-        # Mirror the comment to the bug, unless it's a ship-it or the review
-        # flag was set, in which case throw an error.
-        # Ship-its and review flags are allowed only on child commits.
+        # We only support raw comments on parent review requests to prevent
+        # confusion.  If the ship-it flag or the review flag was set, throw
+        # an error.
+        # Otherwise, mirror the comment over, associating it with the first
+        # commit.
         if review.ship_it or review.extra_data.get(REVIEW_FLAG_KEY):
             raise ParentShipItError
 
-        [b.post_comment(int(bug_id), comment) for bug_id in
-         review_request.get_bug_list()]
+        # TODO: If we ever allow multiple bugs in a single series, and we want
+        # to continue to allow comments on parents, we'll have to pick one
+        # child for each unique bug.
+        first_child = list(gen_child_rrs(review_request))[0]
+        b.post_comment(int(first_child.get_bug_list()[0]), comment)
     else:
         diff_url = get_diff_url(review_request)
         bug_id = int(review_request.get_bug_list()[0])
 
         commented = False
         flag = review.extra_data.get(REVIEW_FLAG_KEY)
 
         if flag is not None: