mercurial/context.py
changeset 16185 352053e6cd8e
parent 16151 a01d2fb5ba65
child 16373 329887a7074c
--- a/mercurial/context.py	Sun Feb 26 17:10:57 2012 +0100
+++ b/mercurial/context.py	Sun Feb 26 17:10:57 2012 +0100
@@ -611,11 +611,12 @@
 
         return None
 
-    def ancestors(self):
+    def ancestors(self, followfirst=False):
         visit = {}
         c = self
+        cut = followfirst and 1 or None
         while True:
-            for parent in c.parents():
+            for parent in c.parents()[:cut]:
                 visit[(parent.rev(), parent.node())] = parent
             if not visit:
                 break
@@ -930,9 +931,10 @@
         finally:
             wlock.release()
 
-    def ancestors(self):
+    def ancestors(self, followfirst=False):
+        cut = followfirst and 1 or None
         for a in self._repo.changelog.ancestors(
-            *[p.rev() for p in self._parents]):
+            *[p.rev() for p in self._parents[:cut]]):
             yield changectx(self._repo, a)
 
     def undelete(self, list):