# HG changeset patch # User Pierre-Yves David # Date 1496666655 -3600 # Node ID 4374e88e808cef2d277a18bb2947be2cd5a00722 # Parent 1cb14923dee9bdf8bfb81254efdbedbe63c2f61a 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 -r 1cb14923dee9 -r 4374e88e808c mercurial/discovery.py --- a/mercurial/discovery.py Mon Jun 05 13:37:04 2017 +0100 +++ b/mercurial/discovery.py Mon Jun 05 13:44:15 2017 +0100 @@ -248,11 +248,10 @@ # 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)