mercurial/revlog.py
changeset 37908 890bdf0e33c8
parent 37907 6921d3ecadc1
child 37909 da083d9fafab
equal deleted inserted replaced
37907:6921d3ecadc1 37908:890bdf0e33c8
  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, node, minlength=1):
  1503     def shortest(self, node, minlength=1):
  1504         """Find the shortest unambiguous prefix that matches node."""
  1504         """Find the shortest unambiguous prefix that matches node."""
       
  1505         def isrev(prefix):
       
  1506             try:
       
  1507                 i = int(prefix)
       
  1508                 # if we are a pure int, then starting with zero will not be
       
  1509                 # confused as a rev; or, obviously, if the int is larger
       
  1510                 # than the value of the tip rev
       
  1511                 if prefix[0] == '0' or i > len(self):
       
  1512                     return False
       
  1513                 return True
       
  1514             except ValueError:
       
  1515                 return False
       
  1516 
  1505         def isvalid(prefix):
  1517         def isvalid(prefix):
  1506             try:
  1518             try:
  1507                 if self._partialmatch(prefix) is None:
  1519                 if self._partialmatch(prefix) is None:
  1508                     return False
  1520                     return False
  1509             except error.RevlogError:
  1521             except error.RevlogError:
  1510                 return False
  1522                 return False
  1511             except error.WdirUnsupported:
  1523             except error.WdirUnsupported:
  1512                 # single 'ff...' match
  1524                 # single 'ff...' match
  1513                 return True
  1525                 return True
  1514             try:
  1526             return not isrev(prefix)
  1515                 i = int(prefix)
       
  1516                 # if we are a pure int, then starting with zero will not be
       
  1517                 # confused as a rev; or, obviously, if the int is larger
       
  1518                 # than the value of the tip rev
       
  1519                 if prefix[0] == '0' or i > len(self):
       
  1520                     return True
       
  1521                 return False
       
  1522             except ValueError:
       
  1523                 return True
       
  1524 
  1527 
  1525         hexnode = hex(node)
  1528         hexnode = hex(node)
  1526         shortest = hexnode
  1529         shortest = hexnode
  1527         startlength = max(6, minlength)
  1530         startlength = max(6, minlength)
  1528         length = startlength
  1531         length = startlength