##// END OF EJS Templates
Only look up tags and branches as a last resort
Matt Mackall -
r3453:dba3cade default
parent child Browse files
Show More
@@ -336,13 +336,16 b' class localrepository(repo.repository):'
336 336 key = self.dirstate.parents()[0]
337 337 if key == nullid:
338 338 raise repo.RepoError(_("no revision checked out"))
339 n = self.changelog._match(key)
340 if n:
341 return n
339 342 if key in self.tags():
340 343 return self.tags()[key]
341 344 if key in self.branchtags():
342 345 return self.branchtags()[key]
343 try:
344 return self.changelog.lookup(key)
345 except:
346 n = self.changelog._partialmatch(key)
347 if n:
348 return n
346 349 raise repo.RepoError(_("unknown revision '%s'") % key)
347 350
348 351 def dev(self):
@@ -746,11 +746,7 b' class revlog(object):'
746 746 continue
747 747 return c
748 748
749 def lookup(self, id):
750 """locate a node based on:
751 - revision number or str(revision number)
752 - nodeid or subset of hex nodeid
753 """
749 def _match(self, id):
754 750 if isinstance(id, (long, int)):
755 751 # rev
756 752 return self.node(id)
@@ -772,13 +768,18 b' class revlog(object):'
772 768 return self.node(rev)
773 769 except (ValueError, OverflowError):
774 770 pass
771 if len(id) == 40:
775 772 try:
776 if len(id) == 40:
777 773 # a full hex nodeid?
778 774 node = bin(id)
779 775 r = self.rev(node)
780 776 return node
781 elif len(id) < 40:
777 except TypeError:
778 pass
779
780 def _partialmatch(self, id):
781 if len(id) < 40:
782 try:
782 783 # hex(node)[:...]
783 784 bin_id = bin(id[:len(id) & ~1]) # grab an even number of digits
784 785 node = None
@@ -792,6 +793,19 b' class revlog(object):'
792 793 except TypeError:
793 794 pass
794 795
796 def lookup(self, id):
797 """locate a node based on:
798 - revision number or str(revision number)
799 - nodeid or subset of hex nodeid
800 """
801
802 n = self._match(id)
803 if n is not None:
804 return n
805 n = self._partialmatch(id)
806 if n:
807 return n
808
795 809 raise RevlogError(_("No match found"))
796 810
797 811 def cmp(self, node, text):
General Comments 0
You need to be logged in to leave comments. Login now