128 """return a random subset of sample of at most desiredlen item""" |
128 """return a random subset of sample of at most desiredlen item""" |
129 if len(sample) > desiredlen: |
129 if len(sample) > desiredlen: |
130 sample = set(random.sample(sample, desiredlen)) |
130 sample = set(random.sample(sample, desiredlen)) |
131 return sample |
131 return sample |
132 |
132 |
133 def findcommonheads(ui, local, remote, heads=None, |
133 def findcommonheads(ui, local, remote, |
134 initialsamplesize=100, |
134 initialsamplesize=100, |
135 fullsamplesize=200, |
135 fullsamplesize=200, |
136 abortwhenunrelated=True, |
136 abortwhenunrelated=True, |
137 ancestorsof=None): |
137 ancestorsof=None): |
138 '''Return a tuple (common, anyincoming, remoteheads) used to identify |
138 '''Return a tuple (common, anyincoming, remoteheads) used to identify |
153 roundtrips += 1 |
153 roundtrips += 1 |
154 ownheads = dag.heads() |
154 ownheads = dag.heads() |
155 sample = _limitsample(ownheads, initialsamplesize) |
155 sample = _limitsample(ownheads, initialsamplesize) |
156 # indices between sample and externalized version must match |
156 # indices between sample and externalized version must match |
157 sample = list(sample) |
157 sample = list(sample) |
158 if heads: |
158 batch = remote.iterbatch() |
159 srvheadhashes = heads |
159 batch.heads() |
160 yesno = remote.known(dag.externalizeall(sample)) |
160 batch.known(dag.externalizeall(sample)) |
161 else: |
161 batch.submit() |
162 batch = remote.iterbatch() |
162 srvheadhashes, yesno = batch.results() |
163 batch.heads() |
|
164 batch.known(dag.externalizeall(sample)) |
|
165 batch.submit() |
|
166 srvheadhashes, yesno = batch.results() |
|
167 |
163 |
168 if cl.tip() == nullid: |
164 if cl.tip() == nullid: |
169 if srvheadhashes != [nullid]: |
165 if srvheadhashes != [nullid]: |
170 return [nullid], True, srvheadhashes |
166 return [nullid], True, srvheadhashes |
171 return [nullid], False, [] |
167 return [nullid], False, [] |