Show More
@@ -167,12 +167,15 b' class partialdiscovery(object):' | |||
|
167 | 167 | Feed with data from the remote repository, this object keep track of the |
|
168 | 168 | current set of changeset in various states: |
|
169 | 169 | |
|
170 | - common: own nodes I know we both know | |
|
170 | - common: own nodes I know we both know | |
|
171 | - undecided: own nodes where I don't know if remote knows them | |
|
171 | 172 | """ |
|
172 | 173 | |
|
173 | def __init__(self, repo): | |
|
174 | def __init__(self, repo, targetheads): | |
|
174 | 175 | self._repo = repo |
|
176 | self._targetheads = targetheads | |
|
175 | 177 | self._common = repo.changelog.incrementalmissingrevs() |
|
178 | self._undecided = None | |
|
176 | 179 | |
|
177 | 180 | def addcommons(self, commons): |
|
178 | 181 | """registrer nodes known as common""" |
@@ -182,6 +185,13 b' class partialdiscovery(object):' | |||
|
182 | 185 | """return True is we have any clue about the remote state""" |
|
183 | 186 | return self._common.hasbases() |
|
184 | 187 | |
|
188 | @property | |
|
189 | def undecided(self): | |
|
190 | if self._undecided is not None: | |
|
191 | return self._undecided | |
|
192 | self._undecided = set(self._common.missingancestors(self._targetheads)) | |
|
193 | return self._undecided | |
|
194 | ||
|
185 | 195 | def commonheads(self): |
|
186 | 196 | """the heads of the known common set""" |
|
187 | 197 | # heads(common) == heads(common.bases) since common represents |
@@ -256,20 +266,18 b' def findcommonheads(ui, local, remote,' | |||
|
256 | 266 | |
|
257 | 267 | # full blown discovery |
|
258 | 268 | |
|
259 | disco = partialdiscovery(local) | |
|
269 | disco = partialdiscovery(local, ownheads) | |
|
260 | 270 | # treat remote heads (and maybe own heads) as a first implicit sample |
|
261 | 271 | # response |
|
262 | 272 | disco.addcommons(srvheads) |
|
263 | 273 | commoninsample = set(n for i, n in enumerate(sample) if yesno[i]) |
|
264 | 274 | disco.addcommons(commoninsample) |
|
265 | # own nodes where I don't know if remote knows them | |
|
266 | undecided = set(disco._common.missingancestors(ownheads)) | |
|
267 | 275 | # own nodes I know remote lacks |
|
268 | 276 | missing = set() |
|
269 | 277 | |
|
270 | 278 | full = False |
|
271 | 279 | progress = ui.makeprogress(_('searching'), unit=_('queries')) |
|
272 | while undecided: | |
|
280 | while disco.undecided: | |
|
273 | 281 | |
|
274 | 282 | if sample: |
|
275 | 283 | missinginsample = [n for i, n in enumerate(sample) if not yesno[i]] |
@@ -280,9 +288,9 b' def findcommonheads(ui, local, remote,' | |||
|
280 | 288 | else: |
|
281 | 289 | missing.update(local.revs('descendants(%ld)', missinginsample)) |
|
282 | 290 | |
|
283 | undecided.difference_update(missing) | |
|
291 | disco.undecided.difference_update(missing) | |
|
284 | 292 | |
|
285 | if not undecided: | |
|
293 | if not disco.undecided: | |
|
286 | 294 | break |
|
287 | 295 | |
|
288 | 296 | if full or disco.hasinfo(): |
@@ -297,12 +305,12 b' def findcommonheads(ui, local, remote,' | |||
|
297 | 305 | ui.debug("taking quick initial sample\n") |
|
298 | 306 | samplefunc = _takequicksample |
|
299 | 307 | targetsize = initialsamplesize |
|
300 | sample = samplefunc(local, ownheads, undecided, targetsize) | |
|
308 | sample = samplefunc(local, ownheads, disco.undecided, targetsize) | |
|
301 | 309 | |
|
302 | 310 | roundtrips += 1 |
|
303 | 311 | progress.update(roundtrips) |
|
304 | 312 | ui.debug("query %i; still undecided: %i, sample size is: %i\n" |
|
305 | % (roundtrips, len(undecided), len(sample))) | |
|
313 | % (roundtrips, len(disco.undecided), len(sample))) | |
|
306 | 314 | # indices between sample and externalized version must match |
|
307 | 315 | sample = list(sample) |
|
308 | 316 | |
@@ -316,7 +324,7 b' def findcommonheads(ui, local, remote,' | |||
|
316 | 324 | if sample: |
|
317 | 325 | commoninsample = set(n for i, n in enumerate(sample) if yesno[i]) |
|
318 | 326 | disco.addcommons(commoninsample) |
|
319 | disco._common.removeancestorsfrom(undecided) | |
|
327 | disco._common.removeancestorsfrom(disco.undecided) | |
|
320 | 328 | |
|
321 | 329 | result = disco.commonheads() |
|
322 | 330 | elapsed = util.timer() - start |
General Comments 0
You need to be logged in to leave comments.
Login now