comparison mercurial/revlog.py @ 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 1ce7a55b09d1
children ee3d58b4a47f
comparison
equal deleted inserted replaced
37766:925707ac2855 37767:44d1959acb3b
1498 if n: 1498 if n:
1499 return n 1499 return n
1500 1500
1501 raise LookupError(id, self.indexfile, _('no match found')) 1501 raise LookupError(id, self.indexfile, _('no match found'))
1502 1502
1503 def shortest(self, hexnode, minlength=1): 1503 def shortest(self, node, minlength=1):
1504 """Find the shortest unambiguous prefix that matches hexnode.""" 1504 """Find the shortest unambiguous prefix that matches node."""
1505 def isvalid(test): 1505 def isvalid(test):
1506 try: 1506 try:
1507 if self._partialmatch(test) is None: 1507 if self._partialmatch(test) is None:
1508 return False 1508 return False
1509 1509
1521 return False 1521 return False
1522 except error.WdirUnsupported: 1522 except error.WdirUnsupported:
1523 # single 'ff...' match 1523 # single 'ff...' match
1524 return True 1524 return True
1525 1525
1526 hexnode = hex(node)
1526 shortest = hexnode 1527 shortest = hexnode
1527 startlength = max(6, minlength) 1528 startlength = max(6, minlength)
1528 length = startlength 1529 length = startlength
1529 while True: 1530 while True:
1530 test = hexnode[:length] 1531 test = hexnode[:length]