[PATCH 4 of 5 V2] phase: replace revset with manual computation

Durham Goode durham at fb.com
Wed Nov 13 15:31:05 CST 2013


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1384216577 28800
#      Mon Nov 11 16:36:17 2013 -0800
# Node ID 21a4fec31a1f3bea839058b8fd7d7a85c096542c
# Parent  e488be1508865f6451795b22bbd7340bbdc77234
phase: replace revset with manual computation

revsets are slow on large repos. Replacing this revset with the manual version
makes amend on a large repo go from 5.5 seconds to 5.3 seconds.

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -245,8 +245,15 @@
                 raise util.Abort(_('cannot change null revision phase'))
             currentroots = currentroots.copy()
             currentroots.update(newroots)
-            ctxs = repo.set('roots(%ln::)', currentroots)
-            currentroots.intersection_update(ctx.node() for ctx in ctxs)
+
+            # filter to the roots of the roots
+            # (could use a revset here, but it's slow on large repos)
+            cl = repo.changelog
+            currentrootrevs = [cl.rev(n) for n in currentroots]
+            desc = set(cl.descendants(currentrootrevs))
+            currentroots = set([cl.node(r) for r in currentrootrevs
+                if not r in desc])
+
             self._updateroots(targetphase, currentroots)
         repo.invalidatevolatilesets()
 


More information about the Mercurial-devel mailing list