phabricator: add --blocker argument to phabsend to specify blocking reviewers
authorIan Moody <moz-ian@perix.co.uk>
Tue, 11 Jun 2019 19:52:16 +0100
changeset 42444 f33d3ee110da
parent 42443 d3c81439e2ee
child 42445 3e42fc243741
phabricator: add --blocker argument to phabsend to specify blocking reviewers The way to signal to Conduit that a reviewer is considered blocking is just to wrap their PHID in "blocking()" when including it in the list of PHIDs passed to `reviewers.add`. arc doesn't have a --blocker, instead one is supposed to append a '!' to the end of reviewer names (I think reviewers are usually added in an editor rather than the command line, where '!'s can be more hazardous). moz-phab (Mozilla's arcanist wrapper) does have a --blocker argument, and being explicit like this is also more discoverable. Even `arc diff`'s help doesn't seem to mention the reviewer! syntax. Differential Revision: https://phab.mercurial-scm.org/D6512
hgext/phabricator.py
--- a/hgext/phabricator.py	Tue Jun 11 19:37:19 2019 +0100
+++ b/hgext/phabricator.py	Tue Jun 11 19:52:16 2019 +0100
@@ -515,6 +515,7 @@
          [(b'r', b'rev', [], _(b'revisions to send'), _(b'REV')),
           (b'', b'amend', True, _(b'update commit messages')),
           (b'', b'reviewer', [], _(b'specify reviewers')),
+          (b'', b'blocker', [], _(b'specify blocking reviewers')),
           (b'm', b'comment', b'',
            _(b'add a comment to Revisions with new/updated Diffs')),
           (b'', b'confirm', None, _(b'ask for confirmation before sending'))],
@@ -568,8 +569,15 @@
 
     actions = []
     reviewers = opts.get(b'reviewer', [])
+    blockers = opts.get(b'blocker', [])
+    phids = []
     if reviewers:
-        phids = userphids(repo, reviewers)
+        phids.extend(userphids(repo, reviewers))
+    if blockers:
+        phids.extend(map(
+            lambda phid: b'blocking(%s)' % phid, userphids(repo, blockers)
+        ))
+    if phids:
         actions.append({b'type': b'reviewers.add', b'value': phids})
 
     drevids = [] # [int]