[PATCH 1 of 2] obsolete: drop usage of changectx in '_computephasedivergentset'

Boris Feld boris.feld at octobus.net
Fri Nov 24 21:34:11 UTC 2017


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1511065392 -3600
#      Sun Nov 19 05:23:12 2017 +0100
# Node ID b76ac906d1ecea6bcac489834699d01273112fc8
# Parent  75013952d8d9608f73cd45f68405fbd6ec112bf2
# EXP-Topic instability-speed
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b76ac906d1ec
obsolete: drop usage of changectx in '_computephasedivergentset'

Changectx are expensive and not needed there. The use of `repo.set` denote old
code that predate the introduction of `repo.revs` that we now use.

On my mercurial repository 495 draft:

    before: 0.010275 second
    after:  0.008832 second

On a mercurial repository with 115973 draft:

    before: 0.899255 second
    after:  0.397131 second

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -994,10 +994,10 @@ def _computephasedivergentset(repo):
     public = phases.public
     cl = repo.changelog
     torev = cl.nodemap.get
-    for ctx in repo.set('(not public()) and (not obsolete())'):
-        rev = ctx.rev()
+    tonode = cl.node
+    for rev in repo.revs('(not public()) and (not obsolete())'):
         # We only evaluate mutable, non-obsolete revision
-        node = ctx.node()
+        node = tonode(rev)
         # (future) A cache of predecessors may worth if split is very common
         for pnode in obsutil.allpredecessors(repo.obsstore, [node],
                                    ignoreflags=bumpedfix):


More information about the Mercurial-devel mailing list