Mercurial > hg
comparison mercurial/wireproto.py @ 37320:39f7d4ee8bcd
repository: port peer interfaces to zope.interface
zope.interface is superior. Let's switch to it.
Unlike abc, which defines interfaces through a base class,
zope.interface uses different types for interfaces and for
implementations. So, we had to invent some new types to hold the
interfaces in order to separate the interface from its default
implementation.
The names here could probably be better. I've been wanting to
overhaul the peer interface for a while. And wire protocol version
2 will force that work. So anticipate a refactoring of these
interfaces in later commits.
With this commit, we no longer test abc interfaces in
test-check-interfaces.py, so code for that has been removed.
Differential Revision: https://phab.mercurial-scm.org/D3068
# no-check-commit because of stream_out()
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 30 Mar 2018 18:53:17 -0700 |
parents | 45b39c69fae0 |
children | ac666c5c2e0c |
comparison
equal
deleted
inserted
replaced
37319:36d17f37db91 | 37320:39f7d4ee8bcd |
---|---|
190 Methods commonly call wire protocol commands of the same name. | 190 Methods commonly call wire protocol commands of the same name. |
191 | 191 |
192 See also httppeer.py and sshpeer.py for protocol-specific | 192 See also httppeer.py and sshpeer.py for protocol-specific |
193 implementations of this interface. | 193 implementations of this interface. |
194 """ | 194 """ |
195 # Begin of basewirepeer interface. | 195 # Begin of ipeercommands interface. |
196 | 196 |
197 def iterbatch(self): | 197 def iterbatch(self): |
198 return remoteiterbatcher(self) | 198 return remoteiterbatcher(self) |
199 | 199 |
200 @batchable | 200 @batchable |
351 # bundle2 push. Send a stream, fetch a stream. | 351 # bundle2 push. Send a stream, fetch a stream. |
352 stream = self._calltwowaystream('unbundle', cg, heads=heads) | 352 stream = self._calltwowaystream('unbundle', cg, heads=heads) |
353 ret = bundle2.getunbundler(self.ui, stream) | 353 ret = bundle2.getunbundler(self.ui, stream) |
354 return ret | 354 return ret |
355 | 355 |
356 # End of basewirepeer interface. | 356 # End of ipeercommands interface. |
357 | 357 |
358 # Begin of baselegacywirepeer interface. | 358 # Begin of ipeerlegacycommands interface. |
359 | 359 |
360 def branches(self, nodes): | 360 def branches(self, nodes): |
361 n = encodelist(nodes) | 361 n = encodelist(nodes) |
362 d = self._call("branches", nodes=n) | 362 d = self._call("branches", nodes=n) |
363 try: | 363 try: |
389 heads = encodelist(heads) | 389 heads = encodelist(heads) |
390 f = self._callcompressable("changegroupsubset", | 390 f = self._callcompressable("changegroupsubset", |
391 bases=bases, heads=heads) | 391 bases=bases, heads=heads) |
392 return changegroupmod.cg1unpacker(f, 'UN') | 392 return changegroupmod.cg1unpacker(f, 'UN') |
393 | 393 |
394 # End of baselegacywirepeer interface. | 394 # End of ipeerlegacycommands interface. |
395 | 395 |
396 def _submitbatch(self, req): | 396 def _submitbatch(self, req): |
397 """run batch request <req> on the server | 397 """run batch request <req> on the server |
398 | 398 |
399 Returns an iterator of the raw responses from the server. | 399 Returns an iterator of the raw responses from the server. |