sqlitestore: add an `ancestors` method
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 09 Nov 2022 13:54:15 -0500
changeset 49671 92c65bd0c4d6
parent 49670 2fd8750f3722
child 49672 e92de86cf4f8
sqlitestore: add an `ancestors` method We will need it during bundling. The implementation mirror the one in revlog.
hgext/sqlitestore.py
--- a/hgext/sqlitestore.py	Thu Nov 24 04:04:19 2022 +0100
+++ b/hgext/sqlitestore.py	Wed Nov 09 13:54:15 2022 -0500
@@ -429,6 +429,25 @@
         entry = self._revisions[self._revtonode[rev]]
         return entry.p1rev, entry.p2rev
 
+    def ancestors(self, revs, stoprev=0, inclusive=False):
+        """Generate the ancestors of 'revs' in reverse revision order.
+        Does not generate revs lower than stoprev.
+
+        See the documentation for ancestor.lazyancestors for more details."""
+
+        # first, make sure start revisions aren't filtered
+        revs = list(revs)
+        checkrev = self.node
+        for r in revs:
+            checkrev(r)
+
+        return ancestor.lazyancestors(
+            self.parentrevs,
+            revs,
+            stoprev=stoprev,
+            inclusive=inclusive,
+        )
+
     def rev(self, node):
         if node == sha1nodeconstants.nullid:
             return nullrev