Patchwork D8683: revlog: avoid hard-coded hash sizes

login
register
mail settings
Submitter phabricator
Date July 6, 2020, 12:44 p.m.
Message ID <differential-rev-PHID-DREV-qly7fzbtkuzcjmeepltf-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46636/
State Superseded
Headers show

Comments

phabricator - July 6, 2020, 12:44 p.m.
joerg.sonnenberger created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




To: joerg.sonnenberger, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1523,7 +1523,7 @@ 
 
         def disambiguate(hexnode, minlength):
             """Disambiguate against wdirid."""
-            for length in range(minlength, 41):
+            for length in range(minlength, len(hexnode) + 1):
                 prefix = hexnode[:length]
                 if not maybewdir(prefix):
                     return prefix
@@ -1540,12 +1540,12 @@ 
                 pass
 
         if node == wdirid:
-            for length in range(minlength, 41):
+            for length in range(minlength, len(hexnode) + 1):
                 prefix = hexnode[:length]
                 if isvalid(prefix):
                     return prefix
 
-        for length in range(minlength, 41):
+        for length in range(minlength, len(hexnode) + 1):
             prefix = hexnode[:length]
             if isvalid(prefix):
                 return disambiguate(hexnode, length)