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