comparison mercurial/setdiscovery.py @ 37630:e1b32dc4646c

wireproto: implement command executor interface for version 1 peers Now that we've defined our new interface for issuing commands, let's implement it. We add the interface to the base peer interface. This means all peer types must implement it. The only peer types that we have are the local peer in localrepo and a shared wire peer for version 1 of the wire protocol. The local peer implementation is pretty straightforward. We don't do anything fancy and just return a resolved future with the result of a method call. This is similar to what localiterbatcher does. The wire protocol version 1 implementation is a bit more complicated and is a more robust implementation. The wire executor queues commands by default. And because the new executor interface always allows multiple commands but not all version 1 commands are @batchable, it has to check that the requested commands are batchable if multiple commands are being requested. The wire executor currently only supports executing a single command. This is for simplicity reasons. Support for multiple commands will be added in a separate commit. To prove the new interface works, a call to the "known" command during discovery has been updated to use the new API. It's worth noting that both implementations require a method having the command name to exist on the peer. There is at least one caller in core that don't have a method calls peer._call() directly. We may need to shore up the requirements later... Differential Revision: https://phab.mercurial-scm.org/D3268
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 13 Apr 2018 10:51:23 -0700
parents 59802fa590db
children 2f626233859b
comparison
equal deleted inserted replaced
37629:fa0382088993 37630:e1b32dc4646c
226 ui.progress(_('searching'), roundtrips, unit=_('queries')) 226 ui.progress(_('searching'), roundtrips, unit=_('queries'))
227 ui.debug("query %i; still undecided: %i, sample size is: %i\n" 227 ui.debug("query %i; still undecided: %i, sample size is: %i\n"
228 % (roundtrips, len(undecided), len(sample))) 228 % (roundtrips, len(undecided), len(sample)))
229 # indices between sample and externalized version must match 229 # indices between sample and externalized version must match
230 sample = list(sample) 230 sample = list(sample)
231 yesno = remote.known(dag.externalizeall(sample)) 231
232 with remote.commandexecutor() as e:
233 yesno = e.callcommand('known', {
234 'nodes': dag.externalizeall(sample),
235 }).result()
236
232 full = True 237 full = True
233 238
234 if sample: 239 if sample:
235 commoninsample = set(n for i, n in enumerate(sample) if yesno[i]) 240 commoninsample = set(n for i, n in enumerate(sample) if yesno[i])
236 common.addbases(commoninsample) 241 common.addbases(commoninsample)