Show More
@@ -754,6 +754,15 b' class revlog(object):' | |||||
754 | if isinstance(id, (long, int)): |
|
754 | if isinstance(id, (long, int)): | |
755 | # rev |
|
755 | # rev | |
756 | return self.node(id) |
|
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 | try: |
|
766 | try: | |
758 | # str(rev) |
|
767 | # str(rev) | |
759 | rev = int(id) |
|
768 | rev = int(id) | |
@@ -764,27 +773,25 b' class revlog(object):' | |||||
764 | except (ValueError, OverflowError): |
|
773 | except (ValueError, OverflowError): | |
765 | pass |
|
774 | pass | |
766 | try: |
|
775 | try: | |
767 |
|
|
776 | if len(id) == 40: | |
768 | if len(id) % 2 == 0: |
|
777 | # a full hex nodeid? | |
769 |
|
|
778 | node = bin(id) | |
770 | else: |
|
779 | r = self.rev(node) | |
771 | bin_id = bin(id[:-1]) |
|
|||
772 | node = None |
|
|||
773 | for n in self.nodemap: |
|
|||
774 | if n.startswith(bin_id) and hex(n).startswith(id): |
|
|||
775 | if node is not None: |
|
|||
776 | raise RevlogError(_("Ambiguous identifier")) |
|
|||
777 | node = n |
|
|||
778 | if node is not None: |
|
|||
779 | return node |
|
780 | return node | |
|
781 | elif len(id) < 40: | |||
|
782 | # hex(node)[:...] | |||
|
783 | bin_id = bin(id[:len(id) & ~1]) # grab an even number of digits | |||
|
784 | node = None | |||
|
785 | for n in self.nodemap: | |||
|
786 | if n.startswith(bin_id) and hex(n).startswith(id): | |||
|
787 | if node is not None: | |||
|
788 | raise RevlogError(_("Ambiguous identifier")) | |||
|
789 | node = n | |||
|
790 | if node is not None: | |||
|
791 | return node | |||
780 | except TypeError: |
|
792 | except TypeError: | |
781 | pass |
|
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 | raise RevlogError(_("No match found")) |
|
795 | raise RevlogError(_("No match found")) | |
789 |
|
796 | |||
790 | def cmp(self, node, text): |
|
797 | def cmp(self, node, text): |
General Comments 0
You need to be logged in to leave comments.
Login now