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

Joshua Redstone joshua.redstone at fb.com
Fri Jun 8 16:27:38 CDT 2012


# HG changeset patch
# User Joshua Redstone <joshua.redstone at fb.com>
# Date 1339167577 25200
# Node ID 2c865a9bca7431eba9de9bcefad0f114f5050ea0
# Parent  d566aa319d5f7c58c69b985b53ff7498f08e53c6
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 -r d566aa319d5f -r 2c865a9bca74 mercurial/revlog.py
--- a/mercurial/revlog.py	Mon Jun 04 17:57:57 2012 -0500
+++ b/mercurial/revlog.py	Fri Jun 08 07:59:37 2012 -0700
@@ -401,6 +401,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