D218: phabricator: add --confirm option to phabsend command
This revision was automatically updated to reflect the committed changes. Closed by commit rHG40cfe3197bc1: phabricator: add --confirm option to phabsend command (authored by pulkit). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D218?vs=515&id=562 REVISION DETAIL https://phab.mercurial-scm.org/D218 AFFECTED FILES contrib/phabricator.py CHANGE DETAILS diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -313,7 +313,8 @@ @command('phabsend', [('r', 'rev', [], _('revisions to send'), _('REV')), - ('', 'reviewer', [], _('specify reviewers'))], + ('', 'reviewer', [], _('specify reviewers')), + ('', 'confirm', None, _('ask for confirmation before sending'))], _('REV [OPTIONS]')) def phabsend(ui, repo, *revs, **opts): """upload changesets to Phabricator @@ -326,13 +327,27 @@ maintain the association. After the first time, phabsend will check obsstore and tags information so it can figure out whether to update an existing Differential Revision, or create a new one. + +The --confirm option lets you confirm changesets before sending them. You +can also add following to your configuration file to make it default +behaviour. + +[phabsend] +confirm = true """ revs = list(revs) + opts.get('rev', []) revs = scmutil.revrange(repo, revs) if not revs: raise error.Abort(_('phabsend requires at least one changeset')) +confirm = ui.configbool('phabsend', 'confirm') +confirm |= bool(opts.get('confirm')) +if confirm: +confirmed = _confirmbeforesend(repo, revs) +if not confirmed: +raise error.Abort(_('phabsend cancelled')) + actions = [] reviewers = opts.get('reviewer', []) if reviewers: @@ -379,6 +394,20 @@ _metanamemap = util.sortdict([(r'user', 'User'), (r'date', 'Date'), (r'node', 'Node ID'), (r'parent', 'Parent ')]) +def _confirmbeforesend(repo, revs): +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') + +if ui.promptchoice(_('Phabsend the above changes (yn)?' +'$$ &Yes $$ &No')): +return False + +return True + def querydrev(repo, params, stack=False): """return a list of "Differential Revision" dicts To: pulkit, #hg-reviewers, durin42 Cc: durin42, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D218: phabricator: add --confirm option to phabsend command
durin42 accepted this revision. durin42 added a comment. This revision is now accepted and ready to land. Sure. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D218 To: pulkit, #hg-reviewers, durin42 Cc: durin42, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D218: phabricator: add --confirm option to phabsend command
pulkit updated this revision to Diff 515. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D218?vs=513&id=515 REVISION DETAIL https://phab.mercurial-scm.org/D218 AFFECTED FILES contrib/phabricator.py CHANGE DETAILS diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -313,7 +313,8 @@ @command('phabsend', [('r', 'rev', [], _('revisions to send'), _('REV')), - ('', 'reviewer', [], _('specify reviewers'))], + ('', 'reviewer', [], _('specify reviewers')), + ('', 'confirm', None, _('ask for confirmation before sending'))], _('REV [OPTIONS]')) def phabsend(ui, repo, *revs, **opts): """upload changesets to Phabricator @@ -326,13 +327,27 @@ maintain the association. After the first time, phabsend will check obsstore and tags information so it can figure out whether to update an existing Differential Revision, or create a new one. + +The --confirm option lets you confirm changesets before sending them. You +can also add following to your configuration file to make it default +behaviour. + +[phabsend] +confirm = true """ revs = list(revs) + opts.get('rev', []) revs = scmutil.revrange(repo, revs) if not revs: raise error.Abort(_('phabsend requires at least one changeset')) +confirm = ui.configbool('phabsend', 'confirm') +confirm |= bool(opts.get('confirm')) +if confirm: +confirmed = _confirmbeforesend(repo, revs) +if not confirmed: +raise error.Abort(_('phabsend cancelled')) + actions = [] reviewers = opts.get('reviewer', []) if reviewers: @@ -379,6 +394,20 @@ _metanamemap = util.sortdict([(r'user', 'User'), (r'date', 'Date'), (r'node', 'Node ID'), (r'parent', 'Parent ')]) +def _confirmbeforesend(repo, revs): +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') + +if ui.promptchoice(_('Phabsend the above changes (yn)?' +'$$ &Yes $$ &No')): +return False + +return True + def querydrev(repo, params, stack=False): """return a list of "Differential Revision" dicts To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D218: phabricator: add --confirm option to phabsend command
pulkit created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This adds a --confirm flag similar to the confirm flag of `hg email` using which one can confirm the changesets before they get emailed. The confirm flag will show the changesets and ask for confirmation before sending them. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D218 AFFECTED FILES contrib/phabricator.py CHANGE DETAILS diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -313,7 +313,8 @@ @command('phabsend', [('r', 'rev', [], _('revisions to send'), _('REV')), - ('', 'reviewer', [], _('specify reviewers'))], + ('', 'reviewer', [], _('specify reviewers')), + ('', 'confirm', None, _('ask for confirmation before sending'))], _('REV [OPTIONS]')) def phabsend(ui, repo, *revs, **opts): """upload changesets to Phabricator @@ -333,6 +334,13 @@ if not revs: raise error.Abort(_('phabsend requires at least one changeset')) +confirm = ui.configbool('phabsend', 'confirm') +confirm |= bool(opts.get('confirm')) +if confirm: +confirmed = _confirmbeforesend(repo, revs) +if not confirmed: +raise error.Abort(_('phabsend cancelled')) + actions = [] reviewers = opts.get('reviewer', []) if reviewers: @@ -379,6 +387,20 @@ _metanamemap = util.sortdict([(r'user', 'User'), (r'date', 'Date'), (r'node', 'Node ID'), (r'parent', 'Parent ')]) +def _confirmbeforesend(repo, revs): +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') + +if ui.promptchoice(_('Phabsend the above changes (yn)?' +'$$ &Yes $$ &No')): +return False + +return True + def querydrev(repo, params, stack=False): """return a list of "Differential Revision" dicts To: pulkit, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel