Mercurial > public > mercurial-scm > hg
comparison mercurial/httppeer.py @ 52520:1554bd50a1af
interfaces: move peer `capabilities()` to the `ipeercapabilities` interface
I'm not sure why this was on the `ipeercommands` interface. It appears to be
because these interfaces started out as `_basewirecommands` to hold wire
commands, back in 558f5b2ee10e. The capabilities interface wasn't split out
until 98861a2298b5, when it pulled the capability related methods off of the
`ipeerbase` interface. Perhaps it was an oversight to not look at the commands
interface because, while this is a wire command, both `sshpeer` and `httppeer`
now perform a handshake while instantiating the peer object, and cache a fixed
list of capabilities in that object. Likewise, `localpeer` is given a fixed set
of capabilities when instantiated. Back in 558f5b2ee10e, `httppeer` looks like
it issued a wire command when this method was called, but `sshpeer` obtained and
cached the capabilities when instantiated, and this method always returned a
fixed value.
There's a perfectly good interface with other capability related methods, and
having it here makes it easier to implement the base `peer` mixin class.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 16 Dec 2024 02:41:24 -0500 |
parents | f4733654f144 |
children | b52f2b365eff |
comparison
equal
deleted
inserted
replaced
52519:5cf81d8d7de1 | 52520:1554bd50a1af |
---|---|
435 % (reqs, sent, recv) | 435 % (reqs, sent, recv) |
436 ) | 436 ) |
437 | 437 |
438 # End of ipeerconnection interface. | 438 # End of ipeerconnection interface. |
439 | 439 |
440 # Begin of ipeercommands interface. | 440 # Begin of ipeercapabilities interface. |
441 | 441 |
442 def capabilities(self): | 442 def capabilities(self): |
443 return self._caps | 443 return self._caps |
444 | |
445 # End of ipeercapabilities interface. | |
444 | 446 |
445 def _finish_inline_clone_bundle(self, stream): | 447 def _finish_inline_clone_bundle(self, stream): |
446 # HTTP streams must hit the end to process the last empty | 448 # HTTP streams must hit the end to process the last empty |
447 # chunk of Chunked-Encoding so the connection can be reused. | 449 # chunk of Chunked-Encoding so the connection can be reused. |
448 chunk = stream.read(1) | 450 chunk = stream.read(1) |
449 if chunk: | 451 if chunk: |
450 self._abort(error.ResponseError(_(b"unexpected response:"), chunk)) | 452 self._abort(error.ResponseError(_(b"unexpected response:"), chunk)) |
451 | |
452 # End of ipeercommands interface. | |
453 | 453 |
454 def _callstream(self, cmd, _compressible=False, **args): | 454 def _callstream(self, cmd, _compressible=False, **args): |
455 args = pycompat.byteskwargs(args) | 455 args = pycompat.byteskwargs(args) |
456 | 456 |
457 req, cu, qs = makev1commandrequest( | 457 req, cu, qs = makev1commandrequest( |