mercurial/revlog.py
changeset 49262 3e5f1fb2aec7
parent 49261 31602d471b60
child 49263 63fd0282ad40
--- a/mercurial/revlog.py	Mon May 30 00:39:53 2022 +0200
+++ b/mercurial/revlog.py	Mon May 30 00:45:00 2022 +0200
@@ -1525,10 +1525,13 @@
             return self._pcache[id]
 
         if len(id) <= 40:
+            # hex(node)[:...]
+            l = len(id) // 2 * 2  # grab an even number of digits
             try:
-                # hex(node)[:...]
-                l = len(id) // 2 * 2  # grab an even number of digits
                 prefix = bin(id[:l])
+            except TypeError:
+                pass
+            else:
                 nl = [e[7] for e in self.index if e[7].startswith(prefix)]
                 nl = [
                     n for n in nl if hex(n).startswith(id) and self.hasnode(n)
@@ -1545,8 +1548,6 @@
                 if maybewdir:
                     raise error.WdirUnsupported
                 return None
-            except TypeError:
-                pass
 
     def lookup(self, id):
         """locate a node based on: