Mercurial > public > mercurial-scm > hg
comparison mercurial/debugcommands.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 | 78e66649cdb3 |
children | 5105a9975407 |
comparison
equal
deleted
inserted
replaced
48115:b067d22dc6ad | 48116:5ced12cfa41b |
---|---|
1080 ) | 1080 ) |
1081 remote = hg.peer(repo, opts, remoteurl) | 1081 remote = hg.peer(repo, opts, remoteurl) |
1082 ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(remoteurl)) | 1082 ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(remoteurl)) |
1083 else: | 1083 else: |
1084 branches = (None, []) | 1084 branches = (None, []) |
1085 remote_filtered_revs = scmutil.revrange( | 1085 remote_filtered_revs = logcmdutil.revrange( |
1086 unfi, [b"not (::(%s))" % remote_revs] | 1086 unfi, [b"not (::(%s))" % remote_revs] |
1087 ) | 1087 ) |
1088 remote_filtered_revs = frozenset(remote_filtered_revs) | 1088 remote_filtered_revs = frozenset(remote_filtered_revs) |
1089 | 1089 |
1090 def remote_func(x): | 1090 def remote_func(x): |
1094 | 1094 |
1095 remote = repo.peer() | 1095 remote = repo.peer() |
1096 remote._repo = remote._repo.filtered(b'debug-discovery-remote-filter') | 1096 remote._repo = remote._repo.filtered(b'debug-discovery-remote-filter') |
1097 | 1097 |
1098 if local_revs: | 1098 if local_revs: |
1099 local_filtered_revs = scmutil.revrange( | 1099 local_filtered_revs = logcmdutil.revrange( |
1100 unfi, [b"not (::(%s))" % local_revs] | 1100 unfi, [b"not (::(%s))" % local_revs] |
1101 ) | 1101 ) |
1102 local_filtered_revs = frozenset(local_filtered_revs) | 1102 local_filtered_revs = frozenset(local_filtered_revs) |
1103 | 1103 |
1104 def local_func(x): | 1104 def local_func(x): |
1132 else: | 1132 else: |
1133 | 1133 |
1134 def doit(pushedrevs, remoteheads, remote=remote): | 1134 def doit(pushedrevs, remoteheads, remote=remote): |
1135 nodes = None | 1135 nodes = None |
1136 if pushedrevs: | 1136 if pushedrevs: |
1137 revs = scmutil.revrange(repo, pushedrevs) | 1137 revs = logcmdutil.revrange(repo, pushedrevs) |
1138 nodes = [repo[r].node() for r in revs] | 1138 nodes = [repo[r].node() for r in revs] |
1139 common, any, hds = setdiscovery.findcommonheads( | 1139 common, any, hds = setdiscovery.findcommonheads( |
1140 ui, repo, remote, ancestorsof=nodes, audit=data | 1140 ui, repo, remote, ancestorsof=nodes, audit=data |
1141 ) | 1141 ) |
1142 return common, hds | 1142 return common, hds |
2591 tr.release() | 2591 tr.release() |
2592 finally: | 2592 finally: |
2593 l.release() | 2593 l.release() |
2594 else: | 2594 else: |
2595 if opts[b'rev']: | 2595 if opts[b'rev']: |
2596 revs = scmutil.revrange(repo, opts[b'rev']) | 2596 revs = logcmdutil.revrange(repo, opts[b'rev']) |
2597 nodes = [repo[r].node() for r in revs] | 2597 nodes = [repo[r].node() for r in revs] |
2598 markers = list( | 2598 markers = list( |
2599 obsutil.getmarkers( | 2599 obsutil.getmarkers( |
2600 repo, nodes=nodes, exclusive=opts[b'exclusive'] | 2600 repo, nodes=nodes, exclusive=opts[b'exclusive'] |
2601 ) | 2601 ) |
4007 """ | 4007 """ |
4008 # passed to successorssets caching computation from one call to another | 4008 # passed to successorssets caching computation from one call to another |
4009 cache = {} | 4009 cache = {} |
4010 ctx2str = bytes | 4010 ctx2str = bytes |
4011 node2str = short | 4011 node2str = short |
4012 for rev in scmutil.revrange(repo, revs): | 4012 for rev in logcmdutil.revrange(repo, revs): |
4013 ctx = repo[rev] | 4013 ctx = repo[rev] |
4014 ui.write(b'%s\n' % ctx2str(ctx)) | 4014 ui.write(b'%s\n' % ctx2str(ctx)) |
4015 for succsset in obsutil.successorssets( | 4015 for succsset in obsutil.successorssets( |
4016 repo, ctx.node(), closest=opts['closest'], cache=cache | 4016 repo, ctx.node(), closest=opts['closest'], cache=cache |
4017 ): | 4017 ): |
4066 if opts['rev']: | 4066 if opts['rev']: |
4067 if repo is None: | 4067 if repo is None: |
4068 raise error.RepoError( | 4068 raise error.RepoError( |
4069 _(b'there is no Mercurial repository here (.hg not found)') | 4069 _(b'there is no Mercurial repository here (.hg not found)') |
4070 ) | 4070 ) |
4071 revs = scmutil.revrange(repo, opts['rev']) | 4071 revs = logcmdutil.revrange(repo, opts['rev']) |
4072 | 4072 |
4073 props = {} | 4073 props = {} |
4074 for d in opts['define']: | 4074 for d in opts['define']: |
4075 try: | 4075 try: |
4076 k, v = (e.strip() for e in d.split(b'=', 1)) | 4076 k, v = (e.strip() for e in d.split(b'=', 1)) |