[PATCH 6 of 9 "] discovery: simplify the building of the children mapping
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Mar 5 12:39:17 EST 2019
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1551796794 -3600
# Tue Mar 05 15:39:54 2019 +0100
# Node ID 1d2a2e4a255fcc8e5713232f5f80858a7b3793e1
# Parent 3f4f517d5ed962a0c2aef538ac81bfab28341355
# EXP-Topic discovery-speedup
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1d2a2e4a255f
discovery: simplify the building of the children mapping
Since we only care about the revisions inside the set we are sampling, we can
use simpler code (and probably sightly faster).
diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -219,13 +219,13 @@ class partialdiscovery(object):
for rev in sorted(revs):
# Always ensure revision has an entry so we don't need to worry
# about missing keys.
- children.setdefault(rev, [])
-
+ children[rev] = []
for prev in parentrevs(rev):
if prev == nullrev:
continue
-
- children.setdefault(prev, []).append(rev)
+ c = children.get(prev)
+ if c is not None:
+ c.append(rev)
_updatesample(revs, revsroots, sample, children.__getitem__)
assert sample
More information about the Mercurial-devel
mailing list