D3067: wireproto: convert human output frames to CBOR

2018-04-04 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG36d17f37db91: wireproto: convert human output frames to 
CBOR (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3067?vs=7610=7619

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

AFFECTED FILES
  mercurial/help/internals/wireprotocol.txt
  mercurial/wireprotoframing.py
  tests/test-wireproto-serverreactor.py

CHANGE DETAILS

diff --git a/tests/test-wireproto-serverreactor.py 
b/tests/test-wireproto-serverreactor.py
--- a/tests/test-wireproto-serverreactor.py
+++ b/tests/test-wireproto-serverreactor.py
@@ -136,22 +136,6 @@
 ffs(b'1 1 0 command-data eos %s' % data.getvalue()),
 ])
 
-def testtextoutputexcessiveargs(self):
-"""At most 255 formatting arguments are allowed."""
-with self.assertRaisesRegexp(ValueError,
- 'cannot use more than 255 formatting'):
-args = [b'x' for i in range(256)]
-list(framing.createtextoutputframe(None, 1,
-   [(b'bleh', args, [])]))
-
-def testtextoutputexcessivelabels(self):
-"""At most 255 labels are allowed."""
-with self.assertRaisesRegexp(ValueError,
- 'cannot use more than 255 labels'):
-labels = [b'l' for i in range(256)]
-list(framing.createtextoutputframe(None, 1,
-   [(b'bleh', [], labels)]))
-
 def testtextoutputformattingstringtype(self):
 """Formatting string must be bytes."""
 with self.assertRaisesRegexp(ValueError, 'must use bytes formatting '):
@@ -168,31 +152,14 @@
 list(framing.createtextoutputframe(None, 1, [
 (b'foo', [], [b'foo'.decode('ascii')])]))
 
-def testtextoutputtoolongformatstring(self):
-with self.assertRaisesRegexp(ValueError,
- 'formatting string cannot be longer 
than'):
-list(framing.createtextoutputframe(None, 1, [
-(b'x' * 65536, [], [])]))
-
-def testtextoutputtoolongargumentstring(self):
-with self.assertRaisesRegexp(ValueError,
- 'argument string cannot be longer than'):
-list(framing.createtextoutputframe(None, 1, [
-(b'bleh', [b'x' * 65536], [])]))
-
-def testtextoutputtoolonglabelstring(self):
-with self.assertRaisesRegexp(ValueError,
- 'label string cannot be longer than'):
-list(framing.createtextoutputframe(None, 1, [
-(b'bleh', [], [b'x' * 65536])]))
-
 def testtextoutput1simpleatom(self):
 stream = framing.stream(1)
 val = list(framing.createtextoutputframe(stream, 1, [
 (b'foo', [], [])]))
 
 self.assertEqual(val, [
-ffs(br'1 1 stream-begin text-output 0 \x03\x00\x00\x00foo'),
+ffs(b'1 1 stream-begin text-output 0 '
+b"cbor:[{b'msg': b'foo'}]"),
 ])
 
 def testtextoutput2simpleatoms(self):
@@ -203,8 +170,8 @@
 ]))
 
 self.assertEqual(val, [
-ffs(br'1 1 stream-begin text-output 0 '
-br'\x03\x00\x00\x00foo\x03\x00\x00\x00bar'),
+ffs(b'1 1 stream-begin text-output 0 '
+b"cbor:[{b'msg': b'foo'}, {b'msg': b'bar'}]")
 ])
 
 def testtextoutput1arg(self):
@@ -214,8 +181,8 @@
 ]))
 
 self.assertEqual(val, [
-ffs(br'1 1 stream-begin text-output 0 '
-br'\x06\x00\x00\x01\x04\x00foo %sval1'),
+ffs(b'1 1 stream-begin text-output 0 '
+b"cbor:[{b'msg': b'foo %s', b'args': [b'val1']}]")
 ])
 
 def testtextoutput2arg(self):
@@ -225,8 +192,8 @@
 ]))
 
 self.assertEqual(val, [
-ffs(br'1 1 stream-begin text-output 0 '
-br'\x09\x00\x00\x02\x03\x00\x05\x00foo %s %svalvalue'),
+ffs(b'1 1 stream-begin text-output 0 '
+b"cbor:[{b'msg': b'foo %s %s', b'args': [b'val', b'value']}]")
 ])
 
 def testtextoutput1label(self):
@@ -236,8 +203,8 @@
 ]))
 
 self.assertEqual(val, [
-ffs(br'1 1 stream-begin text-output 0 '
-br'\x03\x00\x01\x00\x05foolabel'),
+ffs(b'1 1 stream-begin text-output 0 '
+b"cbor:[{b'msg': b'foo', b'labels': [b'label']}]")
 ])
 
 def testargandlabel(self):
@@ -247,8 +214,9 @@
 ]))
 
 self.assertEqual(val, [
-ffs(br'1 1 stream-begin text-output 0 '
-br'\x06\x00\x01\x01\x05\x03\x00foo %slabelarg'),
+ffs(b'1 1 stream-begin text-output 0 '
+b"cbor:[{b'msg': b'foo %s', b'args': [b'arg'], "
+b"b'labels': [b'label']}]")
 ])
 

