D3382: wireprotov2: define response data as CBOR

2018-04-16 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG89a16704114c: wireprotov2: define response data as CBOR 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3382?vs=8294&id=8325

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

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/help/internals/wireprotocol.txt
  mercurial/wireprotoframing.py
  mercurial/wireprotov2peer.py
  mercurial/wireprotov2server.py
  tests/test-http-api-httpv2.t
  tests/test-http-protocol.t
  tests/test-wireproto-command-branchmap.t
  tests/test-wireproto-command-capabilities.t
  tests/test-wireproto-command-heads.t
  tests/test-wireproto-command-known.t
  tests/test-wireproto-command-listkeys.t
  tests/test-wireproto-command-lookup.t
  tests/test-wireproto-command-pushkey.t
  tests/wireprotohelpers.sh

CHANGE DETAILS

diff --git a/tests/wireprotohelpers.sh b/tests/wireprotohelpers.sh
--- a/tests/wireprotohelpers.sh
+++ b/tests/wireprotohelpers.sh
@@ -1,5 +1,5 @@
 HTTPV2=exp-http-v2-0001
-MEDIATYPE=application/mercurial-exp-framing-0003
+MEDIATYPE=application/mercurial-exp-framing-0004
 
 sendhttpraw() {
   hg --verbose debugwireproto --peer raw http://$LOCALIP:$HGPORT/
@@ -26,16 +26,16 @@
 @wireproto.wireprotocommand('customreadonly', permission='pull',
 transportpolicy=wireproto.POLICY_V2_ONLY)
 def customreadonlyv2(repo, proto):
-return wireprototypes.bytesresponse(b'customreadonly bytes response')
+return wireprototypes.cborresponse(b'customreadonly bytes response')
 
 @wireproto.wireprotocommand('customreadwrite', permission='push')
 def customreadwrite(repo, proto):
 return wireprototypes.bytesresponse(b'customreadwrite bytes response')
 
 @wireproto.wireprotocommand('customreadwrite', permission='push',
 transportpolicy=wireproto.POLICY_V2_ONLY)
 def customreadwritev2(repo, proto):
-return wireprototypes.bytesresponse(b'customreadwrite bytes response')
+return wireprototypes.cborresponse(b'customreadwrite bytes response')
 EOF
 
 cat >> $HGRCPATH << EOF
diff --git a/tests/test-wireproto-command-pushkey.t 
b/tests/test-wireproto-command-pushkey.t
--- a/tests/test-wireproto-command-pushkey.t
+++ b/tests/test-wireproto-command-pushkey.t
@@ -32,8 +32,8 @@
   sending pushkey command
   s> *\r\n (glob)
   s> Accept-Encoding: identity\r\n
-  s> accept: application/mercurial-exp-framing-0003\r\n
-  s> content-type: application/mercurial-exp-framing-0003\r\n
+  s> accept: application/mercurial-exp-framing-0004\r\n
+  s> content-type: application/mercurial-exp-framing-0004\r\n
   s> content-length: 105\r\n
   s> host: $LOCALIP:$HGPORT\r\n (glob)
   s> user-agent: Mercurial debugwireproto\r\n
@@ -43,14 +43,14 @@
   s> HTTP/1.1 200 OK\r\n
   s> Server: testing stub value\r\n
   s> Date: $HTTP_DATE$\r\n
-  s> Content-Type: application/mercurial-exp-framing-0003\r\n
+  s> Content-Type: application/mercurial-exp-framing-0004\r\n
   s> Transfer-Encoding: chunked\r\n
   s> \r\n
   s> 9\r\n
-  s> *\x00\x01\x00\x02\x01F (glob)
+  s> \x01\x00\x00\x01\x00\x02\x01B
   s> \xf5
   s> \r\n
-  received frame(size=*; request=1; stream=2; streamflags=stream-begin; 
type=bytes-response; flags=eos|cbor) (glob)
+  received frame(size=1; request=1; stream=2; streamflags=stream-begin; 
type=bytes-response; flags=eos)
   s> 0\r\n
   s> \r\n
   response: True
@@ -63,8 +63,8 @@
   sending listkeys command
   s> POST /api/exp-http-v2-0001/ro/listkeys HTTP/1.1\r\n
   s> Accept-Encoding: identity\r\n
-  s> accept: application/mercurial-exp-framing-0003\r\n
-  s> content-type: application/mercurial-exp-framing-0003\r\n
+  s> accept: application/mercurial-exp-framing-0004\r\n
+  s> content-type: application/mercurial-exp-framing-0004\r\n
   s> content-length: 49\r\n
   s> host: $LOCALIP:$HGPORT\r\n (glob)
   s> user-agent: Mercurial debugwireproto\r\n
@@ -74,14 +74,14 @@
   s> HTTP/1.1 200 OK\r\n
   s> Server: testing stub value\r\n
   s> Date: $HTTP_DATE$\r\n
-  s> Content-Type: application/mercurial-exp-framing-0003\r\n
+  s> Content-Type: application/mercurial-exp-framing-0004\r\n
   s> Transfer-Encoding: chunked\r\n
   s> \r\n
   s> 35\r\n
-  s> -\x00\x00\x01\x00\x02\x01F
+  s> -\x00\x00\x01\x00\x02\x01B
   s> \xa1A@X(426bada5c67598ca65036d57d9e4b64b0c1ce7a0
   s> \r\n
-  received frame(size=45; request=1; stream=2; streamflags=stream-begin; 
type=bytes-response; flags=eos|cbor)
+  received frame(size=45; request=1; stream=2; streamflags=stream-begin; 
type=bytes-response; flags=eos)
   s> 0\r\n
   s> \r\n
   response: {b'@': b'426bada5c67598ca65036d57d9e4b64b0c1ce7a0'}
diff --git a/tests/test-wireproto-command-lookup.t 
b/tests/test-wireproto-command-lookup.t
--- a/tests/test-

D3382: wireprotov2: define response data as CBOR

2018-04-14 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Previously, response data was defined as a stream of bytes. We had
  the option to declare it as CBOR using a frame flag.
  
  We've converged all wire protocol commands exposed on version 2 to
  CBOR. I think consistency is important. The overhead to encoding
  things with CBOR is minimal. Even a very large bytestring can be
  efficiently encoded using an indefinite length bytestring. Now,
  there are limitations with consumers not being able to efficiently
  stream large CBOR values. But these feel like solvable problems.
  
  This commit removes the "is CBOR" frame flag from command response
  frames and defines the frame as always consisting of a stream of
  CBOR values.
  
  The framing protocol media type has been bumped to reflect this
  BC change.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/help/internals/wireprotocol.txt
  mercurial/wireprotoframing.py
  mercurial/wireprotov2peer.py
  mercurial/wireprotov2server.py
  tests/test-http-api-httpv2.t
  tests/test-http-protocol.t
  tests/test-wireproto-command-branchmap.t
  tests/test-wireproto-command-capabilities.t
  tests/test-wireproto-command-heads.t
  tests/test-wireproto-command-known.t
  tests/test-wireproto-command-listkeys.t
  tests/test-wireproto-command-lookup.t
  tests/test-wireproto-command-pushkey.t
  tests/wireprotohelpers.sh

CHANGE DETAILS

diff --git a/tests/wireprotohelpers.sh b/tests/wireprotohelpers.sh
--- a/tests/wireprotohelpers.sh
+++ b/tests/wireprotohelpers.sh
@@ -1,5 +1,5 @@
 HTTPV2=exp-http-v2-0001
-MEDIATYPE=application/mercurial-exp-framing-0003
+MEDIATYPE=application/mercurial-exp-framing-0004
 
 sendhttpraw() {
   hg --verbose debugwireproto --peer raw http://$LOCALIP:$HGPORT/
@@ -26,16 +26,16 @@
 @wireproto.wireprotocommand('customreadonly', permission='pull',
 transportpolicy=wireproto.POLICY_V2_ONLY)
 def customreadonlyv2(repo, proto):
-return wireprototypes.bytesresponse(b'customreadonly bytes response')
+return wireprototypes.cborresponse(b'customreadonly bytes response')
 
 @wireproto.wireprotocommand('customreadwrite', permission='push')
 def customreadwrite(repo, proto):
 return wireprototypes.bytesresponse(b'customreadwrite bytes response')
 
 @wireproto.wireprotocommand('customreadwrite', permission='push',
 transportpolicy=wireproto.POLICY_V2_ONLY)
 def customreadwritev2(repo, proto):
-return wireprototypes.bytesresponse(b'customreadwrite bytes response')
+return wireprototypes.cborresponse(b'customreadwrite bytes response')
 EOF
 
 cat >> $HGRCPATH << EOF
diff --git a/tests/test-wireproto-command-pushkey.t 
b/tests/test-wireproto-command-pushkey.t
--- a/tests/test-wireproto-command-pushkey.t
+++ b/tests/test-wireproto-command-pushkey.t
@@ -32,8 +32,8 @@
   sending pushkey command
   s> *\r\n (glob)
   s> Accept-Encoding: identity\r\n
-  s> accept: application/mercurial-exp-framing-0003\r\n
-  s> content-type: application/mercurial-exp-framing-0003\r\n
+  s> accept: application/mercurial-exp-framing-0004\r\n
+  s> content-type: application/mercurial-exp-framing-0004\r\n
   s> content-length: 105\r\n
   s> host: $LOCALIP:$HGPORT\r\n (glob)
   s> user-agent: Mercurial debugwireproto\r\n
@@ -43,14 +43,14 @@
   s> HTTP/1.1 200 OK\r\n
   s> Server: testing stub value\r\n
   s> Date: $HTTP_DATE$\r\n
-  s> Content-Type: application/mercurial-exp-framing-0003\r\n
+  s> Content-Type: application/mercurial-exp-framing-0004\r\n
   s> Transfer-Encoding: chunked\r\n
   s> \r\n
   s> 9\r\n
-  s> *\x00\x01\x00\x02\x01F (glob)
+  s> \x01\x00\x00\x01\x00\x02\x01B
   s> \xf5
   s> \r\n
-  received frame(size=*; request=1; stream=2; streamflags=stream-begin; 
type=bytes-response; flags=eos|cbor) (glob)
+  received frame(size=1; request=1; stream=2; streamflags=stream-begin; 
type=bytes-response; flags=eos)
   s> 0\r\n
   s> \r\n
   response: True
@@ -63,8 +63,8 @@
   sending listkeys command
   s> POST /api/exp-http-v2-0001/ro/listkeys HTTP/1.1\r\n
   s> Accept-Encoding: identity\r\n
-  s> accept: application/mercurial-exp-framing-0003\r\n
-  s> content-type: application/mercurial-exp-framing-0003\r\n
+  s> accept: application/mercurial-exp-framing-0004\r\n
+  s> content-type: application/mercurial-exp-framing-0004\r\n
   s> content-length: 49\r\n
   s> host: $LOCALIP:$HGPORT\r\n (glob)
   s> user-agent: Mercurial debugwireproto\r\n
@@ -74,14 +74,14 @@
   s> HTTP/1.1 200 OK\r\n
   s> Server: testing stub value\r\n
   s> Date: $HTTP_DATE$\r\n
-  s> Content-Type: application/mercurial-exp-framing-0003\r\n
+  s> Content-Type: application/mercurial-exp-framing-0004\r\n
   s> Transf