Mercurial > public > mercurial-scm > hg
comparison contrib/phabricator.py @ 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 | 941c33cfde81 |
comparison
equal
deleted
inserted
replaced
33977:edeb8f28c031 | 33978:088598153aa2 |
---|---|
376 if not revs: | 376 if not revs: |
377 raise error.Abort(_('phabsend requires at least one changeset')) | 377 raise error.Abort(_('phabsend requires at least one changeset')) |
378 if opts.get('amend'): | 378 if opts.get('amend'): |
379 cmdutil.checkunfinished(repo) | 379 cmdutil.checkunfinished(repo) |
380 | 380 |
381 # {newnode: (oldnode, olddiff, olddrev} | |
382 oldmap = getoldnodedrevmap(repo, [repo[r].node() for r in revs]) | |
383 | |
381 confirm = ui.configbool('phabsend', 'confirm') | 384 confirm = ui.configbool('phabsend', 'confirm') |
382 confirm |= bool(opts.get('confirm')) | 385 confirm |= bool(opts.get('confirm')) |
383 if confirm: | 386 if confirm: |
384 confirmed = _confirmbeforesend(repo, revs) | 387 confirmed = _confirmbeforesend(repo, revs, oldmap) |
385 if not confirmed: | 388 if not confirmed: |
386 raise error.Abort(_('phabsend cancelled')) | 389 raise error.Abort(_('phabsend cancelled')) |
387 | 390 |
388 actions = [] | 391 actions = [] |
389 reviewers = opts.get('reviewer', []) | 392 reviewers = opts.get('reviewer', []) |
390 if reviewers: | 393 if reviewers: |
391 phids = userphids(repo, reviewers) | 394 phids = userphids(repo, reviewers) |
392 actions.append({'type': 'reviewers.add', 'value': phids}) | 395 actions.append({'type': 'reviewers.add', 'value': phids}) |
393 | |
394 # {newnode: (oldnode, olddiff, olddrev} | |
395 oldmap = getoldnodedrevmap(repo, [repo[r].node() for r in revs]) | |
396 | 396 |
397 drevids = [] # [int] | 397 drevids = [] # [int] |
398 diffmap = {} # {newnode: diff} | 398 diffmap = {} # {newnode: diff} |
399 | 399 |
400 # Send patches one by one so we know their Differential Revision IDs and | 400 # Send patches one by one so we know their Differential Revision IDs and |
472 # Map from "hg:meta" keys to header understood by "hg import". The order is | 472 # Map from "hg:meta" keys to header understood by "hg import". The order is |
473 # consistent with "hg export" output. | 473 # consistent with "hg export" output. |
474 _metanamemap = util.sortdict([(r'user', 'User'), (r'date', 'Date'), | 474 _metanamemap = util.sortdict([(r'user', 'User'), (r'date', 'Date'), |
475 (r'node', 'Node ID'), (r'parent', 'Parent ')]) | 475 (r'node', 'Node ID'), (r'parent', 'Parent ')]) |
476 | 476 |
477 def _confirmbeforesend(repo, revs): | 477 def _confirmbeforesend(repo, revs, oldmap): |
478 url, token = readurltoken(repo) | 478 url, token = readurltoken(repo) |
479 ui = repo.ui | 479 ui = repo.ui |
480 for rev in revs: | 480 for rev in revs: |
481 ctx = repo[rev] | 481 ctx = repo[rev] |
482 desc = ctx.description().splitlines()[0] | 482 desc = ctx.description().splitlines()[0] |
483 ui.write(('%d: ' % rev), label='phabsend.revnumber') | 483 oldnode, olddiff, drevid = oldmap.get(ctx.node(), (None, None, None)) |
484 ui.write(('%s\n' % desc), label='phabsend.desc') | 484 if drevid: |
485 drevdesc = ui.label('D%s' % drevid, 'phabricator.drev') | |
486 else: | |
487 drevdesc = ui.label(_('NEW'), 'phabricator.drev') | |
488 | |
489 ui.write(_('%s - %s: %s\n') % (drevdesc, | |
490 ui.label(bytes(ctx), 'phabricator.node'), | |
491 ui.label(desc, 'phabricator.desc'))) | |
485 | 492 |
486 if ui.promptchoice(_('Send the above changes to %s (yn)?' | 493 if ui.promptchoice(_('Send the above changes to %s (yn)?' |
487 '$$ &Yes $$ &No') % url): | 494 '$$ &Yes $$ &No') % url): |
488 return False | 495 return False |
489 | 496 |