Mercurial > hg-stable
changeset 48129:b74e128676d4
errors: raise InputError from revpair() iff revset provided by the user
Same reasoning as for `revrange()` in an earlier patch.
Differential Revision: https://phab.mercurial-scm.org/D11561
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 28 Sep 2021 13:59:01 -0700 |
parents | 5ced12cfa41b |
children | 5105a9975407 |
files | hgext/extdiff.py mercurial/commands.py mercurial/logcmdutil.py tests/autodiff.py |
diffstat | 4 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/extdiff.py Tue Sep 28 08:47:11 2021 -0700 +++ b/hgext/extdiff.py Tue Sep 28 13:59:01 2021 -0700 @@ -101,6 +101,7 @@ error, filemerge, formatter, + logcmdutil, pycompat, registrar, scmutil, @@ -568,7 +569,7 @@ ctx1b = repo[nullrev] ctx2 = scmutil.revsingle(repo, to_rev, None) else: - ctx1a, ctx2 = scmutil.revpair(repo, revs) + ctx1a, ctx2 = logcmdutil.revpair(repo, revs) if not revs: ctx1b = repo[None].p2() else:
--- a/mercurial/commands.py Tue Sep 28 08:47:11 2021 -0700 +++ b/mercurial/commands.py Tue Sep 28 13:59:01 2021 -0700 @@ -2610,7 +2610,7 @@ ctx2 = scmutil.revsingle(repo, to_rev, None) else: repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn') - ctx1, ctx2 = scmutil.revpair(repo, revs) + ctx1, ctx2 = logcmdutil.revpair(repo, revs) if reverse: ctxleft = ctx2 @@ -6909,7 +6909,7 @@ ctx1 = ctx2.p1() else: repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn') - ctx1, ctx2 = scmutil.revpair(repo, revs) + ctx1, ctx2 = logcmdutil.revpair(repo, revs) forcerelativevalue = None if ui.hasconfig(b'commands', b'status.relative'):
--- a/mercurial/logcmdutil.py Tue Sep 28 08:47:11 2021 -0700 +++ b/mercurial/logcmdutil.py Tue Sep 28 13:59:01 2021 -0700 @@ -912,6 +912,18 @@ return None +def revpair(repo, revs): + """Resolves user-provided revset(s) into two revisions. + + This just wraps the lower-level scmutil.revpair() in order to raise an + exception indicating user error. + """ + try: + return scmutil.revpair(repo, revs) + except error.RepoLookupError as e: + raise error.InputError(e.args[0], hint=e.hint) + + def revrange(repo, specs, localalias=None): """Resolves user-provided revset(s).
--- a/tests/autodiff.py Tue Sep 28 08:47:11 2021 -0700 +++ b/tests/autodiff.py Tue Sep 28 13:59:01 2021 -0700 @@ -4,6 +4,7 @@ from mercurial import ( error, + logcmdutil, patch, pycompat, registrar, @@ -49,7 +50,7 @@ else: raise error.Abort(b'--git must be yes, no or auto') - ctx1, ctx2 = scmutil.revpair(repo, []) + ctx1, ctx2 = logcmdutil.revpair(repo, []) m = scmutil.match(ctx2, pats, opts) it = patch.diff( repo,