[PATCH 4 of 4] checkheads: use a "lazyancestors" object for allfuturecommon

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Jun 9 21:32:21 EDT 2017


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1496666655 -3600
#      Mon Jun 05 13:44:15 2017 +0100
# Node ID 51e07bde42f5205650d0c372b361bda78726e9db
# Parent  4f1a47b8fdacbb3f757ac7f92d783770dcf8215d
# EXP-Topic skipctx
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 51e07bde42f5
checkheads: use a "lazyancestors" object for allfuturecommon

Instead of walking all ancestors to compute the full set we now check membership
lazily. This massively speed.

On a million-ish revision repository, this remove 14 seconds from the push logic,
making the checkheads function disappear from profile.

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -248,11 +248,10 @@ def _headssummary(pushop):
 
     # If there are no obsstore, no post processing are needed.
     if repo.obsstore:
-        allmissing = set(outgoing.missing)
-        cctx = repo.set('%ld', outgoing.common)
-        allfuturecommon = set(c.rev() for c in cctx)
         torev = repo.changelog.rev
-        allfuturecommon.update(torev(m) for m in allmissing)
+        futureheads = set(torev(h) for h in outgoing.missingheads)
+        futureheads |= set(torev(h) for h in outgoing.commonheads)
+        allfuturecommon = repo.changelog.ancestors(futureheads, inclusive=True)
         for branch, heads in sorted(headssum.iteritems()):
             remoteheads, newheads, unsyncedheads, placeholder = heads
             result = _postprocessobsolete(pushop, allfuturecommon, newheads)


More information about the Mercurial-devel mailing list