changeset 33978:088598153aa2

phabsend: show associated Differential Revisions with --confirm Often people running `phabsend --confirm` just want to check whether a commit will trigger a creation of new Differential Revision, or update an existing one. This patch implements that. The `--confirm` message was changed to use node instead of revision number to be consistent with what `phabsend` outputs. An example output looks like: D487 - a80f447973a0 test-extension: enable demandimport explicitly D494 - cf440ea6e47e test-casecollision-merge: fix the test NEW - 0a6b97147128 phabsend: polish the docstring a bit Send the above changes to https://phab.mercurial-scm.org/ (yn)? Differential Revision: https://phab.mercurial-scm.org/D514
author Jun Wu <quark@fb.com>
date Thu, 24 Aug 2017 17:44:08 -0700
parents edeb8f28c031
children 3939b30d0cb7
files contrib/phabricator.py
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/phabricator.py	Thu Aug 24 17:31:33 2017 -0700
+++ b/contrib/phabricator.py	Thu Aug 24 17:44:08 2017 -0700
@@ -378,10 +378,13 @@
     if opts.get('amend'):
         cmdutil.checkunfinished(repo)
 
+    # {newnode: (oldnode, olddiff, olddrev}
+    oldmap = getoldnodedrevmap(repo, [repo[r].node() for r in revs])
+
     confirm = ui.configbool('phabsend', 'confirm')
     confirm |= bool(opts.get('confirm'))
     if confirm:
-        confirmed = _confirmbeforesend(repo, revs)
+        confirmed = _confirmbeforesend(repo, revs, oldmap)
         if not confirmed:
             raise error.Abort(_('phabsend cancelled'))
 
@@ -391,9 +394,6 @@
         phids = userphids(repo, reviewers)
         actions.append({'type': 'reviewers.add', 'value': phids})
 
-    # {newnode: (oldnode, olddiff, olddrev}
-    oldmap = getoldnodedrevmap(repo, [repo[r].node() for r in revs])
-
     drevids = [] # [int]
     diffmap = {} # {newnode: diff}
 
@@ -474,14 +474,21 @@
 _metanamemap = util.sortdict([(r'user', 'User'), (r'date', 'Date'),
                               (r'node', 'Node ID'), (r'parent', 'Parent ')])
 
-def _confirmbeforesend(repo, revs):
+def _confirmbeforesend(repo, revs, oldmap):
     url, token = readurltoken(repo)
     ui = repo.ui
     for rev in revs:
         ctx = repo[rev]
         desc = ctx.description().splitlines()[0]
-        ui.write(('%d: ' % rev), label='phabsend.revnumber')
-        ui.write(('%s\n' % desc), label='phabsend.desc')
+        oldnode, olddiff, drevid = oldmap.get(ctx.node(), (None, None, None))
+        if drevid:
+            drevdesc = ui.label('D%s' % drevid, 'phabricator.drev')
+        else:
+            drevdesc = ui.label(_('NEW'), 'phabricator.drev')
+
+        ui.write(_('%s - %s: %s\n') % (drevdesc,
+                                       ui.label(bytes(ctx), 'phabricator.node'),
+                                       ui.label(desc, 'phabricator.desc')))
 
     if ui.promptchoice(_('Send the above changes to %s (yn)?'
                          '$$ &Yes $$ &No') % url):