diff mercurial/context.py @ 16185:352053e6cd8e

context: add followfirst arg to filectx and workingfilectx When _followfirst() revset was introduced it seemed to be the sole user of such an argument, so filectx.ancestors() was duplicated and modified instead. It now appears this argument could be used when computing the set of files to be considered when --patch or --stat are passed along with --follow FILE.
author Patrick Mezard <patrick@mezard.eu>
date Sun, 26 Feb 2012 17:10:57 +0100
parents a01d2fb5ba65
children 329887a7074c
line wrap: on
line diff
--- 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):