Mercurial > hg
comparison hgext/histedit.py @ 48116:5ced12cfa41b
errors: raise InputError on bad revset to revrange() iff provided by the user
Most callers of `scmutil.revrange()` pass in a revset provided by the
user. If there are problems resolving that, it should result in an
`InputError` and exit code 10 (when using detailed exit
codes). However, there are also some callers that pass in revsets not
provided by the user. `InputError` is not appropriate in those
cases. This patch therefore introduces a wrapper around
`scmutil.revrange()` that simply converts the exception type. I put it
in `logcmdutil.py` since that seems to be the lowest-level module in
the (poorly defined) UI layer.
Differential Revision: https://phab.mercurial-scm.org/D11560
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 28 Sep 2021 08:47:11 -0700 |
parents | f27a83399abb |
children | b6fc7d188f68 |
comparison
equal
deleted
inserted
replaced
48115:b067d22dc6ad | 48116:5ced12cfa41b |
---|---|
1705 if len(revs) != 1: | 1705 if len(revs) != 1: |
1706 raise error.InputError( | 1706 raise error.InputError( |
1707 _(b'histedit requires exactly one ancestor revision') | 1707 _(b'histedit requires exactly one ancestor revision') |
1708 ) | 1708 ) |
1709 | 1709 |
1710 rr = list(repo.set(b'roots(%ld)', scmutil.revrange(repo, revs))) | 1710 rr = list(repo.set(b'roots(%ld)', logcmdutil.revrange(repo, revs))) |
1711 if len(rr) != 1: | 1711 if len(rr) != 1: |
1712 raise error.InputError( | 1712 raise error.InputError( |
1713 _( | 1713 _( |
1714 b'The specified revisions must have ' | 1714 b'The specified revisions must have ' |
1715 b'exactly one common root' | 1715 b'exactly one common root' |
1980 | 1980 |
1981 _validateargs(ui, repo, freeargs, opts, goal, rules, revs) | 1981 _validateargs(ui, repo, freeargs, opts, goal, rules, revs) |
1982 | 1982 |
1983 hastags = False | 1983 hastags = False |
1984 if revs: | 1984 if revs: |
1985 revs = scmutil.revrange(repo, revs) | 1985 revs = logcmdutil.revrange(repo, revs) |
1986 ctxs = [repo[rev] for rev in revs] | 1986 ctxs = [repo[rev] for rev in revs] |
1987 for ctx in ctxs: | 1987 for ctx in ctxs: |
1988 tags = [tag for tag in ctx.tags() if tag != b'tip'] | 1988 tags = [tag for tag in ctx.tags() if tag != b'tip'] |
1989 if not hastags: | 1989 if not hastags: |
1990 hastags = len(tags) | 1990 hastags = len(tags) |
2203 remote = freeargs[0] | 2203 remote = freeargs[0] |
2204 else: | 2204 else: |
2205 remote = None | 2205 remote = None |
2206 root = findoutgoing(ui, repo, remote, force, opts) | 2206 root = findoutgoing(ui, repo, remote, force, opts) |
2207 else: | 2207 else: |
2208 rr = list(repo.set(b'roots(%ld)', scmutil.revrange(repo, revs))) | 2208 rr = list(repo.set(b'roots(%ld)', logcmdutil.revrange(repo, revs))) |
2209 if len(rr) != 1: | 2209 if len(rr) != 1: |
2210 raise error.InputError( | 2210 raise error.InputError( |
2211 _( | 2211 _( |
2212 b'The specified revisions must have ' | 2212 b'The specified revisions must have ' |
2213 b'exactly one common root' | 2213 b'exactly one common root' |