##// END OF EJS Templates
lookup: speed up partial lookup
Matt Mackall -
r7365:ec3aafa8 default
parent child Browse files
Show More
@@ -873,16 +873,16 b' class revlog(object):'
873 if len(id) < 40:
873 if len(id) < 40:
874 try:
874 try:
875 # hex(node)[:...]
875 # hex(node)[:...]
876 bin_id = bin(id[:len(id) & ~1]) # grab an even number of digits
876 l = len(id) / 2 # grab an even number of digits
877 node = None
877 bin_id = bin(id[:l*2])
878 for n in self.nodemap:
878 nl = [n for n in self.nodemap if n[:l] == bin_id]
879 if n.startswith(bin_id) and hex(n).startswith(id):
879 nl = [n for n in nl if hex(n).startswith(id)]
880 if node is not None:
880 if len(nl) > 0:
881 raise LookupError(id, self.indexfile,
881 if len(nl) == 1:
882 _('ambiguous identifier'))
882 return nl[0]
883 node = n
883 raise LookupError(id, self.indexfile,
884 if node is not None:
884 _('ambiguous identifier'))
885 return node
885 return None
886 except TypeError:
886 except TypeError:
887 pass
887 pass
888
888
General Comments 0
You need to be logged in to leave comments. Login now