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

login
register
mail settings
Submitter Durham Goode
Date Nov. 13, 2013, 9:31 p.m.
Message ID <21a4fec31a1f3bea8390.1384378265@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/2941/
State Superseded
Headers show

Comments

Durham Goode - Nov. 13, 2013, 9:31 p.m.
# HG changeset patch
# User Durham Goode <durham@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.

Patch

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()