##// END OF EJS Templates
Speedup revlog.ancestors for the linear case...
Chris Mason -
r2081:416d8b2a default
parent child Browse files
Show More
@@ -940,6 +940,24 b' class revlog(object):'
940 940
941 941 def ancestor(self, a, b):
942 942 """calculate the least common ancestor of nodes a and b"""
943
944 # start with some short cuts for the linear cases
945 if a == b:
946 return a
947 ra = self.rev(a)
948 rb = self.rev(b)
949 if ra < rb:
950 last = b
951 first = a
952 else:
953 last = a
954 first = b
955
956 # reachable won't include stop in the list, so we have to use a parent
957 reachable = self.reachable(last, stop=self.parents(first)[0])
958 if first in reachable:
959 return first
960
943 961 # calculate the distance of every node from root
944 962 dist = {nullid: 0}
945 963 for i in xrange(self.count()):
General Comments 0
You need to be logged in to leave comments. Login now