diff mercurial/commands.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 b067d22dc6ad
children b74e128676d4
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Sep 28 09:08:43 2021 -0700
+++ b/mercurial/commands.py	Tue Sep 28 08:47:11 2021 -0700
@@ -536,7 +536,7 @@
     )
     skiprevs = opts.get(b'skip')
     if skiprevs:
-        skiprevs = scmutil.revrange(repo, skiprevs)
+        skiprevs = logcmdutil.revrange(repo, skiprevs)
 
     uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
     for abs in ctx.walk(m):
@@ -1037,7 +1037,7 @@
     state = hbisect.load_state(repo)
 
     if rev:
-        nodes = [repo[i].node() for i in scmutil.revrange(repo, rev)]
+        nodes = [repo[i].node() for i in logcmdutil.revrange(repo, rev)]
     else:
         nodes = [repo.lookup(b'.')]
 
@@ -1424,7 +1424,7 @@
     revs = opts.get(b'rev')
     selectedbranches = None
     if revs:
-        revs = scmutil.revrange(repo, revs)
+        revs = logcmdutil.revrange(repo, revs)
         getbi = repo.revbranchcache().branchinfo
         selectedbranches = {getbi(r)[0] for r in revs}
 
@@ -1558,7 +1558,7 @@
     revs = None
     if b'rev' in opts:
         revstrings = opts[b'rev']
-        revs = scmutil.revrange(repo, revstrings)
+        revs = logcmdutil.revrange(repo, revstrings)
         if revstrings and not revs:
             raise error.InputError(_(b'no commits to bundle'))
 
@@ -1590,7 +1590,7 @@
             ui.warn(_(b"ignoring --base because --all was specified\n"))
         base = [nullrev]
     else:
-        base = scmutil.revrange(repo, opts.get(b'base'))
+        base = logcmdutil.revrange(repo, opts.get(b'base'))
     if cgversion not in changegroup.supportedoutgoingversions(repo):
         raise error.Abort(
             _(b"repository does not support bundle version %s") % cgversion
@@ -2753,7 +2753,7 @@
             changesets = [b'.']
 
         repo = scmutil.unhidehashlikerevs(repo, changesets, b'nowarn')
-        revs = scmutil.revrange(repo, changesets)
+        revs = logcmdutil.revrange(repo, changesets)
 
     if not revs:
         raise error.InputError(_(b"export requires at least one changeset"))
@@ -3170,7 +3170,7 @@
             raise error.InputError(_(b'no revisions specified'))
         cmdutil.checkunfinished(repo)
         cmdutil.bailifchanged(repo)
-        revs = scmutil.revrange(repo, revs)
+        revs = logcmdutil.revrange(repo, revs)
 
     skipped = set()
     basectx = None
@@ -3708,7 +3708,7 @@
 
     if branchrevs:
         branches = {
-            repo[r].branch() for r in scmutil.revrange(repo, branchrevs)
+            repo[r].branch() for r in logcmdutil.revrange(repo, branchrevs)
         }
         heads = [h for h in heads if h.branch() in branches]
 
@@ -5220,7 +5220,7 @@
     revs = list(revs)
     revs.extend(opts[b'rev'])
     if revs:
-        revs = scmutil.revrange(repo, revs)
+        revs = logcmdutil.revrange(repo, revs)
     else:
         # display both parents as the second parent phase can influence
         # the phase of a merge commit
@@ -5735,7 +5735,7 @@
 
         try:
             if revs:
-                revs = [repo[r].node() for r in scmutil.revrange(repo, revs)]
+                revs = [repo[r].node() for r in logcmdutil.revrange(repo, revs)]
                 if not revs:
                     raise error.InputError(
                         _(b"specified revisions evaluate to an empty set"),