Mercurial > public > mercurial-scm > hg-stable
diff mercurial/wireprotov2server.py @ 39467:660879e49b46
wireprotov2server: use our CBOR encoder
Again, test output changed slightly because of map key ordering
differences. This shouldn't matter.
I could have called oncommandresponsereadygen() with the raw output
from the stream encoder. However, this changed test output further.
I left a TODO to follow up on that later.
Differential Revision: https://phab.mercurial-scm.org/D4468
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 28 Aug 2018 18:12:04 -0700 |
parents | 856f381ad74b |
children | 07b58266bce3 |
line wrap: on
line diff
--- a/mercurial/wireprotov2server.py Tue Aug 28 18:05:48 2018 -0700 +++ b/mercurial/wireprotov2server.py Tue Aug 28 18:12:04 2018 -0700 @@ -9,9 +9,6 @@ import contextlib from .i18n import _ -from .thirdparty import ( - cbor, -) from . import ( encoding, error, @@ -22,6 +19,7 @@ wireprototypes, ) from .utils import ( + cborutil, interfaceutil, ) @@ -302,8 +300,11 @@ 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)