hbisect: use a defaultdict to avoid large allocations for a large changelogs
We can avoid a SPACE(len(changelog)) allocation by using a defaultdict.
Test Plan:
python run-tests.py test-bisect*
Differential Revision: https://phab.mercurial-scm.org/D1499
--- a/mercurial/hbisect.py Thu Nov 23 14:12:55 2017 -0800
+++ b/mercurial/hbisect.py Thu Nov 23 14:13:14 2017 -0800
@@ -38,7 +38,7 @@
def buildancestors(bad, good):
badrev = min([changelog.rev(n) for n in bad])
- ancestors = [None] * (len(changelog) + 1)
+ ancestors = collections.defaultdict(lambda: None)
for rev in repo.revs("descendants(%ln) - ancestors(%ln)", good, good):
ancestors[rev] = []
if ancestors[badrev] is None: