core: don't hard-code node length
authorJoerg Sonnenberger <joerg@bec.de>
Fri, 30 Apr 2021 03:19:45 +0200
changeset 47042 c5e1cc0b4c77
parent 47041 a407fe56d6e8
child 47043 12450fbea288
core: don't hard-code node length Differential Revision: https://phab.mercurial-scm.org/D10536
mercurial/localrepo.py
mercurial/revlog.py
--- a/mercurial/localrepo.py	Fri Apr 30 03:09:16 2021 +0200
+++ b/mercurial/localrepo.py	Fri Apr 30 03:19:45 2021 +0200
@@ -1840,7 +1840,7 @@
                 # when we know that '.' won't be hidden
                 node = self.dirstate.p1()
                 rev = self.unfiltered().changelog.rev(node)
-            elif len(changeid) == 20:
+            elif len(changeid) == self.nodeconstants.nodelen:
                 try:
                     node = changeid
                     rev = self.changelog.rev(changeid)
--- a/mercurial/revlog.py	Fri Apr 30 03:09:16 2021 +0200
+++ b/mercurial/revlog.py	Fri Apr 30 03:19:45 2021 +0200
@@ -1299,7 +1299,7 @@
         if isinstance(id, int):
             # rev
             return self.node(id)
-        if len(id) == 20:
+        if len(id) == self.nodeconstants.nodelen:
             # possibly a binary node
             # odds of a binary node being all hex in ASCII are 1 in 10**25
             try: