Mercurial > hg
comparison hgext/phabricator.py @ 42431:29528c4235a1
phabricator: add commenting to phabsend for new/updated Diffs
Especially useful when sending updates to existing Revisions so one can specify
the sort of changes e.g. "Address review comments" or "Rebase to tip"
If the diff content hasn't changed then it only needs a metadata update which
doesn't show in the Phabricator updates UI, so don't add a comment that will.
Differential Revision: https://phab.mercurial-scm.org/D6496
author | Ian Moody <moz-ian@perix.co.uk> |
---|---|
date | Fri, 07 Jun 2019 20:19:55 +0100 |
parents | af13e2088f77 |
children | 500b64c5d991 |
comparison
equal
deleted
inserted
replaced
42430:5b217451a2c2 | 42431:29528c4235a1 |
---|---|
414 }), | 414 }), |
415 } | 415 } |
416 callconduit(ctx.repo(), b'differential.setdiffproperty', params) | 416 callconduit(ctx.repo(), b'differential.setdiffproperty', params) |
417 | 417 |
418 def createdifferentialrevision(ctx, revid=None, parentrevid=None, oldnode=None, | 418 def createdifferentialrevision(ctx, revid=None, parentrevid=None, oldnode=None, |
419 olddiff=None, actions=None): | 419 olddiff=None, actions=None, comment=None): |
420 """create or update a Differential Revision | 420 """create or update a Differential Revision |
421 | 421 |
422 If revid is None, create a new Differential Revision, otherwise update | 422 If revid is None, create a new Differential Revision, otherwise update |
423 revid. If parentrevid is not None, set it as a dependency. | 423 revid. If parentrevid is not None, set it as a dependency. |
424 | 424 |
437 | 437 |
438 transactions = [] | 438 transactions = [] |
439 if neednewdiff: | 439 if neednewdiff: |
440 diff = creatediff(ctx) | 440 diff = creatediff(ctx) |
441 transactions.append({b'type': b'update', b'value': diff[b'phid']}) | 441 transactions.append({b'type': b'update', b'value': diff[b'phid']}) |
442 if comment: | |
443 transactions.append({b'type': b'comment', b'value': comment}) | |
442 else: | 444 else: |
443 # Even if we don't need to upload a new diff because the patch content | 445 # Even if we don't need to upload a new diff because the patch content |
444 # does not change. We might still need to update its metadata so | 446 # does not change. We might still need to update its metadata so |
445 # pushers could know the correct node metadata. | 447 # pushers could know the correct node metadata. |
446 assert olddiff | 448 assert olddiff |
495 | 497 |
496 @vcrcommand(b'phabsend', | 498 @vcrcommand(b'phabsend', |
497 [(b'r', b'rev', [], _(b'revisions to send'), _(b'REV')), | 499 [(b'r', b'rev', [], _(b'revisions to send'), _(b'REV')), |
498 (b'', b'amend', True, _(b'update commit messages')), | 500 (b'', b'amend', True, _(b'update commit messages')), |
499 (b'', b'reviewer', [], _(b'specify reviewers')), | 501 (b'', b'reviewer', [], _(b'specify reviewers')), |
502 (b'm', b'comment', b'', | |
503 _(b'add a comment to Revisions with new/updated Diffs')), | |
500 (b'', b'confirm', None, _(b'ask for confirmation before sending'))], | 504 (b'', b'confirm', None, _(b'ask for confirmation before sending'))], |
501 _(b'REV [OPTIONS]'), | 505 _(b'REV [OPTIONS]'), |
502 helpcategory=command.CATEGORY_IMPORT_EXPORT) | 506 helpcategory=command.CATEGORY_IMPORT_EXPORT) |
503 def phabsend(ui, repo, *revs, **opts): | 507 def phabsend(ui, repo, *revs, **opts): |
504 """upload changesets to Phabricator | 508 """upload changesets to Phabricator |
565 # Get Differential Revision ID | 569 # Get Differential Revision ID |
566 oldnode, olddiff, revid = oldmap.get(ctx.node(), (None, None, None)) | 570 oldnode, olddiff, revid = oldmap.get(ctx.node(), (None, None, None)) |
567 if oldnode != ctx.node() or opts.get(b'amend'): | 571 if oldnode != ctx.node() or opts.get(b'amend'): |
568 # Create or update Differential Revision | 572 # Create or update Differential Revision |
569 revision, diff = createdifferentialrevision( | 573 revision, diff = createdifferentialrevision( |
570 ctx, revid, lastrevid, oldnode, olddiff, actions) | 574 ctx, revid, lastrevid, oldnode, olddiff, actions, |
575 opts.get(b'comment')) | |
571 diffmap[ctx.node()] = diff | 576 diffmap[ctx.node()] = diff |
572 newrevid = int(revision[b'object'][b'id']) | 577 newrevid = int(revision[b'object'][b'id']) |
573 if revid: | 578 if revid: |
574 action = b'updated' | 579 action = b'updated' |
575 else: | 580 else: |