storageutil: match node length with repository
authorJoerg Sonnenberger <joerg@bec.de>
Thu, 29 Apr 2021 22:01:04 +0200
changeset 49967 5698c5eee12b
parent 49966 380ed77e9ad3
child 49972 1bd33932713d
storageutil: match node length with repository
mercurial/utils/storageutil.py
--- a/mercurial/utils/storageutil.py	Tue Dec 13 12:50:52 2022 +0100
+++ b/mercurial/utils/storageutil.py	Thu Apr 29 22:01:04 2021 +0200
@@ -190,9 +190,9 @@
 
     ``fileid`` can be:
 
-    * A 20 or 32 byte binary node.
+    * A binary node of appropiate size (e.g. 20/32 Bytes).
     * An integer revision number
-    * A 40 or 64 byte hex node.
+    * A hex node of appropiate size (e.g. 40/64 Bytes).
     * A bytes that can be parsed as an integer representing a revision number.
 
     ``identifier`` is used to populate ``error.LookupError`` with an identifier
@@ -208,14 +208,14 @@
                 b'%d' % fileid, identifier, _(b'no match found')
             )
 
-    if len(fileid) in (20, 32):
+    if len(fileid) == len(store.nullid):
         try:
             store.rev(fileid)
             return fileid
         except error.LookupError:
             pass
 
-    if len(fileid) in (40, 64):
+    if len(fileid) == 2 * len(store.nullid):
         try:
             rawnode = bin(fileid)
             store.rev(rawnode)