Show More
@@ -56,7 +56,7 b' from . import (' | |||||
56 | util, |
|
56 | util, | |
57 | ) |
|
57 | ) | |
58 |
|
58 | |||
59 | def _updatesample(dag, revs, sample, quicksamplesize=0): |
|
59 | def _updatesample(dag, revs, heads, sample, quicksamplesize=0): | |
60 | """update an existing sample to match the expected size |
|
60 | """update an existing sample to match the expected size | |
61 |
|
61 | |||
62 | The sample is updated with revs exponentially distant from each head of the |
|
62 | The sample is updated with revs exponentially distant from each head of the | |
@@ -68,13 +68,9 b' def _updatesample(dag, revs, sample, qui' | |||||
68 |
|
68 | |||
69 | :dag: a dag object from dagutil |
|
69 | :dag: a dag object from dagutil | |
70 | :revs: set of revs we want to discover (if None, assume the whole dag) |
|
70 | :revs: set of revs we want to discover (if None, assume the whole dag) | |
|
71 | :heads: set of DAG head revs | |||
71 | :sample: a sample to update |
|
72 | :sample: a sample to update | |
72 | :quicksamplesize: optional target size of the sample""" |
|
73 | :quicksamplesize: optional target size of the sample""" | |
73 | # if revs is empty we scan the entire graph |
|
|||
74 | if revs: |
|
|||
75 | heads = dag.headsetofconnecteds(revs) |
|
|||
76 | else: |
|
|||
77 | heads = dag.heads() |
|
|||
78 | dist = {} |
|
74 | dist = {} | |
79 | visit = collections.deque(heads) |
|
75 | visit = collections.deque(heads) | |
80 | seen = set() |
|
76 | seen = set() | |
@@ -109,16 +105,19 b' def _takequicksample(repo, dag, revs, si' | |||||
109 |
|
105 | |||
110 | if len(sample) >= size: |
|
106 | if len(sample) >= size: | |
111 | return _limitsample(sample, size) |
|
107 | return _limitsample(sample, size) | |
112 | _updatesample(dag, None, sample, quicksamplesize=size) |
|
108 | ||
|
109 | _updatesample(dag, None, dag.heads(), sample, quicksamplesize=size) | |||
113 | return sample |
|
110 | return sample | |
114 |
|
111 | |||
115 | def _takefullsample(repo, dag, revs, size): |
|
112 | def _takefullsample(repo, dag, revs, size): | |
116 | sample = set(repo.revs('heads(%ld)', revs)) |
|
113 | sample = set(repo.revs('heads(%ld)', revs)) | |
117 |
|
114 | |||
118 | # update from heads |
|
115 | # update from heads | |
119 | _updatesample(dag, revs, sample) |
|
116 | _updatesample(dag, revs, dag.headsetofconnecteds(revs), sample) | |
120 | # update from roots |
|
117 | # update from roots | |
121 | _updatesample(dag.inverse(), revs, sample) |
|
118 | inverteddag = dag.inverse() | |
|
119 | _updatesample(inverteddag, revs, inverteddag.headsetofconnecteds(revs), | |||
|
120 | sample) | |||
122 | assert sample |
|
121 | assert sample | |
123 | sample = _limitsample(sample, size) |
|
122 | sample = _limitsample(sample, size) | |
124 | if len(sample) < size: |
|
123 | if len(sample) < size: |
General Comments 0
You need to be logged in to leave comments.
Login now