Show More
@@ -747,25 +747,35 b' class revlog(object):' | |||
|
747 | 747 | return c |
|
748 | 748 | |
|
749 | 749 | def lookup(self, id): |
|
750 |
"""locate a node based on |
|
|
750 | """locate a node based on: | |
|
751 | - revision number or str(revision number) | |
|
752 | - nodeid or subset of hex nodeid | |
|
753 | """ | |
|
751 | 754 | if type(id) == type(0): |
|
755 | # rev | |
|
752 | 756 | return self.node(id) |
|
753 | 757 | try: |
|
758 | # str(rev) | |
|
754 | 759 | rev = int(id) |
|
755 | 760 | if str(rev) != id: raise ValueError |
|
756 | 761 | if rev < 0: rev = self.count() + rev |
|
757 | 762 | if rev < 0 or rev >= self.count(): raise ValueError |
|
758 | 763 | return self.node(rev) |
|
759 | 764 | except (ValueError, OverflowError): |
|
760 |
|
|
|
761 | for n in self.nodemap: | |
|
762 | if hex(n).startswith(id): | |
|
763 | c.append(n) | |
|
764 | if len(c) > 1: raise RevlogError(_("Ambiguous identifier")) | |
|
765 | if len(c) == 1: return c[0] | |
|
765 | pass | |
|
766 | # hex(node)[:...] | |
|
767 | node = None | |
|
768 | for n in self.nodemap: | |
|
769 | if hex(n).startswith(id): | |
|
770 | if node is not None: | |
|
771 | raise RevlogError(_("Ambiguous identifier")) | |
|
772 | node = n | |
|
773 | if node is not None: | |
|
774 | return node | |
|
766 | 775 | |
|
767 | 776 | # might need fixing if we change hash lengths |
|
768 | 777 | if len(id) == 20 and id in self.nodemap: |
|
778 | # node | |
|
769 | 779 | return id |
|
770 | 780 | |
|
771 | 781 | raise RevlogError(_("No match found")) |
General Comments 0
You need to be logged in to leave comments.
Login now