# HG changeset patch # User Joerg Sonnenberger # Date 2021-04-29 20:01:04 # Node ID 5698c5eee12b5bfc5e08e9c8ba3a3c96616c6c1a # Parent 380ed77e9ad3f1b6143ef0006be501ebd2a757b4 storageutil: match node length with repository diff --git a/mercurial/utils/storageutil.py b/mercurial/utils/storageutil.py --- a/mercurial/utils/storageutil.py +++ b/mercurial/utils/storageutil.py @@ -190,9 +190,9 @@ def fileidlookup(store, fileid, identifi ``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 @@ def fileidlookup(store, fileid, identifi 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)