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

login
register
mail settings
Submitter Boris Feld
Date Nov. 24, 2017, 9:34 p.m.
Message ID <b76ac906d1ecea6bcac4.1511559251@FB>
Download mbox | patch
Permalink /patch/25739/
State Accepted
Headers show

Comments

Boris Feld - Nov. 24, 2017, 9:34 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@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
Yuya Nishihara - Nov. 26, 2017, 10:48 a.m.
On Fri, 24 Nov 2017 16:34:11 -0500, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@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'

Looks good. Queued, thanks.

Patch

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