##// 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,14 +336,17 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 raise repo.RepoError(_("unknown revision '%s'") % key)
346 n = self.changelog._partialmatch(key)
347 if n:
348 return n
349 raise repo.RepoError(_("unknown revision '%s'") % key)
347 350
348 351 def dev(self):
349 352 return os.lstat(self.path).st_dev
@@ -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
775 try:
776 if len(id) == 40:
771 if len(id) == 40:
772 try:
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
@@ -789,8 +790,21 b' class revlog(object):'
789 790 node = n
790 791 if node is not None:
791 792 return node
792 except TypeError:
793 pass
793 except TypeError:
794 pass
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
794 808
795 809 raise RevlogError(_("No match found"))
796 810
General Comments 0
You need to be logged in to leave comments. Login now