##// END OF EJS Templates
setdiscovery: avoid a full changelog graph traversal...
Siddharth Agarwal -
r23343:f8a2647f default
parent child Browse files
Show More
@@ -40,7 +40,7 b' nodes that will maximize the number of n'
40 classified with it (since all ancestors or descendants will be marked as well).
40 classified with it (since all ancestors or descendants will be marked as well).
41 """
41 """
42
42
43 from node import nullid
43 from node import nullid, nullrev
44 from i18n import _
44 from i18n import _
45 import random
45 import random
46 import util, dagutil
46 import util, dagutil
@@ -177,27 +177,23 b' def findcommonheads(ui, local, remote,'
177 # own nodes where I don't know if remote knows them
177 # own nodes where I don't know if remote knows them
178 undecided = dag.nodeset()
178 undecided = dag.nodeset()
179 # own nodes I know we both know
179 # own nodes I know we both know
180 common = set()
180 # treat remote heads (and maybe own heads) as a first implicit sample
181 # response
182 common = cl.incrementalmissingrevs(srvheads)
183 commoninsample = set(n for i, n in enumerate(sample) if yesno[i])
184 common.addbases(commoninsample)
185 undecided = set(common.missingancestors(ownheads))
181 # own nodes I know remote lacks
186 # own nodes I know remote lacks
182 missing = set()
187 missing = set()
183
188
184 # treat remote heads (and maybe own heads) as a first implicit sample
185 # response
186 common.update(dag.ancestorset(srvheads))
187 undecided.difference_update(common)
188
189 full = False
189 full = False
190 while undecided:
190 while undecided:
191
191
192 if sample:
192 if sample:
193 commoninsample = set(n for i, n in enumerate(sample) if yesno[i])
194 common.update(dag.ancestorset(commoninsample, common))
195
196 missinginsample = [n for i, n in enumerate(sample) if not yesno[i]]
193 missinginsample = [n for i, n in enumerate(sample) if not yesno[i]]
197 missing.update(dag.descendantset(missinginsample, missing))
194 missing.update(dag.descendantset(missinginsample, missing))
198
195
199 undecided.difference_update(missing)
196 undecided.difference_update(missing)
200 undecided.difference_update(common)
201
197
202 if not undecided:
198 if not undecided:
203 break
199 break
@@ -206,7 +202,7 b' def findcommonheads(ui, local, remote,'
206 ui.note(_("sampling from both directions\n"))
202 ui.note(_("sampling from both directions\n"))
207 sample = _takefullsample(dag, undecided, size=fullsamplesize)
203 sample = _takefullsample(dag, undecided, size=fullsamplesize)
208 targetsize = fullsamplesize
204 targetsize = fullsamplesize
209 elif common:
205 elif common.hasbases():
210 # use cheapish initial sample
206 # use cheapish initial sample
211 ui.debug("taking initial sample\n")
207 ui.debug("taking initial sample\n")
212 sample = _takefullsample(dag, undecided, size=fullsamplesize)
208 sample = _takefullsample(dag, undecided, size=fullsamplesize)
@@ -228,7 +224,17 b' def findcommonheads(ui, local, remote,'
228 yesno = remote.known(dag.externalizeall(sample))
224 yesno = remote.known(dag.externalizeall(sample))
229 full = True
225 full = True
230
226
231 result = dag.headsetofconnecteds(common)
227 if sample:
228 commoninsample = set(n for i, n in enumerate(sample) if yesno[i])
229 common.addbases(commoninsample)
230 common.removeancestorsfrom(undecided)
231
232 # heads(common) == heads(common.bases) since common represents common.bases
233 # and all its ancestors
234 result = dag.headsetofconnecteds(common.bases)
235 # common.bases can include nullrev, but our contract requires us to not
236 # return any heads in that case, so discard that
237 result.discard(nullrev)
232 ui.progress(_('searching'), None)
238 ui.progress(_('searching'), None)
233 ui.debug("%d total queries\n" % roundtrips)
239 ui.debug("%d total queries\n" % roundtrips)
234
240
General Comments 0
You need to be logged in to leave comments. Login now