[PATCH 1 of 6 v8] revlog: add incancestors, a version of ancestors that includes revs listed

Joshua Redstone joshua.redstone at fb.com
Tue Jun 19 15:21:14 CDT 2012


# HG changeset patch
# User Joshua Redstone <joshua.redstone at fb.com>
# Date 1339167577 25200
# Node ID 23a373252eb5c147433d4af6f212a6785f7498ab
# Parent  132ea1736751cb02b16992cf421e7de8bad888a1
revlog: add incancestors, a version of ancestors that includes revs listed

ancestors() returns the ancestors of revs provided. This func is like
that except it also includes the revs themselves in the total set of
revs generated.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -404,6 +404,14 @@
                     seen.add(parent)
                     yield parent
 
+    def incancestors(self, revs, stoprev=0):
+        """Identical to ancestors() except it also generates the
+        revisions, 'revs'"""
+        for rev in revs:
+            yield rev
+        for rev in self.ancestors(revs, stoprev):
+            yield rev
+
     def descendants(self, revs):
         """Generate the descendants of 'revs' in revision order.
 


More information about the Mercurial-devel mailing list