Patchwork D9600: errors: raise InputError if an ambiguous revision id prefix is used

login
register
mail settings
Submitter phabricator
Date Dec. 14, 2020, 9:32 p.m.
Message ID <differential-rev-PHID-DREV-5brs2qulvbfno5mstfa3-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47899/
State Superseded
Headers show

Comments

phabricator - Dec. 14, 2020, 9:32 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  It's long bothered me that way include the "00changelog.i" part in a
  message to the user. This fixes that along with the exit code.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9600

AFFECTED FILES
  mercurial/revset.py
  mercurial/scmutil.py
  tests/test-revisions.t
  tests/test-revset.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -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)
diff --git a/tests/test-revisions.t b/tests/test-revisions.t
--- a/tests/test-revisions.t
+++ b/tests/test-revisions.t
@@ -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
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -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:
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2690,7 +2690,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):