setdiscovery: pass head revisions into sample functions
This eliminates the last remaining consumer of heads() and
related functionality in dagutil.
Differential Revision: https://phab.mercurial-scm.org/D4319
--- a/mercurial/setdiscovery.py Fri Aug 17 17:48:15 2018 +0000
+++ b/mercurial/setdiscovery.py Fri Aug 17 17:54:10 2018 +0000
@@ -92,13 +92,14 @@
dist.setdefault(p, d + 1)
visit.append(p)
-def _takequicksample(repo, dag, revs, size):
+def _takequicksample(repo, dag, headrevs, revs, size):
"""takes a quick sample of size <size>
It is meant for initial sampling and focuses on querying heads and close
ancestors of heads.
:dag: a dag object
+ :headrevs: set of head revisions in local DAG to consider
:revs: set of revs to discover
:size: the maximum size of the sample"""
sample = set(repo.revs('heads(%ld)', revs))
@@ -106,10 +107,10 @@
if len(sample) >= size:
return _limitsample(sample, size)
- _updatesample(dag, None, dag.heads(), sample, quicksamplesize=size)
+ _updatesample(dag, None, headrevs, sample, quicksamplesize=size)
return sample
-def _takefullsample(repo, dag, revs, size):
+def _takefullsample(repo, dag, headrevs, revs, size):
sample = set(repo.revs('heads(%ld)', revs))
# update from heads
@@ -243,7 +244,7 @@
if len(undecided) < targetsize:
sample = list(undecided)
else:
- sample = samplefunc(local, dag, undecided, targetsize)
+ sample = samplefunc(local, dag, ownheads, undecided, targetsize)
roundtrips += 1
progress.update(roundtrips)