Mercurial > hg
diff hgext/phabricator.py @ 46037:9624bf057c2a
phabricator: allow local revisions to be specified with `phabupdate`
It's way easier and less error prone to specify a revset after importing a
series than to manually type in a series of Differentials.
Unlike most revision oriented commands, this requires the `--rev` option
explicitly because the existing `DREVSPEC` doesn't need to have the leading 'D',
and therefore the meaning is ambiguous. I wouldn't have a problem giving
precedence to the local revnum, but `phabread` and `phabimport` also use
DREVSPEC, and local revisions make no sense there. I would be fine with
modifying that definition to require the leading 'D', but I'm not sure how many
people are used to not specifying it.
Differential Revision: https://phab.mercurial-scm.org/D9356
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 21 Nov 2020 00:10:36 -0500 |
parents | 4d70444c3ea9 |
children | ffd3e823a7e5 |
line wrap: on
line diff
--- a/hgext/phabricator.py Fri Nov 20 10:51:07 2020 +0100 +++ b/hgext/phabricator.py Sat Nov 21 00:10:36 2020 -0500 @@ -2235,8 +2235,9 @@ (b'', b'resign', False, _(b'resign as a reviewer from revisions')), (b'', b'commandeer', False, _(b'commandeer revisions')), (b'm', b'comment', b'', _(b'comment on the last revision')), + (b'r', b'rev', b'', _(b'local revision to update'), _(b'REV')), ], - _(b'DREVSPEC... [OPTIONS]'), + _(b'[DREVSPEC...| -r REV...] [OPTIONS]'), helpcategory=command.CATEGORY_IMPORT_EXPORT, optionalrepo=True, ) @@ -2266,6 +2267,28 @@ for f in flags: actions.append({b'type': f, b'value': True}) + revs = opts.get(b'rev') + if revs: + if not repo: + raise error.InputError(_(b'--rev requires a repository')) + + if specs: + raise error.InputError(_(b'cannot specify both DREVSPEC and --rev')) + + drevmap = getdrevmap(repo, scmutil.revrange(repo, [revs])) + specs = [] + unknown = [] + for r, d in pycompat.iteritems(drevmap): + if d is None: + unknown.append(repo[r]) + else: + specs.append(b'D%d' % d) + if unknown: + raise error.InputError( + _(b'selected revisions without a Differential: %s') + % scmutil.nodesummaries(repo, unknown) + ) + drevs = _getdrevs(ui, opts.get(b'stack'), specs) for i, drev in enumerate(drevs): if i + 1 == len(drevs) and opts.get(b'comment'):