mercurial/context.py
changeset 10264 d6512b3e9ac0
parent 10176 24ce8f0c0a39
parent 10263 25e572394f5c
child 10282 08a0f04b56bd
--- a/mercurial/context.py	Mon Jan 18 22:59:32 2010 +0100
+++ b/mercurial/context.py	Tue Jan 19 22:45:09 2010 -0600
@@ -3,7 +3,7 @@
 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
 #
 # This software may be used and distributed according to the terms of the
-# GNU General Public License version 2, incorporated herein by reference.
+# GNU General Public License version 2 or any later version.
 
 from node import nullid, nullrev, short, hex
 from i18n import _
@@ -493,6 +493,17 @@
 
         return None
 
+    def ancestors(self):
+        seen = set(str(self))
+        visit = [self]
+        while visit:
+            for parent in visit.pop(0).parents():
+                s = str(parent)
+                if s not in seen:
+                    visit.append(parent)
+                    seen.add(s)
+                    yield parent
+
 class workingctx(changectx):
     """A workingctx object makes access to data related to
     the current working directory convenient.