D4468: wireprotov2server: use our CBOR encoder

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Wed Sep 5 08:23:42 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG660879e49b46: wireprotov2server: use our CBOR encoder (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4468?vs=10765&id=10785

REVISION DETAIL
  https://phab.mercurial-scm.org/D4468

AFFECTED FILES
  mercurial/wireprotov2server.py
  tests/test-http-api-httpv2.t
  tests/test-wireproto-command-capabilities.t
  tests/test-wireproto-command-listkeys.t

CHANGE DETAILS

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 @@
   s>     \r\n
   s>     33\r\n
   s>     +\x00\x00\x01\x00\x02\x012
-  s>     \xa1FstatusBok\xa3Fphases at Ibookmarks@Jnamespaces@
+  s>     \xa1FstatusBok\xa3Ibookmarks at 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 @@
   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
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 @@
   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-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 @@
   s>     Transfer-Encoding: chunked\r\n
   s>     \r\n
   s>     33\r\n
-  s>     +\x00\x00\x03\x00\x02\x012\xa1FstatusBok\xa3Fphases at Ibookmarks@Jnamespaces@
+  s>     +\x00\x00\x03\x00\x02\x012\xa1FstatusBok\xa3Ibookmarks at Jnamespaces@Fphases@
   s>     \r\n
   s>     14\r\n
   s>     \x0c\x00\x00\x01\x00\x02\x002\xa1FstatusBok\xa0
diff --git a/mercurial/wireprotov2server.py b/mercurial/wireprotov2server.py
--- a/mercurial/wireprotov2server.py
+++ b/mercurial/wireprotov2server.py
@@ -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)



To: indygreg, #hg-reviewers, pulkit
Cc: mercurial-devel


More information about the Mercurial-devel mailing list