Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
46036:8d54944eaeb0 | 46037:9624bf057c2a |
---|---|
2233 (b'', b'reopen', False, _(b'reopen revisions')), | 2233 (b'', b'reopen', False, _(b'reopen revisions')), |
2234 (b'', b'plan-changes', False, _(b'plan changes for revisions')), | 2234 (b'', b'plan-changes', False, _(b'plan changes for revisions')), |
2235 (b'', b'resign', False, _(b'resign as a reviewer from revisions')), | 2235 (b'', b'resign', False, _(b'resign as a reviewer from revisions')), |
2236 (b'', b'commandeer', False, _(b'commandeer revisions')), | 2236 (b'', b'commandeer', False, _(b'commandeer revisions')), |
2237 (b'm', b'comment', b'', _(b'comment on the last revision')), | 2237 (b'm', b'comment', b'', _(b'comment on the last revision')), |
2238 (b'r', b'rev', b'', _(b'local revision to update'), _(b'REV')), | |
2238 ], | 2239 ], |
2239 _(b'DREVSPEC... [OPTIONS]'), | 2240 _(b'[DREVSPEC...| -r REV...] [OPTIONS]'), |
2240 helpcategory=command.CATEGORY_IMPORT_EXPORT, | 2241 helpcategory=command.CATEGORY_IMPORT_EXPORT, |
2241 optionalrepo=True, | 2242 optionalrepo=True, |
2242 ) | 2243 ) |
2243 def phabupdate(ui, repo, *specs, **opts): | 2244 def phabupdate(ui, repo, *specs, **opts): |
2244 """update Differential Revision in batch | 2245 """update Differential Revision in batch |
2263 raise error.Abort(_(b'%s cannot be used together') % b', '.join(flags)) | 2264 raise error.Abort(_(b'%s cannot be used together') % b', '.join(flags)) |
2264 | 2265 |
2265 actions = [] | 2266 actions = [] |
2266 for f in flags: | 2267 for f in flags: |
2267 actions.append({b'type': f, b'value': True}) | 2268 actions.append({b'type': f, b'value': True}) |
2269 | |
2270 revs = opts.get(b'rev') | |
2271 if revs: | |
2272 if not repo: | |
2273 raise error.InputError(_(b'--rev requires a repository')) | |
2274 | |
2275 if specs: | |
2276 raise error.InputError(_(b'cannot specify both DREVSPEC and --rev')) | |
2277 | |
2278 drevmap = getdrevmap(repo, scmutil.revrange(repo, [revs])) | |
2279 specs = [] | |
2280 unknown = [] | |
2281 for r, d in pycompat.iteritems(drevmap): | |
2282 if d is None: | |
2283 unknown.append(repo[r]) | |
2284 else: | |
2285 specs.append(b'D%d' % d) | |
2286 if unknown: | |
2287 raise error.InputError( | |
2288 _(b'selected revisions without a Differential: %s') | |
2289 % scmutil.nodesummaries(repo, unknown) | |
2290 ) | |
2268 | 2291 |
2269 drevs = _getdrevs(ui, opts.get(b'stack'), specs) | 2292 drevs = _getdrevs(ui, opts.get(b'stack'), specs) |
2270 for i, drev in enumerate(drevs): | 2293 for i, drev in enumerate(drevs): |
2271 if i + 1 == len(drevs) and opts.get(b'comment'): | 2294 if i + 1 == len(drevs) and opts.get(b'comment'): |
2272 actions.append({b'type': b'comment', b'value': opts[b'comment']}) | 2295 actions.append({b'type': b'comment', b'value': opts[b'comment']}) |