145 ### Code performing discovery ### |
145 ### Code performing discovery ### |
146 ################################## |
146 ################################## |
147 |
147 |
148 def _canobshashrange(local, remote): |
148 def _canobshashrange(local, remote): |
149 return (local.ui.configbool('experimental', 'obshashrange', False) |
149 return (local.ui.configbool('experimental', 'obshashrange', False) |
150 and remote.capable('_evoext_obshashrange_1')) |
150 and remote.capable('_donotusemeever_evoext_obshashrange_1')) |
|
151 |
151 |
152 |
152 def _obshashrange_capabilities(orig, repo, proto): |
153 def _obshashrange_capabilities(orig, repo, proto): |
153 """wrapper to advertise new capability""" |
154 """wrapper to advertise new capability""" |
154 caps = orig(repo, proto) |
155 caps = orig(repo, proto) |
155 enabled = repo.ui.configbool('experimental', 'obshashrange', False) |
156 enabled = repo.ui.configbool('experimental', 'obshashrange', False) |
156 if obsolete.isenabled(repo, obsolete.exchangeopt) and enabled: |
157 if obsolete.isenabled(repo, obsolete.exchangeopt) and enabled: |
157 caps = caps.split() |
158 caps = caps.split() |
158 caps.append('_evoext_obshashrange_1') |
159 caps.append('_donotusemeever_evoext_obshashrange_1') |
159 caps.sort() |
160 caps.sort() |
160 caps = ' '.join(caps) |
161 caps = ' '.join(caps) |
161 return caps |
162 return caps |
162 |
163 |
163 @eh.extsetup |
164 @eh.extsetup |
322 yield key |
323 yield key |
323 |
324 |
324 bundler = bundle2.bundle20(ui, bundle2.bundle2caps(remote)) |
325 bundler = bundle2.bundle20(ui, bundle2.bundle2caps(remote)) |
325 capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) |
326 capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) |
326 bundler.newpart('replycaps', data=capsblob) |
327 bundler.newpart('replycaps', data=capsblob) |
327 bundler.newpart('_evoexp_obsrangehash_0', data=gen()) |
328 bundler.newpart('_donotusemeever_evoext_obshashrange_1', data=gen()) |
328 |
329 |
329 stream = util.chunkbuffer(bundler.getchunks()) |
330 stream = util.chunkbuffer(bundler.getchunks()) |
330 try: |
331 try: |
331 reply = remote.unbundle( |
332 reply = remote.unbundle( |
332 stream, ['force'], remote.url()) |
333 stream, ['force'], remote.url()) |
339 except bundle2.AbortFromPart as exc: |
340 except bundle2.AbortFromPart as exc: |
340 ui.status(_('remote: %s\n') % exc) |
341 ui.status(_('remote: %s\n') % exc) |
341 if exc.hint is not None: |
342 if exc.hint is not None: |
342 ui.status(_('remote: %s\n') % ('(%s)' % exc.hint)) |
343 ui.status(_('remote: %s\n') % ('(%s)' % exc.hint)) |
343 raise error.Abort(_('push failed on remote')) |
344 raise error.Abort(_('push failed on remote')) |
344 for rep in op.records['_evoexp_obsrangehash_0']: |
345 for rep in op.records['_donotusemeever_evoext_obshashrange_1']: |
345 yield mapping[rep['key']], rep['value'] |
346 yield mapping[rep['key']], rep['value'] |
346 |
347 |
347 |
348 |
348 @bundle2.parthandler('_evoexp_obsrangehash_0', ()) |
349 @bundle2.parthandler('_donotusemeever_evoext_obshashrange_1', ()) |
349 def _processqueryrange(op, inpart): |
350 def _processqueryrange(op, inpart): |
350 assert op.reply is not None |
351 assert op.reply is not None |
351 replies = [] |
352 replies = [] |
352 data = inpart.read(24) |
353 data = inpart.read(24) |
353 while data: |
354 while data: |
355 index = _unpack('>I', data[20:])[0] |
356 index = _unpack('>I', data[20:])[0] |
356 r = op.repo.changelog.rev(n) |
357 r = op.repo.changelog.rev(n) |
357 rhash = _range(op.repo, r, index).obshash |
358 rhash = _range(op.repo, r, index).obshash |
358 replies.append(data + rhash) |
359 replies.append(data + rhash) |
359 data = inpart.read(24) |
360 data = inpart.read(24) |
360 op.reply.newpart('reply:_evoexp_obsrangehash_0', data=iter(replies)) |
361 op.reply.newpart('reply:_donotusemeever_evoext_obshashrange_1', data=iter(replies)) |
361 |
362 |
362 |
363 |
363 @bundle2.parthandler('reply:_evoexp_obsrangehash_0', ()) |
364 @bundle2.parthandler('reply:_donotusemeever_evoext_obshashrange_1', ()) |
364 def _processqueryrangereply(op, inpart): |
365 def _processqueryrangereply(op, inpart): |
365 data = inpart.read(44) |
366 data = inpart.read(44) |
366 while data: |
367 while data: |
367 key = data[:24] |
368 key = data[:24] |
368 rhash = data[24:] |
369 rhash = data[24:] |
369 op.records.add('_evoexp_obsrangehash_0', {'key': key, 'value': rhash}) |
370 op.records.add('_donotusemeever_evoext_obshashrange_1', {'key': key, 'value': rhash}) |
370 data = inpart.read(44) |
371 data = inpart.read(44) |
371 |
372 |
372 ################################## |
373 ################################## |
373 ### Stable topological sorting ### |
374 ### Stable topological sorting ### |
374 ################################## |
375 ################################## |