Patchwork D9524: debugdiscovery: move various computation earlier

login
register
mail settings
Submitter phabricator
Date Dec. 5, 2020, 2:32 p.m.
Message ID <differential-rev-PHID-DREV-jfhfxmb4edglji5qgzaz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47807/
State Superseded
Headers show

Comments

phabricator - Dec. 5, 2020, 2:32 p.m.
marmoute created this revision.
marmoute added a comment.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.


  initial sent before test run (refresh post test run imminent)

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9524

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1017,23 +1017,33 @@ 
         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 = common & heads_local
+    heads_common_remote = common & heads_remote
+    heads_common_both = 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'] = len(common)
-    data[b'nb-common-head-local'] = len(common & lheads)
-    data[b'nb-common-head-remote'] = len(common & rheads)
-    data[b'nb-common-head-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-head-local']
-    data[b'nb-head-remote'] = len(rheads)
-    data[b'nb-head-remote-unknown'] = data[b'nb-head-remote'] - data[b'nb-common-head-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-common'] = len(heads_common)
+    data[b'nb-common-head-local'] = len(heads_common_local)
+    data[b'nb-common-head-remote'] = len(heads_common_remote)
+    data[b'nb-common-head-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-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)