Mercurial > hg
changeset 46061:44a52048c6d6
debugdiscovery: move various computation earlier
We are about to add more data to debug discovery (eg: data bout the initial
undecided set, number of roundtrip, etc). So we start by cleaning up the code by
spliting some computation and some display related preparation.
Differential Revision: https://phab.mercurial-scm.org/D9524
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 06 Dec 2020 14:45:04 +0100 |
parents | 24751551fe64 |
children | 14ff4929ca8c |
files | mercurial/debugcommands.py |
diffstat | 1 files changed, 27 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/debugcommands.py Sun Dec 06 06:23:26 2020 +0100 +++ b/mercurial/debugcommands.py Sun Dec 06 14:45:04 2020 +0100 @@ -1017,27 +1017,35 @@ common, hds = doit(localrevs, remoterevs) # compute all statistics - common = set(common) - rheads = set(hds) - lheads = set(repo.heads()) + heads_common = set(common) + heads_remote = set(hds) + heads_local = set(repo.heads()) + # note: they cannot be a local or remote head that is in common and not + # itself a head of common. + heads_common_local = heads_common & heads_local + heads_common_remote = heads_common & heads_remote + heads_common_both = heads_common & heads_remote & heads_local + + all = repo.revs(b'all()') + common = repo.revs(b'::%ln', common) + missing = repo.revs(b'not ::%ld', common) + assert len(common) + len(missing) == len(all) data = {} data[b'elapsed'] = t.elapsed - data[b'nb-common-heads'] = len(common) - data[b'nb-common-heads-local'] = len(common & lheads) - data[b'nb-common-heads-remote'] = len(common & rheads) - data[b'nb-common-heads-both'] = len(common & rheads & lheads) - data[b'nb-head-local'] = len(lheads) - data[b'nb-head-local-missing'] = ( - data[b'nb-head-local'] - data[b'nb-common-heads-local'] + data[b'nb-common-heads'] = len(heads_common) + data[b'nb-common-heads-local'] = len(heads_common_local) + data[b'nb-common-heads-remote'] = len(heads_common_remote) + data[b'nb-common-heads-both'] = len(heads_common_both) + data[b'nb-head-local'] = len(heads_local) + data[b'nb-head-local-missing'] = len(heads_local) - len(heads_common_local) + data[b'nb-head-remote'] = len(heads_remote) + data[b'nb-head-remote-unknown'] = len(heads_remote) - len( + heads_common_remote ) - data[b'nb-head-remote'] = len(rheads) - data[b'nb-head-remote-unknown'] = ( - data[b'nb-head-remote'] - data[b'nb-common-heads-remote'] - ) - data[b'nb-revs'] = len(repo.revs(b'all()')) - data[b'nb-revs-common'] = len(repo.revs(b'::%ln', common)) - data[b'nb-revs-missing'] = data[b'nb-revs'] - data[b'nb-revs-common'] + data[b'nb-revs'] = len(all) + data[b'nb-revs-common'] = len(common) + data[b'nb-revs-missing'] = len(missing) # display discovery summary ui.writenoi18n(b"elapsed time: %(elapsed)f seconds\n" % data) @@ -1070,7 +1078,8 @@ if ui.verbose: ui.writenoi18n( - b"common heads: %s\n" % b" ".join(sorted(short(n) for n in common)) + b"common heads: %s\n" + % b" ".join(sorted(short(n) for n in heads_common)) )