merge-slicing: use reachable roots to filter the various branches
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Fri, 24 Mar 2017 06:36:12 +0100
changeset 2216 de76219b42b8
parent 2215 6d9cadc635d5
child 2217 37fa3d83f294
merge-slicing: use reachable roots to filter the various branches Reachable roots does what we want and have a quite fast C implementation.
hgext3rd/evolve/stablerange.py
--- a/hgext3rd/evolve/stablerange.py	Fri Mar 24 05:51:20 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Fri Mar 24 06:36:12 2017 +0100
@@ -428,11 +428,17 @@
             parentrevs = cl.parentrevs
             parents = self._parents
             du = bheads.difference_update
+            reachableroots = repo.changelog.reachableroots
             for r in bottomrevs:
                 du(parents(r, parentrevs))
             for h in bheads:
-                subset = cl.ancestors([h], inclusive=True)
-                hrevs = [r for r in bottomrevs if r in subset]
+                # reachable roots is fast because is C
+                #
+                # It is worth noting that will use this kind of filtering from
+                # "h" multiple time in a warming run. So using "ancestors" and
+                # caching that should be faster. But python code filtering on
+                # the ancestors end up being slower.
+                hrevs = reachableroots(bottomrevs[0], [h], bottomrevs, True)
                 start = self.depthrev(repo, h) - len(hrevs)
                 entry = (h, start)
                 result.append(entry)