D3067: wireproto: convert human output frames to CBOR

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

REVISION SUMMARY
  This is easier than rolling our own encoding format.
  
  As a bonus, some of our artificial limits around lengths of
  things went away because we are no longer using fixed length
  fields to hold sizes.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/help/internals/wireprotocol.txt
  mercurial/wireprotoframing.py
  tests/test-wireproto-serverreactor.py

CHANGE DETAILS

diff --git a/tests/test-wireproto-serverreactor.py 
b/tests/test-wireproto-serverreactor.py
--- a/tests/test-wireproto-serverreactor.py
+++ b/tests/test-wireproto-serverreactor.py
@@ -136,22 +136,6 @@
 ffs(b'1 1 0 command-data eos %s' % data.getvalue()),
 ])
 
-def testtextoutputexcessiveargs(self):
-"""At most 255 formatting arguments are allowed."""
-with self.assertRaisesRegexp(ValueError,
- 'cannot use more than 255 formatting'):
-args = [b'x' for i in range(256)]
-list(framing.createtextoutputframe(None, 1,
-   [(b'bleh', args, [])]))
-
-def testtextoutputexcessivelabels(self):
-"""At most 255 labels are allowed."""
-with self.assertRaisesRegexp(ValueError,
- 'cannot use more than 255 labels'):
-labels = [b'l' for i in range(256)]
-list(framing.createtextoutputframe(None, 1,
-   [(b'bleh', [], labels)]))
-
 def testtextoutputformattingstringtype(self):
 """Formatting string must be bytes."""
 with self.assertRaisesRegexp(ValueError, 'must use bytes formatting '):
@@ -168,31 +152,14 @@
 list(framing.createtextoutputframe(None, 1, [
 (b'foo', [], [b'foo'.decode('ascii')])]))
 
-def testtextoutputtoolongformatstring(self):
-with self.assertRaisesRegexp(ValueError,
- 'formatting string cannot be longer 
than'):
-list(framing.createtextoutputframe(None, 1, [
-(b'x' * 65536, [], [])]))
-
-def testtextoutputtoolongargumentstring(self):
-with self.assertRaisesRegexp(ValueError,
- 'argument string cannot be longer than'):
-list(framing.createtextoutputframe(None, 1, [
-(b'bleh', [b'x' * 65536], [])]))
-
-def testtextoutputtoolonglabelstring(self):
-with self.assertRaisesRegexp(ValueError,
- 'label string cannot be longer than'):
-list(framing.createtextoutputframe(None, 1, [
-(b'bleh', [], [b'x' * 65536])]))
-
 def testtextoutput1simpleatom(self):
 stream = framing.stream(1)
 val = list(framing.createtextoutputframe(stream, 1, [
 (b'foo', [], [])]))
 
 self.assertEqual(val, [
-ffs(br'1 1 stream-begin text-output 0 \x03\x00\x00\x00foo'),
+ffs(b'1 1 stream-begin text-output 0 '
+b"cbor:[{b'msg': b'foo'}]"),
 ])
 
 def testtextoutput2simpleatoms(self):
@@ -203,8 +170,8 @@
 ]))
 
 self.assertEqual(val, [
-ffs(br'1 1 stream-begin text-output 0 '
-br'\x03\x00\x00\x00foo\x03\x00\x00\x00bar'),
+ffs(b'1 1 stream-begin text-output 0 '
+b"cbor:[{b'msg': b'foo'}, {b'msg': b'bar'}]")
 ])
 
 def testtextoutput1arg(self):
@@ -214,8 +181,8 @@
 ]))
 
 self.assertEqual(val, [
-ffs(br'1 1 stream-begin text-output 0 '
-br'\x06\x00\x00\x01\x04\x00foo %sval1'),
+ffs(b'1 1 stream-begin text-output 0 '
+b"cbor:[{b'msg': b'foo %s', b'args': [b'val1']}]")
 ])
 
 def testtextoutput2arg(self):
@@ -225,8 +192,8 @@
 ]))
 
 self.assertEqual(val, [
-ffs(br'1 1 stream-begin text-output 0 '
-br'\x09\x00\x00\x02\x03\x00\x05\x00foo %s %svalvalue'),
+ffs(b'1 1 stream-begin text-output 0 '
+b"cbor:[{b'msg': b'foo %s %s', b'args': [b'val', b'value']}]")
 ])
 
 def testtextoutput1label(self):
@@ -236,8 +203,8 @@
 ]))
 
 self.assertEqual(val, [
-ffs(br'1 1 stream-begin text-output 0 '
-br'\x03\x00\x01\x00\x05foolabel'),
+ffs(b'1 1 stream-begin text-output 0 '
+b"cbor:[{b'msg': b'foo', b'labels': [b'label']}]")
 ])
 
 def testargandlabel(self):
@@ -247,8 +214,9 @@
 ]))
 
 self.assertEqual(val, [
-ffs(br'1 1 stream-begin text-output 0 '
-br'\x06\x00\x01\x01\x05\x03\x00foo %slabelarg'),
+ffs(b'1 1 stream-begin text-output 0 '
+b"cbor:[{b'msg': b'foo %s', b'args':