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

login
register
mail settings
Submitter Durham Goode
Date Nov. 12, 2013, 4:14 a.m.
Message ID <bd7f7d542d7417d2784b.1384229666@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/2921/
State Superseded
Headers show

Comments

Durham Goode - Nov. 12, 2013, 4:14 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1384216577 28800
#      Mon Nov 11 16:36:17 2013 -0800
# Node ID bd7f7d542d7417d2784b577d3e9a7a55476e5f54
# Parent  c22c16072cc8519f18a66932c87f2892d3b266be
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,13 @@ 
                 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)
+
+            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()