diff --git a/mercurial/wireprotov2server.py b/mercurial/wireprotov2server.py --- a/mercurial/wireprotov2server.py +++ b/mercurial/wireprotov2server.py @@ -9,9 +9,6 @@ from __future__ import absolute_import import contextlib from .i18n import _ -from .thirdparty import ( - cbor, -) from . import ( encoding, error, @@ -22,6 +19,7 @@ from . import ( wireprototypes, ) from .utils import ( + cborutil, interfaceutil, ) @@ -302,8 +300,11 @@ def _httpv2runcommand(ui, repo, req, res res.status = b'200 OK' res.headers[b'Content-Type'] = FRAMINGTYPE + # TODO consider adding a type to represent an iterable of values to + # be CBOR encoded. if isinstance(rsp, wireprototypes.cborresponse): - encoded = cbor.dumps(rsp.value, canonical=True) + # TODO consider calling oncommandresponsereadygen(). + encoded = b''.join(cborutil.streamencode(rsp.value)) action, meta = reactor.oncommandresponseready(outstream, command['requestid'], encoded) diff --git a/tests/test-http-api-httpv2.t b/tests/test-http-api-httpv2.t --- a/tests/test-http-api-httpv2.t +++ b/tests/test-http-api-httpv2.t @@ -517,7 +517,7 @@ Interleaved requests to "multirequest" a s> Transfer-Encoding: chunked\r\n s> \r\n s> 33\r\n - s> +\x00\x00\x03\x00\x02\x012\xa1FstatusBok\xa3Fphases@Ibookmarks@Jnamespaces@ + s> +\x00\x00\x03\x00\x02\x012\xa1FstatusBok\xa3Ibookmarks@Jnamespaces@Fphases@ s> \r\n s> 14\r\n s> \x0c\x00\x00\x01\x00\x02\x002\xa1FstatusBok\xa0 diff --git a/tests/test-wireproto-command-capabilities.t b/tests/test-wireproto-command-capabilities.t --- a/tests/test-wireproto-command-capabilities.t +++ b/tests/test-wireproto-command-capabilities.t @@ -335,7 +335,7 @@ capabilities command returns expected in s> \r\n s> 1d7\r\n s> \xcf\x01\x00\x01\x00\x02\x012 - s> \xa1FstatusBok\xa4Hcommands\xa7Eheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyCnewCnewColdColdInamespaceBnsKpermissions\x81DpushHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullKcompression\x81\xa1DnameDzlibNrawrepoformats\x82LgeneraldeltaHrevlogv1Qframingmediatypes\x81X&application/mercurial-exp-framing-0005 + s> \xa1FstatusBok\xa4Hcommands\xa7Ibranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullEheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyInamespaceBnsCnewCnewColdColdKpermissions\x81DpushKcompression\x81\xa1DnameDzlibQframingmediatypes\x81X&application/mercurial-exp-framing-0005Nrawrepoformats\x82LgeneraldeltaHrevlogv1 s> \r\n received frame(size=463; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos) s> 0\r\n diff --git a/tests/test-wireproto-command-listkeys.t b/tests/test-wireproto-command-listkeys.t --- a/tests/test-wireproto-command-listkeys.t +++ b/tests/test-wireproto-command-listkeys.t @@ -49,7 +49,7 @@ Request for namespaces works s> \r\n s> 33\r\n s> +\x00\x00\x01\x00\x02\x012 - s> \xa1FstatusBok\xa3Fphases@Ibookmarks@Jnamespaces@ + s> \xa1FstatusBok\xa3Ibookmarks@Jnamespaces@Fphases@ s> \r\n received frame(size=43; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos) s> 0\r\n @@ -86,7 +86,7 @@ Request for phases works s> \r\n s> 50\r\n s> H\x00\x00\x01\x00\x02\x012 - s> \xa1FstatusBok\xa2JpublishingDTrueX(be0ef73c17ade3fc89dc41701eb9fc3a91b58282A1 + s> \xa1FstatusBok\xa2X(be0ef73c17ade3fc89dc41701eb9fc3a91b58282A1JpublishingDTrue s> \r\n received frame(size=72; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos) s> 0\r\n