##// END OF EJS Templates
setdiscovery: don't use dagutil for parent resolution...
Gregory Szorc -
r39210:71d83b31 default
parent child Browse files
Show More
@@ -56,7 +56,7 b' from . import ('
56 util,
56 util,
57 )
57 )
58
58
59 def _updatesample(dag, revs, heads, sample, quicksamplesize=0):
59 def _updatesample(revs, heads, sample, parentfn, 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
@@ -66,10 +66,10 b' def _updatesample(dag, revs, heads, samp'
66 reached. Otherwise sampling will happen until roots of the <revs> set are
66 reached. Otherwise sampling will happen until roots of the <revs> set are
67 reached.
67 reached.
68
68
69 :dag: a dag object from dagutil
70 :revs: set of revs we want to discover (if None, assume the whole dag)
69 :revs: set of revs we want to discover (if None, assume the whole dag)
71 :heads: set of DAG head revs
70 :heads: set of DAG head revs
72 :sample: a sample to update
71 :sample: a sample to update
72 :parentfn: a callable to resolve parents for a revision
73 :quicksamplesize: optional target size of the sample"""
73 :quicksamplesize: optional target size of the sample"""
74 dist = {}
74 dist = {}
75 visit = collections.deque(heads)
75 visit = collections.deque(heads)
@@ -87,12 +87,13 b' def _updatesample(dag, revs, heads, samp'
87 if quicksamplesize and (len(sample) >= quicksamplesize):
87 if quicksamplesize and (len(sample) >= quicksamplesize):
88 return
88 return
89 seen.add(curr)
89 seen.add(curr)
90 for p in dag.parents(curr):
90
91 if not revs or p in revs:
91 for p in parentfn(curr):
92 if p != nullrev and (not revs or p in revs):
92 dist.setdefault(p, d + 1)
93 dist.setdefault(p, d + 1)
93 visit.append(p)
94 visit.append(p)
94
95
95 def _takequicksample(repo, dag, headrevs, revs, size):
96 def _takequicksample(repo, headrevs, revs, size):
96 """takes a quick sample of size <size>
97 """takes a quick sample of size <size>
97
98
98 It is meant for initial sampling and focuses on querying heads and close
99 It is meant for initial sampling and focuses on querying heads and close
@@ -107,18 +108,23 b' def _takequicksample(repo, dag, headrevs'
107 if len(sample) >= size:
108 if len(sample) >= size:
108 return _limitsample(sample, size)
109 return _limitsample(sample, size)
109
110
110 _updatesample(dag, None, headrevs, sample, quicksamplesize=size)
111 _updatesample(None, headrevs, sample, repo.changelog.parentrevs,
112 quicksamplesize=size)
111 return sample
113 return sample
112
114
113 def _takefullsample(repo, dag, headrevs, revs, size):
115 def _takefullsample(repo, headrevs, revs, size):
114 sample = set(repo.revs('heads(%ld)', revs))
116 sample = set(repo.revs('heads(%ld)', revs))
115
117
116 # update from heads
118 # update from heads
117 revsheads = set(repo.revs('heads(%ld)', revs))
119 revsheads = set(repo.revs('heads(%ld)', revs))
118 _updatesample(dag, revs, revsheads, sample)
120 _updatesample(revs, revsheads, sample, repo.changelog.parentrevs)
119 # update from roots
121 # update from roots
120 revsroots = set(repo.revs('roots(%ld)', revs))
122 revsroots = set(repo.revs('roots(%ld)', revs))
121 _updatesample(dag.inverse(), revs, revsroots, sample)
123
124 # TODO this is quadratic
125 parentfn = lambda rev: repo.changelog.children(repo.changelog.node(rev))
126
127 _updatesample(revs, revsroots, sample, parentfn)
122 assert sample
128 assert sample
123 sample = _limitsample(sample, size)
129 sample = _limitsample(sample, size)
124 if len(sample) < size:
130 if len(sample) < size:
@@ -244,7 +250,7 b' def findcommonheads(ui, local, remote,'
244 if len(undecided) < targetsize:
250 if len(undecided) < targetsize:
245 sample = list(undecided)
251 sample = list(undecided)
246 else:
252 else:
247 sample = samplefunc(local, dag, ownheads, undecided, targetsize)
253 sample = samplefunc(local, ownheads, undecided, targetsize)
248
254
249 roundtrips += 1
255 roundtrips += 1
250 progress.update(roundtrips)
256 progress.update(roundtrips)
General Comments 0
You need to be logged in to leave comments. Login now