errors: raise InputError if an ambiguous revision id prefix is used
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 09 Dec 2020 20:22:25 -0800
changeset 46115 be3d8178251e
parent 46114 c6ae1982b2a1
child 46116 17a695357270
errors: raise InputError if an ambiguous revision id prefix is used It's long bothered me that we include the "00changelog.i" part in a message to the user. This fixes that along with the exit code. Differential Revision: https://phab.mercurial-scm.org/D9600
mercurial/revset.py
mercurial/scmutil.py
tests/test-revisions.t
tests/test-revset.t
--- a/mercurial/revset.py	Thu Dec 10 01:18:15 2020 -0800
+++ b/mercurial/revset.py	Wed Dec 09 20:22:25 2020 -0800
@@ -2691,7 +2691,15 @@
 
 
 def lookupfn(repo):
-    return lambda symbol: scmutil.isrevsymbol(repo, symbol)
+    def fn(symbol):
+        try:
+            return scmutil.isrevsymbol(repo, symbol)
+        except error.AmbiguousPrefixLookupError:
+            raise error.InputError(
+                b'ambiguous revision identifier: %s' % symbol
+            )
+
+    return fn
 
 
 def match(ui, spec, lookup=None):
--- a/mercurial/scmutil.py	Thu Dec 10 01:18:15 2020 -0800
+++ b/mercurial/scmutil.py	Wed Dec 09 20:22:25 2020 -0800
@@ -1798,7 +1798,7 @@
             k = encoding.tolocal(k)
             try:
                 data[revsingle(repo, k).rev()] = encoding.tolocal(v)
-            except (error.LookupError, error.RepoLookupError):
+            except (error.LookupError, error.RepoLookupError, error.InputError):
                 pass  # we ignore data for nodes that don't exist locally
     finally:
         if proc:
--- a/tests/test-revisions.t	Thu Dec 10 01:18:15 2020 -0800
+++ b/tests/test-revisions.t	Wed Dec 09 20:22:25 2020 -0800
@@ -36,8 +36,8 @@
   1:9
 7 was ambiguous and still is
   $ hg l -r 7
-  abort: 00changelog.i@7: ambiguous identifier
-  [255]
+  abort: ambiguous revision identifier: 7
+  [10]
 7b is no longer ambiguous
   $ hg l -r 7b
   3:7b
--- a/tests/test-revset.t	Thu Dec 10 01:18:15 2020 -0800
+++ b/tests/test-revset.t	Wed Dec 09 20:22:25 2020 -0800
@@ -1873,8 +1873,8 @@
   3
   $ hg log --template '{rev}\n' -r 'id(x)'
   $ hg log --template '{rev}\n' -r 'x'
-  abort: 00changelog.i@: ambiguous identifier
-  [255]
+  abort: ambiguous revision identifier: x
+  [10]
   $ log 'id(23268)'
   4
   $ log 'id(2785f51eece)'
@@ -2040,14 +2040,14 @@
   obsoleted 1 changesets
 
   $ hg debugrevspec 'fff'
-  abort: 00changelog.i@fff: ambiguous identifier
-  [255]
+  abort: ambiguous revision identifier: fff
+  [10]
   $ hg debugrevspec 'ffff'
-  abort: 00changelog.i@ffff: ambiguous identifier
-  [255]
+  abort: ambiguous revision identifier: ffff
+  [10]
   $ hg debugrevspec 'fffb'
-  abort: 00changelog.i@fffb: ambiguous identifier
-  [255]
+  abort: ambiguous revision identifier: fffb
+  [10]
 BROKEN should be '2' (node lookup uses unfiltered repo)
   $ hg debugrevspec 'id(fffb)'
 BROKEN should be '2' (node lookup uses unfiltered repo)