[Updated] D10740: revlog: avoid raising no-arg RevlogError for internal flow control

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu May 20 13:22:17 UTC 2021


Closed by commit rHG93a0abe098e7: revlog: avoid raising no-arg RevlogError for internal flow control (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10740?vs=28088&id=28145

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10740/new/

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1538,28 +1538,33 @@
     def _partialmatch(self, id):
         # we don't care wdirfilenodeids as they should be always full hash
         maybewdir = self.nodeconstants.wdirhex.startswith(id)
+        ambiguous = False
         try:
             partial = self.index.partialmatch(id)
             if partial and self.hasnode(partial):
                 if maybewdir:
                     # single 'ff...' match in radix tree, ambiguous with wdir
-                    raise error.RevlogError
-                return partial
-            if maybewdir:
+                    ambiguous = True
+                else:
+                    return partial
+            elif maybewdir:
                 # no 'ff...' match in radix tree, wdir identified
                 raise error.WdirUnsupported
-            return None
+            else:
+                return None
         except error.RevlogError:
             # parsers.c radix tree lookup gave multiple matches
             # fast path: for unfiltered changelog, radix tree is accurate
             if not getattr(self, 'filteredrevs', None):
-                raise error.AmbiguousPrefixLookupError(
-                    id, self.display_id, _(b'ambiguous identifier')
-                )
+                ambiguous = True
             # 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
             pass
+        if ambiguous:
+            raise error.AmbiguousPrefixLookupError(
+                id, self.display_id, _(b'ambiguous identifier')
+            )
 
         if id in self._pcache:
             return self._pcache[id]



To: martinvonz, indygreg, #hg-reviewers, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210520/dfe6e033/attachment-0002.html>


More information about the Mercurial-patches mailing list