Patchwork D4036: revlog: use specialized exception for ambiguous prefix lookup

login
register
mail settings
Submitter phabricator
Date Aug. 4, 2018, 3:12 a.m.
Message ID <1ca900607228c7772d24010e3b2fb8f2@localhost.localdomain>
Download mbox | patch
Permalink /patch/33209/
State Not Applicable
Headers show

Comments

phabricator - Aug. 4, 2018, 3:12 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGdf0873ab5c14: revlog: use specialized exception for ambiguous prefix lookup (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4036?vs=9752&id=9875

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

AFFECTED FILES
  mercurial/error.py
  mercurial/localrepo.py
  mercurial/revlog.py
  mercurial/scmutil.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -480,8 +480,8 @@ 
 def isrevsymbol(repo, symbol):
     """Checks if a symbol exists in the repo.
 
-    See revsymbol() for details. Raises error.LookupError if the symbol is an
-    ambiguous nodeid prefix.
+    See revsymbol() for details. Raises error.AmbiguousPrefixLookupError if the
+    symbol is an ambiguous nodeid prefix.
     """
     try:
         revsymbol(repo, symbol)
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -91,6 +91,7 @@ 
 
 RevlogError = error.RevlogError
 LookupError = error.LookupError
+AmbiguousPrefixLookupError = error.AmbiguousPrefixLookupError
 CensoredNodeError = error.CensoredNodeError
 ProgrammingError = error.ProgrammingError
 
@@ -1788,8 +1789,8 @@ 
             # parsers.c radix tree lookup gave multiple matches
             # fast path: for unfiltered changelog, radix tree is accurate
             if not getattr(self, 'filteredrevs', None):
-                raise LookupError(id, self.indexfile,
-                                  _('ambiguous identifier'))
+                raise AmbiguousPrefixLookupError(id, self.indexfile,
+                                                 _('ambiguous identifier'))
             # fall through to slow path that filters hidden revisions
         except (AttributeError, ValueError):
             # we are pure python, or key was too short to search radix tree
@@ -1810,8 +1811,8 @@ 
                     if len(nl) == 1 and not maybewdir:
                         self._pcache[id] = nl[0]
                         return nl[0]
-                    raise LookupError(id, self.indexfile,
-                                      _('ambiguous identifier'))
+                    raise AmbiguousPrefixLookupError(id, self.indexfile,
+                                                     _('ambiguous identifier'))
                 if maybewdir:
                     raise error.WdirUnsupported
                 return None
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -860,7 +860,8 @@ 
     def __contains__(self, changeid):
         """True if the given changeid exists
 
-        error.LookupError is raised if an ambiguous node specified.
+        error.AmbiguousPrefixLookupError is raised if an ambiguous node
+        specified.
         """
         try:
             self[changeid]
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -58,6 +58,9 @@ 
     def __str__(self):
         return RevlogError.__str__(self)
 
+class AmbiguousPrefixLookupError(LookupError):
+    pass
+
 class FilteredLookupError(LookupError):
     pass