##// END OF EJS Templates
discovery: add a simple `addinfo` method...
Boris Feld -
r41207:f46ffd23 default
parent child Browse files
Show More
@@ -195,6 +195,20 b' class partialdiscovery(object):'
195 195
196 196 self.undecided.difference_update(self.missing)
197 197
198 def addinfo(self, sample):
199 """consume an iterable of (rev, known) tuples"""
200 common = set()
201 missing = set()
202 for rev, known in sample:
203 if known:
204 common.add(rev)
205 else:
206 missing.add(rev)
207 if common:
208 self.addcommons(common)
209 if missing:
210 self.addmissings(missing)
211
198 212 def hasinfo(self):
199 213 """return True is we have any clue about the remote state"""
200 214 return self._common.hasbases()
@@ -288,21 +302,12 b' def findcommonheads(ui, local, remote,'
288 302 # treat remote heads (and maybe own heads) as a first implicit sample
289 303 # response
290 304 disco.addcommons(srvheads)
291 commoninsample = set(n for i, n in enumerate(sample) if yesno[i])
292 disco.addcommons(commoninsample)
305 disco.addinfo(zip(sample, yesno))
293 306
294 307 full = False
295 308 progress = ui.makeprogress(_('searching'), unit=_('queries'))
296 309 while not disco.iscomplete():
297 310
298 if sample:
299 missinginsample = [n for i, n in enumerate(sample) if not yesno[i]]
300 disco.addmissings(missinginsample)
301
302
303 if disco.iscomplete():
304 break
305
306 311 if full or disco.hasinfo():
307 312 if full:
308 313 ui.note(_("sampling from both directions\n"))
@@ -331,9 +336,7 b' def findcommonheads(ui, local, remote,'
331 336
332 337 full = True
333 338
334 if sample:
335 commoninsample = set(n for i, n in enumerate(sample) if yesno[i])
336 disco.addcommons(commoninsample)
339 disco.addinfo(zip(sample, yesno))
337 340
338 341 result = disco.commonheads()
339 342 elapsed = util.timer() - start
General Comments 0
You need to be logged in to leave comments. Login now