Patchwork D3403: revlog: make shortest() take a full binary nodeid (API)

login
register
mail settings
Submitter phabricator
Date April 17, 2018, 2:51 p.m.
Message ID <differential-rev-PHID-DREV-xhc2ml2nfr4rx3szettd-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/31168/
State Superseded
Headers show

Comments

phabricator - April 17, 2018, 2:51 p.m.
martinvonz created this revision.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Follow-up to https://phab.mercurial-scm.org/rHG7b29556247776a86ead7eb98fd3a20dafd0c08b4 (scmutil: make shortesthexnodeidprefix()
  take a full binary nodeid, 2018-04-14).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlog.py
  mercurial/scmutil.py

CHANGE DETAILS




To: martinvonz, indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -448,7 +448,7 @@ 
     # _partialmatch() of filtered changelog could take O(len(repo)) time,
     # which would be unacceptably slow. so we look for hash collision in
     # unfiltered space, which means some hashes may be slightly longer.
-    return repo.unfiltered().changelog.shortest(hex(node), minlength)
+    return repo.unfiltered().changelog.shortest(node, minlength)
 
 def isrevsymbol(repo, symbol):
     """Checks if a symbol exists in the repo.
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1500,8 +1500,8 @@ 
 
         raise LookupError(id, self.indexfile, _('no match found'))
 
-    def shortest(self, hexnode, minlength=1):
-        """Find the shortest unambiguous prefix that matches hexnode."""
+    def shortest(self, node, minlength=1):
+        """Find the shortest unambiguous prefix that matches node."""
         def isvalid(test):
             try:
                 if self._partialmatch(test) is None:
@@ -1523,6 +1523,7 @@ 
                 # single 'ff...' match
                 return True
 
+        hexnode = hex(node)
         shortest = hexnode
         startlength = max(6, minlength)
         length = startlength