##// END OF EJS Templates
revlog.lookup tweaks...
Matt Mackall -
r3438:b17f9d3e default
parent child Browse files
Show More
@@ -754,6 +754,15 b' class revlog(object):'
754 754 if isinstance(id, (long, int)):
755 755 # rev
756 756 return self.node(id)
757 if len(id) == 20:
758 # possibly a binary node
759 # odds of a binary node being all hex in ASCII are 1 in 10**25
760 try:
761 node = id
762 r = self.rev(node) # quick search the index
763 return node
764 except RevlogError:
765 pass # may be partial hex id
757 766 try:
758 767 # str(rev)
759 768 rev = int(id)
@@ -764,11 +773,14 b' class revlog(object):'
764 773 except (ValueError, OverflowError):
765 774 pass
766 775 try:
776 if len(id) == 40:
777 # a full hex nodeid?
778 node = bin(id)
779 r = self.rev(node)
780 return node
781 elif len(id) < 40:
767 782 # hex(node)[:...]
768 if len(id) % 2 == 0:
769 bin_id = bin(id)
770 else:
771 bin_id = bin(id[:-1])
783 bin_id = bin(id[:len(id) & ~1]) # grab an even number of digits
772 784 node = None
773 785 for n in self.nodemap:
774 786 if n.startswith(bin_id) and hex(n).startswith(id):
@@ -780,11 +792,6 b' class revlog(object):'
780 792 except TypeError:
781 793 pass
782 794
783 # might need fixing if we change hash lengths
784 if len(id) == 20 and id in self.nodemap:
785 # node
786 return id
787
788 795 raise RevlogError(_("No match found"))
789 796
790 797 def cmp(self, node, text):
General Comments 0
You need to be logged in to leave comments. Login now