##// 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 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 44 from i18n import _
45 45 import random
46 46 import util, dagutil
@@ -177,27 +177,23 b' def findcommonheads(ui, local, remote,'
177 177 # own nodes where I don't know if remote knows them
178 178 undecided = dag.nodeset()
179 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 186 # own nodes I know remote lacks
182 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 189 full = False
190 190 while undecided:
191 191
192 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 193 missinginsample = [n for i, n in enumerate(sample) if not yesno[i]]
197 194 missing.update(dag.descendantset(missinginsample, missing))
198 195
199 196 undecided.difference_update(missing)
200 undecided.difference_update(common)
201 197
202 198 if not undecided:
203 199 break
@@ -206,7 +202,7 b' def findcommonheads(ui, local, remote,'
206 202 ui.note(_("sampling from both directions\n"))
207 203 sample = _takefullsample(dag, undecided, size=fullsamplesize)
208 204 targetsize = fullsamplesize
209 elif common:
205 elif common.hasbases():
210 206 # use cheapish initial sample
211 207 ui.debug("taking initial sample\n")
212 208 sample = _takefullsample(dag, undecided, size=fullsamplesize)
@@ -228,7 +224,17 b' def findcommonheads(ui, local, remote,'
228 224 yesno = remote.known(dag.externalizeall(sample))
229 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 238 ui.progress(_('searching'), None)
233 239 ui.debug("%d total queries\n" % roundtrips)
234 240
General Comments 0
You need to be logged in to leave comments. Login now