mercurial/revlog.py
changeset 49247 3e5f1fb2aec7
parent 49246 31602d471b60
child 49248 63fd0282ad40
equal deleted inserted replaced
49246:31602d471b60 49247:3e5f1fb2aec7
  1523 
  1523 
  1524         if id in self._pcache:
  1524         if id in self._pcache:
  1525             return self._pcache[id]
  1525             return self._pcache[id]
  1526 
  1526 
  1527         if len(id) <= 40:
  1527         if len(id) <= 40:
       
  1528             # hex(node)[:...]
       
  1529             l = len(id) // 2 * 2  # grab an even number of digits
  1528             try:
  1530             try:
  1529                 # hex(node)[:...]
       
  1530                 l = len(id) // 2 * 2  # grab an even number of digits
       
  1531                 prefix = bin(id[:l])
  1531                 prefix = bin(id[:l])
       
  1532             except TypeError:
       
  1533                 pass
       
  1534             else:
  1532                 nl = [e[7] for e in self.index if e[7].startswith(prefix)]
  1535                 nl = [e[7] for e in self.index if e[7].startswith(prefix)]
  1533                 nl = [
  1536                 nl = [
  1534                     n for n in nl if hex(n).startswith(id) and self.hasnode(n)
  1537                     n for n in nl if hex(n).startswith(id) and self.hasnode(n)
  1535                 ]
  1538                 ]
  1536                 if self.nodeconstants.nullhex.startswith(id):
  1539                 if self.nodeconstants.nullhex.startswith(id):
  1543                         id, self.display_id, _(b'ambiguous identifier')
  1546                         id, self.display_id, _(b'ambiguous identifier')
  1544                     )
  1547                     )
  1545                 if maybewdir:
  1548                 if maybewdir:
  1546                     raise error.WdirUnsupported
  1549                     raise error.WdirUnsupported
  1547                 return None
  1550                 return None
  1548             except TypeError:
       
  1549                 pass
       
  1550 
  1551 
  1551     def lookup(self, id):
  1552     def lookup(self, id):
  1552         """locate a node based on:
  1553         """locate a node based on:
  1553         - revision number or str(revision number)
  1554         - revision number or str(revision number)
  1554         - nodeid or subset of hex nodeid
  1555         - nodeid or subset of hex nodeid