# HG changeset patch # User Gregory Szorc # Date 1534526471 0 # Node ID 2d218db7389b5c4d7b9f64372abebb54af0a38fe # Parent 136ed75bbe12b1e0d9310d069f45324ea6a85ed0 setdiscovery: reflect use of revs instead of nodes This code all operates on revision numbers. Update variable names and comments accordingly. Differential Revision: https://phab.mercurial-scm.org/D4316 diff -r 136ed75bbe12 -r 2d218db7389b mercurial/setdiscovery.py --- a/mercurial/setdiscovery.py Fri Aug 17 17:15:09 2018 +0000 +++ b/mercurial/setdiscovery.py Fri Aug 17 17:21:11 2018 +0000 @@ -56,23 +56,23 @@ util, ) -def _updatesample(dag, nodes, sample, quicksamplesize=0): +def _updatesample(dag, revs, sample, quicksamplesize=0): """update an existing sample to match the expected size - The sample is updated with nodes exponentially distant from each head of the - set. (H~1, H~2, H~4, H~8, etc). + The sample is updated with revs exponentially distant from each head of the + set. (H~1, H~2, H~4, H~8, etc). If a target size is specified, the sampling will stop once this size is - reached. Otherwise sampling will happen until roots of the set are + reached. Otherwise sampling will happen until roots of the set are reached. :dag: a dag object from dagutil - :nodes: set of nodes we want to discover (if None, assume the whole dag) + :revs: set of revs we want to discover (if None, assume the whole dag) :sample: a sample to update :quicksamplesize: optional target size of the sample""" - # if nodes is empty we scan the entire graph - if nodes: - heads = dag.headsetofconnecteds(nodes) + # if revs is empty we scan the entire graph + if revs: + heads = dag.headsetofconnecteds(revs) else: heads = dag.heads() dist = {} @@ -92,36 +92,36 @@ return seen.add(curr) for p in dag.parents(curr): - if not nodes or p in nodes: + if not revs or p in revs: dist.setdefault(p, d + 1) visit.append(p) -def _takequicksample(dag, nodes, size): +def _takequicksample(dag, revs, size): """takes a quick sample of size It is meant for initial sampling and focuses on querying heads and close ancestors of heads. :dag: a dag object - :nodes: set of nodes to discover + :revs: set of revs to discover :size: the maximum size of the sample""" - sample = dag.headsetofconnecteds(nodes) + sample = dag.headsetofconnecteds(revs) if len(sample) >= size: return _limitsample(sample, size) _updatesample(dag, None, sample, quicksamplesize=size) return sample -def _takefullsample(dag, nodes, size): - sample = dag.headsetofconnecteds(nodes) +def _takefullsample(dag, revs, size): + sample = dag.headsetofconnecteds(revs) # update from heads - _updatesample(dag, nodes, sample) + _updatesample(dag, revs, sample) # update from roots - _updatesample(dag.inverse(), nodes, sample) + _updatesample(dag.inverse(), revs, sample) assert sample sample = _limitsample(sample, size) if len(sample) < size: more = size - len(sample) - sample.update(random.sample(list(nodes - sample), more)) + sample.update(random.sample(list(revs - sample), more)) return sample def _limitsample(sample, desiredlen):