changeset 37767:44d1959acb3b

revlog: make shortest() take a full binary nodeid (API) Follow-up to 7b2955624777 (scmutil: make shortesthexnodeidprefix() take a full binary nodeid, 2018-04-14). Differential Revision: https://phab.mercurial-scm.org/D3403
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 16 Apr 2018 23:29:09 -0700
parents 925707ac2855
children 5527aa808dea
files mercurial/revlog.py mercurial/scmutil.py
diffstat 2 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Fri Apr 06 11:13:47 2018 -0400
+++ b/mercurial/revlog.py	Mon Apr 16 23:29:09 2018 -0700
@@ -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
--- a/mercurial/scmutil.py	Fri Apr 06 11:13:47 2018 -0400
+++ b/mercurial/scmutil.py	Mon Apr 16 23:29:09 2018 -0700
@@ -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.