Bug 1177944 - Allow disabling reviewer deduction with a config option. r=glob draft
authorBotond Ballo <botond@mozilla.com>
Fri, 18 Mar 2016 13:40:16 -0400
changeset 7542 becc6adc44dcc980216097acf3dfda6334f6100c
parent 7540 0b60c968cf226def9a11f7c4727b037f2d2b364e
child 7543 3a19fd9a17e10911e9fff74e3ca9ad10ab18f9f7
child 7544 3180b79f0796d9cc3a9991ad4b3c1f2d4c1496c8
child 7545 fdaa883f476e08816ab930227f9e2c40ef9d877c
push id711
push userbballo@mozilla.com
push dateWed, 23 Mar 2016 19:11:04 +0000
reviewersglob
bugs1177944
Bug 1177944 - Allow disabling reviewer deduction with a config option. r=glob MozReview-Commit-ID: DBCNh42eN4C
hgext/reviewboard/client.py
hgext/reviewboard/hgrb/proto.py
hgext/reviewboard/tests/test-specify-reviewers.t
--- a/hgext/reviewboard/client.py
+++ b/hgext/reviewboard/client.py
@@ -542,16 +542,17 @@ def doreview(repo, ui, remote, nodes):
                     'with changeset evolution. Read more at '
                     'http://mozilla-version-control-tools.readthedocs.org/en/latest/mozreview-user.html)\n'))
                 break
 
     req = commonrequestdict(ui, bzauth)
     req['identifier'] = identifier.full
     req['changesets'] = []
     req['obsolescence'] = obsolete.isenabled(repo, obsolete.createmarkersopt)
+    req['deduce-reviewers'] = ui.configbool('reviewboard', 'deduce-reviewers', True)
 
     reviews = repo.reviews
     oldparentid = reviews.findparentreview(identifier=identifier.full)
 
     # Include obsolescence data so server can make intelligent decisions.
     obsstore = repo.obsstore
     for node in nodes:
         precursors = [hex(n) for n in obsolete.allprecursors(obsstore, [node])]
--- a/hgext/reviewboard/hgrb/proto.py
+++ b/hgext/reviewboard/hgrb/proto.py
@@ -292,30 +292,36 @@ def _processpushreview(repo, req, ldap_u
         diff = ''.join(patch.diff(repo, node1=p1, node2=ctx.node(), opts=diffopts)) + '\n'
 
         if i:
             base_commit_id = nodes[i-1]
         else:
             base_commit_id = base_ctx.hex()
 
         summary = encoding.fromlocal(ctx.description().splitlines()[0])
+        if req.get('deduce-reviewers', True):
+            reviewers = list(commitparser.parse_rquestion_reviewers(summary))
+            requal_reviewers = list(commitparser.parse_requal_reviewers(summary))
+        else:
+            reviewers = []
+            requal_reviewers = []
         commits['individual'].append({
             'id': node,
             'precursors': precursors.get(node, []),
             'message': encoding.fromlocal(ctx.description()),
             # Diffs are arbitrary byte sequences. json.dump() will try to
             # interpret str as UTF-8, which could fail. Instead of trying
             # to coerce the str to a unicode or use ensure_ascii=False (which
             # is a giant pain), just base64 encode the diff in the JSON.
             'diff_b64': diff.encode('base64'),
             'bug': str(reviewid.bug),
             'base_commit_id': base_commit_id,
             'first_public_ancestor': first_public_ancestor,
-            'reviewers': list(commitparser.parse_rquestion_reviewers(summary)),
-            'requal_reviewers': list(commitparser.parse_requal_reviewers(summary))
+            'reviewers': reviewers,
+            'requal_reviewers': requal_reviewers
         })
 
     squashed_diff = b''.join(patch.diff(repo,
                                         node1=base_parent_node,
                                         node2=repo[nodes[-1]].node(),
                                         opts=diffopts)) + '\n'
 
     commits['squashed']['diff_b64'] = squashed_diff.encode('base64')
--- a/hgext/reviewboard/tests/test-specify-reviewers.t
+++ b/hgext/reviewboard/tests/test-specify-reviewers.t
@@ -575,13 +575,40 @@ Reviewer identification should be case i
   review url: http://$DOCKER_HOSTNAME:$HGPORT1/r/12 (draft)
   
   publish these review requests now (Yn)?  y
   (published review request 12)
 
   $ rbmanage list-reviewers 14
   RyanVM
 
+Reviewer deduction can be disabled with a config option.
+
+  $ echo blah >> foo
+  $ hg commit -m 'Bug 2 - awesome stuff; r?remus'
+  $ hg push -c 29 --config reviewboard.deduce-reviewers=false
+  pushing to ssh://$DOCKER_HOSTNAME:$HGPORT6/test-repo
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  remote: recorded push in pushlog
+  submitting 1 changesets for review
+  
+  changeset:  29:df9e974cc15e
+  summary:    Bug 2 - awesome stuff; r?remus
+  review:     http://$DOCKER_HOSTNAME:$HGPORT1/r/15 (draft)
+  
+  review id:  bz://2/mynick
+  review url: http://$DOCKER_HOSTNAME:$HGPORT1/r/12 (draft)
+  (review requests lack reviewers; visit review url to assign reviewers)
+  
+  publish these review requests now (Yn)?  y
+  (published review request 12)
+
+  $ rbmanage list-reviewers 15
+  
 
 Cleanup
 
   $ mozreview stop
   stopped 9 containers