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

login
register
mail settings
Submitter Boris Feld
Date Nov. 24, 2017, 9:34 p.m.
Message ID <15d0adf567fa66fbc331.1511559252@FB>
Download mbox | patch
Permalink /patch/25738/
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 1511066090 -3600
#      Sun Nov 19 05:34:50 2017 +0100
# Node ID 15d0adf567fa66fbc33146e296fbc293bb507663
# Parent  b76ac906d1ecea6bcac489834699d01273112fc8
# EXP-Topic instability-speed
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 15d0adf567fa
obsolete: drop usage of changectx in '_computecontentdivergentset'

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.054239 second
    after:  0.046935 second

On a mercurial repository with 115973 draft:

    before: 0.564548 second
    after:  0.130534 second

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -1023,8 +1023,10 @@  def _computecontentdivergentset(repo):
     divergent = set()
     obsstore = repo.obsstore
     newermap = {}
-    for ctx in repo.set('(not public()) - obsolete()'):
-        mark = obsstore.predecessors.get(ctx.node(), ())
+    tonode = repo.changelog.node
+    for rev in repo.revs('(not public()) - obsolete()'):
+        node = tonode(rev)
+        mark = obsstore.predecessors.get(node, ())
         toprocess = set(mark)
         seen = set()
         while toprocess:
@@ -1036,7 +1038,7 @@  def _computecontentdivergentset(repo):
                 obsutil.successorssets(repo, prec, cache=newermap)
             newer = [n for n in newermap[prec] if n]
             if len(newer) > 1:
-                divergent.add(ctx.rev())
+                divergent.add(rev)
                 break
             toprocess.update(obsstore.predecessors.get(prec, ()))
     return divergent