Show More
@@ -161,6 +161,28 b' def _limitsample(sample, desiredlen):' | |||
|
161 | 161 | sample = set(random.sample(sample, desiredlen)) |
|
162 | 162 | return sample |
|
163 | 163 | |
|
164 | class partialdiscovery(object): | |
|
165 | """an object representing ongoing discovery | |
|
166 | ||
|
167 | Feed with data from the remote repository, this object keep track of the | |
|
168 | current set of changeset in various states: | |
|
169 | ||
|
170 | - common: own nodes I know we both know | |
|
171 | """ | |
|
172 | ||
|
173 | def __init__(self, repo): | |
|
174 | self._repo = repo | |
|
175 | self._common = repo.changelog.incrementalmissingrevs() | |
|
176 | ||
|
177 | def addcommons(self, commons): | |
|
178 | """registrer nodes known as common""" | |
|
179 | self._common.addbases(commons) | |
|
180 | ||
|
181 | def hasinfo(self): | |
|
182 | """return True is we have any clue about the remote state""" | |
|
183 | return self._common.hasbases() | |
|
184 | ||
|
185 | ||
|
164 | 186 | def findcommonheads(ui, local, remote, |
|
165 | 187 | initialsamplesize=100, |
|
166 | 188 | fullsamplesize=200, |
@@ -227,14 +249,14 b' def findcommonheads(ui, local, remote,' | |||
|
227 | 249 | |
|
228 | 250 | # full blown discovery |
|
229 | 251 | |
|
230 | # own nodes I know we both know | |
|
252 | disco = partialdiscovery(local) | |
|
231 | 253 | # treat remote heads (and maybe own heads) as a first implicit sample |
|
232 | 254 | # response |
|
233 | common = cl.incrementalmissingrevs(srvheads) | |
|
255 | disco.addcommons(srvheads) | |
|
234 | 256 | commoninsample = set(n for i, n in enumerate(sample) if yesno[i]) |
|
235 |
co |
|
|
257 | disco.addcommons(commoninsample) | |
|
236 | 258 | # own nodes where I don't know if remote knows them |
|
237 | undecided = set(common.missingancestors(ownheads)) | |
|
259 | undecided = set(disco._common.missingancestors(ownheads)) | |
|
238 | 260 | # own nodes I know remote lacks |
|
239 | 261 | missing = set() |
|
240 | 262 | |
@@ -256,7 +278,7 b' def findcommonheads(ui, local, remote,' | |||
|
256 | 278 | if not undecided: |
|
257 | 279 | break |
|
258 | 280 | |
|
259 |
if full or co |
|
|
281 | if full or disco.hasinfo(): | |
|
260 | 282 | if full: |
|
261 | 283 | ui.note(_("sampling from both directions\n")) |
|
262 | 284 | else: |
@@ -286,13 +308,13 b' def findcommonheads(ui, local, remote,' | |||
|
286 | 308 | |
|
287 | 309 | if sample: |
|
288 | 310 | commoninsample = set(n for i, n in enumerate(sample) if yesno[i]) |
|
289 |
co |
|
|
290 | common.removeancestorsfrom(undecided) | |
|
311 | disco.addcommons(commoninsample) | |
|
312 | disco._common.removeancestorsfrom(undecided) | |
|
291 | 313 | |
|
292 | 314 | # heads(common) == heads(common.bases) since common represents common.bases |
|
293 | 315 | # and all its ancestors |
|
294 | 316 | # The presence of nullrev will confuse heads(). So filter it out. |
|
295 | result = set(local.revs('heads(%ld)', common.bases - {nullrev})) | |
|
317 | result = set(local.revs('heads(%ld)', disco._common.bases - {nullrev})) | |
|
296 | 318 | elapsed = util.timer() - start |
|
297 | 319 | progress.complete() |
|
298 | 320 | ui.debug("%d total queries in %.4fs\n" % (roundtrips, elapsed)) |
General Comments 0
You need to be logged in to leave comments.
Login now