changeset 33855:6e666cd59879

phabricator: add phabupdate command to update status in batch Changing status (accept, etc) on the webpage is not very convenient - currently there is no way to accept (or abandon etc.) a stack using a single click or command. This patch adds a `phabupdate` command that could be used to change status in batch. It also supports `--comment` which will write a comment on the last revision, which is similar to what we do using emails. Differential Revision: https://phab.mercurial-scm.org/D127
author Jun Wu <quark@fb.com>
date Tue, 18 Jul 2017 02:05:19 -0700
parents fb59192b4981
children 057d31ceace3
files contrib/phabricator.py
diffstat 1 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/phabricator.py	Tue Jul 18 01:34:55 2017 -0700
+++ b/contrib/phabricator.py	Tue Jul 18 02:05:19 2017 -0700
@@ -9,7 +9,7 @@
 This extension provides a ``phabsend`` command which sends a stack of
 changesets to Phabricator without amending commit messages, and a ``phabread``
 command which prints a stack of revisions in a format suitable
-for :hg:`import`.
+for :hg:`import`, and a ``phabupdate`` command to update statuses in batch.
 
 By default, Phabricator requires ``Test Plan`` which might prevent some
 changeset from being sent. The requirement could be disabled by changing
@@ -798,3 +798,32 @@
         spec = ':(%s)' % spec
     drevs = querydrev(repo, spec)
     readpatch(repo, drevs, ui.write)
+
+@command('phabupdate',
+         [('', 'accept', False, _('accept revisions')),
+          ('', 'reject', False, _('reject revisions')),
+          ('', 'abandon', False, _('abandon revisions')),
+          ('', 'reclaim', False, _('reclaim revisions')),
+          ('m', 'comment', '', _('comment on the last revision')),
+         ], _('DREVSPEC [OPTIONS]'))
+def phabupdate(ui, repo, spec, **opts):
+    """update Differential Revision in batch
+
+    DREVSPEC selects revisions. See :hg:`help phabread` for its usage.
+    """
+    flags = [n for n in 'accept reject abandon reclaim'.split() if opts.get(n)]
+    if len(flags) > 1:
+        raise error.Abort(_('%s cannot be used together') % ', '.join(flags))
+
+    actions = []
+    for f in flags:
+        actions.append({'type': f, 'value': 'true'})
+
+    drevs = querydrev(repo, spec)
+    for i, drev in enumerate(drevs):
+        if i + 1 == len(drevs) and opts.get('comment'):
+            actions.append({'type': 'comment', 'value': opts['comment']})
+        if actions:
+            params = {'objectIdentifier': drev[r'phid'],
+                      'transactions': actions}
+            callconduit(repo, 'differential.revision.edit', params)