revlog: fix up previously stupid API change
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Sat, 06 Feb 2010 12:47:17 +0100
changeset 10329 ae0ae8691e47
parent 10328 0798a3d5f812
child 10330 d8c0e6c43791
revlog: fix up previously stupid API change
mercurial/revlog.py
--- a/mercurial/revlog.py	Sat Feb 06 11:29:48 2010 +0100
+++ b/mercurial/revlog.py	Sat Feb 06 12:47:17 2010 +0100
@@ -1137,21 +1137,21 @@
             self._cache = (node, curr, text)
         return node
 
-    def descendant(self, a, b):
-        if a > b:
-            return False
-        for i in self.descendants(a):
-            if i == b:
+    def descendant(self, start, end):
+        for i in self.descendants(start):
+            if i == end:
                 return True
-            elif i > b:
+            elif i > end:
                 break
         return False
 
     def ancestor(self, a, b):
         """calculate the least common ancestor of nodes a and b"""
 
+        # fast path, check if it is a descendant
+        a, b = self.rev(a), self.rev(b)
         start, end = sorted((a, b))
-        if self.descendant(a, b):
+        if self.descendant(start, end):
             return self.node(start)
 
         def parents(rev):