changeset 39378:0f549da54379

stringutil: teach pprint() to indent This will make data structure dumping in various places a bit easier to read and diff. Since I wanted this for `hg debugwireproto` output, I added indentation to it. A more advanced pretty printer implementation would conditionally add newlines if output is too long. But it is vastly simpler to be consistent and always add newlines when indenting. Again, I'm not crazy about the verbosity of the code and there is room to consolidate logic for "print a collection." But this isn't the most complicated code in the world and I'm not convinced it is worth doing. Differential Revision: https://phab.mercurial-scm.org/D4399
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 27 Aug 2018 09:13:58 -0700
parents b4e7e1f09c09
children b64d36e5ca31
files mercurial/debugcommands.py mercurial/utils/stringutil.py tests/test-http-api-httpv2.t tests/test-http-protocol.t tests/test-ssh-proto.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-pushkey.t
diffstat 11 files changed, 380 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Wed Aug 22 08:20:51 2018 +0800
+++ b/mercurial/debugcommands.py	Mon Aug 27 09:13:58 2018 -0700
@@ -3244,11 +3244,10 @@
                 if isinstance(res, wireprotov2peer.commandresponse):
                     val = list(res.cborobjects())
                     ui.status(_('response: %s\n') %
-                              stringutil.pprint(val, bprefix=True))
-
+                              stringutil.pprint(val, bprefix=True, indent=2))
                 else:
                     ui.status(_('response: %s\n') %
-                              stringutil.pprint(res, bprefix=True))
+                              stringutil.pprint(res, bprefix=True, indent=2))
 
         elif action == 'batchbegin':
             if batchedcommands is not None:
@@ -3322,7 +3321,8 @@
 
             if res.headers.get('Content-Type') == 'application/mercurial-cbor':
                 ui.write(_('cbor> %s\n') %
-                         stringutil.pprint(cbor.loads(body), bprefix=True))
+                         stringutil.pprint(cbor.loads(body), bprefix=True,
+                                           indent=2))
 
         elif action == 'close':
             peer.close()
--- a/mercurial/utils/stringutil.py	Wed Aug 22 08:20:51 2018 +0800
+++ b/mercurial/utils/stringutil.py	Mon Aug 27 09:13:58 2018 -0700
@@ -43,12 +43,20 @@
         return pat
     return pat.encode('latin1')
 
-def pprint(o, bprefix=False):
+def pprint(o, bprefix=False, indent=0):
     """Pretty print an object."""
-    return b''.join(pprintgen(o, bprefix=bprefix))
+    return b''.join(pprintgen(o, bprefix=bprefix, indent=indent))
+
+def pprintgen(o, bprefix=False, indent=0, _level=1):
+    """Pretty print an object to a generator of atoms.
 
-def pprintgen(o, bprefix=False):
-    """Pretty print an object to a generator of atoms."""
+    ``bprefix`` is a flag influencing whether bytestrings are preferred with
+    a ``b''`` prefix.
+
+    ``indent`` controls whether collections and nested data structures
+    span multiple lines via the indentation amount in spaces. By default,
+    no newlines are emitted.
+    """
 
     if isinstance(o, bytes):
         if bprefix:
@@ -66,12 +74,25 @@
 
         yield '['
 
+        if indent:
+            yield '\n'
+            yield ' ' * (_level * indent)
+
         for i, a in enumerate(o):
-            for chunk in pprintgen(a, bprefix=bprefix):
+            for chunk in pprintgen(a, bprefix=bprefix, indent=indent,
+                                   _level=_level + 1):
                 yield chunk
 
             if i + 1 < len(o):
-                yield ', '
+                if indent:
+                    yield ',\n'
+                    yield ' ' * (_level * indent)
+                else:
+                    yield ', '
+
+        if indent:
+            yield '\n'
+            yield ' ' * ((_level - 1) * indent)
 
         yield ']'
     elif isinstance(o, dict):
@@ -81,17 +102,31 @@
 
         yield '{'
 
+        if indent:
+            yield '\n'
+            yield ' ' * (_level * indent)
+
         for i, (k, v) in enumerate(sorted(o.items())):
-            for chunk in pprintgen(k, bprefix=bprefix):
+            for chunk in pprintgen(k, bprefix=bprefix, indent=indent,
+                                   _level=_level + 1):
                 yield chunk
 
             yield ': '
 
-            for chunk in pprintgen(v, bprefix=bprefix):
+            for chunk in pprintgen(v, bprefix=bprefix, indent=indent,
+                                   _level=_level + 1):
                 yield chunk
 
             if i + 1 < len(o):
-                yield ', '
+                if indent:
+                    yield ',\n'
+                    yield ' ' * (_level * indent)
+                else:
+                    yield ', '
+
+        if indent:
+            yield '\n'
+            yield ' ' * ((_level - 1) * indent)
 
         yield '}'
     elif isinstance(o, set):
@@ -101,12 +136,25 @@
 
         yield 'set(['
 
+        if indent:
+            yield '\n'
+            yield ' ' * (_level * indent)
+
         for i, k in enumerate(sorted(o)):
-            for chunk in pprintgen(k, bprefix=bprefix):
+            for chunk in pprintgen(k, bprefix=bprefix, indent=indent,
+                                   _level=_level + 1):
                 yield chunk
 
             if i + 1 < len(o):
-                yield ', '
+                if indent:
+                    yield ',\n'
+                    yield ' ' * (_level * indent)
+                else:
+                    yield ', '
+
+        if indent:
+            yield '\n'
+            yield ' ' * ((_level - 1) * indent)
 
         yield '])'
     elif isinstance(o, tuple):
@@ -116,12 +164,25 @@
 
         yield '('
 
+        if indent:
+            yield '\n'
+            yield ' ' * (_level * indent)
+
         for i, a in enumerate(o):
-            for chunk in pprintgen(a, bprefix=bprefix):
+            for chunk in pprintgen(a, bprefix=bprefix, indent=indent,
+                                   _level=_level + 1):
                 yield chunk
 
             if i + 1 < len(o):
-                yield ', '
+                if indent:
+                    yield ',\n'
+                    yield ' ' * (_level * indent)
+                else:
+                    yield ', '
+
+        if indent:
+            yield '\n'
+            yield ' ' * ((_level - 1) * indent)
 
         yield ')'
     elif isinstance(o, types.GeneratorType):
@@ -134,6 +195,10 @@
 
         yield 'gen['
 
+        if indent:
+            yield '\n'
+            yield ' ' * (_level * indent)
+
         last = False
 
         while not last:
@@ -144,11 +209,20 @@
             except StopIteration:
                 last = True
 
-            for chunk in pprintgen(current, bprefix=bprefix):
+            for chunk in pprintgen(current, bprefix=bprefix, indent=indent,
+                                   _level=_level + 1):
                 yield chunk
 
             if not last:
-                yield ', '
+                if indent:
+                    yield ',\n'
+                    yield ' ' * (_level * indent)
+                else:
+                    yield ', '
+
+        if indent:
+            yield '\n'
+            yield ' ' * ((_level -1) * indent)
 
         yield ']'
     else:
--- a/tests/test-http-api-httpv2.t	Wed Aug 22 08:20:51 2018 +0800
+++ b/tests/test-http-api-httpv2.t	Mon Aug 27 09:13:58 2018 -0700
@@ -210,7 +210,12 @@
   received frame(size=42; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
   s>     0\r\n
   s>     \r\n
-  response: [{b'status': b'ok'}, b'customreadonly bytes response']
+  response: [
+    {
+      b'status': b'ok'
+    },
+    b'customreadonly bytes response'
+  ]
 
 Request to read-write command fails because server is read-only by default
 
--- a/tests/test-http-protocol.t	Wed Aug 22 08:20:51 2018 +0800
+++ b/tests/test-http-protocol.t	Mon Aug 27 09:13:58 2018 -0700
@@ -213,7 +213,11 @@
   s>     bookmarks\t\n
   s>     namespaces\t\n
   s>     phases\t
-  response: {b'bookmarks': b'', b'namespaces': b'', b'phases': b''}
+  response: {
+    b'bookmarks': b'',
+    b'namespaces': b'',
+    b'phases': b''
+  }
 
 Same thing, but with "httprequest" command
 
@@ -279,7 +283,9 @@
   s>     Content-Length: 41\r\n
   s>     \r\n
   s>     0000000000000000000000000000000000000000\n
-  response: [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00']
+  response: [
+    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+  ]
 
   $ killdaemons.py
   $ enablehttpv2 empty
@@ -332,7 +338,9 @@
   received frame(size=33; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
   s>     0\r\n
   s>     \r\n
-  response: [b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00']
+  response: [
+    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+  ]
 
   $ killdaemons.py
 
@@ -463,7 +471,9 @@
   s>     Content-Length: 41\r\n
   s>     \r\n
   s>     96ee1d7354c4ad7372047672c36a1f561e3a6a4c\n
-  response: [b'\x96\xee\x1dsT\xc4\xadsr\x04vr\xc3j\x1fV\x1e:jL']
+  response: [
+    b'\x96\xee\x1dsT\xc4\xadsr\x04vr\xc3j\x1fV\x1e:jL'
+  ]
 
   $ killdaemons.py
 
@@ -725,4 +735,6 @@
   s>     Content-Length: 41\r\n
   s>     \r\n
   s>     96ee1d7354c4ad7372047672c36a1f561e3a6a4c\n
-  response: [b'\x96\xee\x1dsT\xc4\xadsr\x04vr\xc3j\x1fV\x1e:jL']
+  response: [
+    b'\x96\xee\x1dsT\xc4\xadsr\x04vr\xc3j\x1fV\x1e:jL'
+  ]
--- a/tests/test-ssh-proto.t	Wed Aug 22 08:20:51 2018 +0800
+++ b/tests/test-ssh-proto.t	Mon Aug 27 09:13:58 2018 -0700
@@ -1357,7 +1357,11 @@
   o>     bookmarks\t\n
   o>     namespaces\t\n
   o>     phases\t
-  response: {b'bookmarks': b'', b'namespaces': b'', b'phases': b''}
+  response: {
+    b'bookmarks': b'',
+    b'namespaces': b'',
+    b'phases': b''
+  }
   
   testing ssh2
   creating ssh peer from handshake results
@@ -1388,7 +1392,11 @@
   o>     bookmarks\t\n
   o>     namespaces\t\n
   o>     phases\t
-  response: {b'bookmarks': b'', b'namespaces': b'', b'phases': b''}
+  response: {
+    b'bookmarks': b'',
+    b'namespaces': b'',
+    b'phases': b''
+  }
 
   $ cd ..
 
@@ -1495,7 +1503,9 @@
   o> bufferedreadline() -> 3:
   o>     46\n
   o> bufferedread(46) -> 46: bookA\t68986213bd4485ea51533535e3fc9e78007a711f
-  response: {b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f'}
+  response: {
+    b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f'
+  }
   
   testing ssh2
   creating ssh peer from handshake results
@@ -1523,7 +1533,9 @@
   o> bufferedreadline() -> 3:
   o>     46\n
   o> bufferedread(46) -> 46: bookA\t68986213bd4485ea51533535e3fc9e78007a711f
-  response: {b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f'}
+  response: {
+    b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f'
+  }
 
 With multiple bookmarks set
 
@@ -1560,7 +1572,10 @@
   o> bufferedread(93) -> 93:
   o>     bookA\t68986213bd4485ea51533535e3fc9e78007a711f\n
   o>     bookB\t1880f3755e2e52e3199e0ee5638128b08642f34d
-  response: {b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f', b'bookB': b'1880f3755e2e52e3199e0ee5638128b08642f34d'}
+  response: {
+    b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f',
+    b'bookB': b'1880f3755e2e52e3199e0ee5638128b08642f34d'
+  }
   
   testing ssh2
   creating ssh peer from handshake results
@@ -1590,7 +1605,10 @@
   o> bufferedread(93) -> 93:
   o>     bookA\t68986213bd4485ea51533535e3fc9e78007a711f\n
   o>     bookB\t1880f3755e2e52e3199e0ee5638128b08642f34d
-  response: {b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f', b'bookB': b'1880f3755e2e52e3199e0ee5638128b08642f34d'}
+  response: {
+    b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f',
+    b'bookB': b'1880f3755e2e52e3199e0ee5638128b08642f34d'
+  }
 
 Test pushkey for bookmarks
 
@@ -1719,7 +1737,9 @@
   o> bufferedreadline() -> 3:
   o>     15\n
   o> bufferedread(15) -> 15: publishing\tTrue
-  response: {b'publishing': b'True'}
+  response: {
+    b'publishing': b'True'
+  }
   
   testing ssh2
   creating ssh peer from handshake results
@@ -1747,7 +1767,9 @@
   o> bufferedreadline() -> 3:
   o>     15\n
   o> bufferedread(15) -> 15: publishing\tTrue
-  response: {b'publishing': b'True'}
+  response: {
+    b'publishing': b'True'
+  }
 
 Create some commits
 
@@ -1801,7 +1823,11 @@
   o>     20b8a89289d80036e6c4e87c2083e3bea1586637\t1\n
   o>     c4750011d906c18ea2f0527419cbc1a544435150\t1\n
   o>     publishing\tTrue
-  response: {b'20b8a89289d80036e6c4e87c2083e3bea1586637': b'1', b'c4750011d906c18ea2f0527419cbc1a544435150': b'1', b'publishing': b'True'}
+  response: {
+    b'20b8a89289d80036e6c4e87c2083e3bea1586637': b'1',
+    b'c4750011d906c18ea2f0527419cbc1a544435150': b'1',
+    b'publishing': b'True'
+  }
   
   testing ssh2
   creating ssh peer from handshake results
@@ -1832,7 +1858,11 @@
   o>     20b8a89289d80036e6c4e87c2083e3bea1586637\t1\n
   o>     c4750011d906c18ea2f0527419cbc1a544435150\t1\n
   o>     publishing\tTrue
-  response: {b'20b8a89289d80036e6c4e87c2083e3bea1586637': b'1', b'c4750011d906c18ea2f0527419cbc1a544435150': b'1', b'publishing': b'True'}
+  response: {
+    b'20b8a89289d80036e6c4e87c2083e3bea1586637': b'1',
+    b'c4750011d906c18ea2f0527419cbc1a544435150': b'1',
+    b'publishing': b'True'
+  }
 
 Single draft head
 
@@ -1869,7 +1899,10 @@
   o> bufferedread(58) -> 58:
   o>     c4750011d906c18ea2f0527419cbc1a544435150\t1\n
   o>     publishing\tTrue
-  response: {b'c4750011d906c18ea2f0527419cbc1a544435150': b'1', b'publishing': b'True'}
+  response: {
+    b'c4750011d906c18ea2f0527419cbc1a544435150': b'1',
+    b'publishing': b'True'
+  }
   
   testing ssh2
   creating ssh peer from handshake results
@@ -1899,7 +1932,10 @@
   o> bufferedread(58) -> 58:
   o>     c4750011d906c18ea2f0527419cbc1a544435150\t1\n
   o>     publishing\tTrue
-  response: {b'c4750011d906c18ea2f0527419cbc1a544435150': b'1', b'publishing': b'True'}
+  response: {
+    b'c4750011d906c18ea2f0527419cbc1a544435150': b'1',
+    b'publishing': b'True'
+  }
 
 All public heads
 
@@ -1934,7 +1970,9 @@
   o> bufferedreadline() -> 3:
   o>     15\n
   o> bufferedread(15) -> 15: publishing\tTrue
-  response: {b'publishing': b'True'}
+  response: {
+    b'publishing': b'True'
+  }
   
   testing ssh2
   creating ssh peer from handshake results
@@ -1962,7 +2000,9 @@
   o> bufferedreadline() -> 3:
   o>     15\n
   o> bufferedread(15) -> 15: publishing\tTrue
-  response: {b'publishing': b'True'}
+  response: {
+    b'publishing': b'True'
+  }
 
 Setting public phase via pushkey
 
--- a/tests/test-wireproto-command-branchmap.t	Wed Aug 22 08:20:51 2018 +0800
+++ b/tests/test-wireproto-command-branchmap.t	Mon Aug 27 09:13:58 2018 -0700
@@ -67,6 +67,17 @@
   received frame(size=123; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
   s>     0\r\n
   s>     \r\n
-  response: {b'branch1': [b'\xb5\xfa\xac\xdf\xd2c7h\xcb1R3l\xc0\x953\x81&f\x88'], b'branch2': [b'"Aa\xc7X\x9a\xa4\x8f\xa8:H\xfe\xff^\x95\xb5j\xe3\'\xfc'], b'default': [b'&\x80Z\xba\x1e`\n\x82\xe96a\x14\x9f#\x13\x86j"\x1a{', b'\xbe\x0e\xf7<\x17\xad\xe3\xfc\x89\xdcAp\x1e\xb9\xfc:\x91\xb5\x82\x82']}
+  response: {
+    b'branch1': [
+      b'\xb5\xfa\xac\xdf\xd2c7h\xcb1R3l\xc0\x953\x81&f\x88'
+    ],
+    b'branch2': [
+      b'"Aa\xc7X\x9a\xa4\x8f\xa8:H\xfe\xff^\x95\xb5j\xe3\'\xfc'
+    ],
+    b'default': [
+      b'&\x80Z\xba\x1e`\n\x82\xe96a\x14\x9f#\x13\x86j"\x1a{',
+      b'\xbe\x0e\xf7<\x17\xad\xe3\xfc\x89\xdcAp\x1e\xb9\xfc:\x91\xb5\x82\x82'
+    ]
+  }
 
   $ cat error.log
--- a/tests/test-wireproto-command-capabilities.t	Wed Aug 22 08:20:51 2018 +0800
+++ b/tests/test-wireproto-command-capabilities.t	Mon Aug 27 09:13:58 2018 -0700
@@ -146,7 +146,11 @@
   s>     Content-Length: *\r\n (glob)
   s>     \r\n
   s>     \xa3Dapis\xa0GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
-  cbor> {b'apibase': b'api/', b'apis': {}, b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash'}
+  cbor> {
+    b'apibase': b'api/',
+    b'apis': {},
+    b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash'
+  }
 
 Restart server to enable HTTPv2
 
@@ -179,7 +183,11 @@
   s>     Content-Length: *\r\n (glob)
   s>     \r\n
   s>     \xa3Dapis\xa0GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
-  cbor> {b'apibase': b'api/', b'apis': {}, b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash'}
+  cbor> {
+    b'apibase': b'api/',
+    b'apis': {},
+    b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash'
+  }
 
 Request for HTTPv2 service returns information about it
 
@@ -205,7 +213,85 @@
   s>     Content-Length: *\r\n (glob)
   s>     \r\n
   s>     \xa3Dapis\xa1Pexp-http-v2-0001\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-0005GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
-  cbor> {b'apibase': b'api/', b'apis': {b'exp-http-v2-0001': {b'commands': {b'branchmap': {b'args': {}, b'permissions': [b'pull']}, b'capabilities': {b'args': {}, b'permissions': [b'pull']}, b'heads': {b'args': {b'publiconly': False}, b'permissions': [b'pull']}, b'known': {b'args': {b'nodes': [b'deadbeef']}, b'permissions': [b'pull']}, b'listkeys': {b'args': {b'namespace': b'ns'}, b'permissions': [b'pull']}, b'lookup': {b'args': {b'key': b'foo'}, b'permissions': [b'pull']}, b'pushkey': {b'args': {b'key': b'key', b'namespace': b'ns', b'new': b'new', b'old': b'old'}, b'permissions': [b'push']}}, b'compression': [{b'name': b'zlib'}], b'framingmediatypes': [b'application/mercurial-exp-framing-0005'], b'rawrepoformats': [b'generaldelta', b'revlogv1']}}, b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash'}
+  cbor> {
+    b'apibase': b'api/',
+    b'apis': {
+      b'exp-http-v2-0001': {
+        b'commands': {
+          b'branchmap': {
+            b'args': {},
+            b'permissions': [
+              b'pull'
+            ]
+          },
+          b'capabilities': {
+            b'args': {},
+            b'permissions': [
+              b'pull'
+            ]
+          },
+          b'heads': {
+            b'args': {
+              b'publiconly': False
+            },
+            b'permissions': [
+              b'pull'
+            ]
+          },
+          b'known': {
+            b'args': {
+              b'nodes': [
+                b'deadbeef'
+              ]
+            },
+            b'permissions': [
+              b'pull'
+            ]
+          },
+          b'listkeys': {
+            b'args': {
+              b'namespace': b'ns'
+            },
+            b'permissions': [
+              b'pull'
+            ]
+          },
+          b'lookup': {
+            b'args': {
+              b'key': b'foo'
+            },
+            b'permissions': [
+              b'pull'
+            ]
+          },
+          b'pushkey': {
+            b'args': {
+              b'key': b'key',
+              b'namespace': b'ns',
+              b'new': b'new',
+              b'old': b'old'
+            },
+            b'permissions': [
+              b'push'
+            ]
+          }
+        },
+        b'compression': [
+          {
+            b'name': b'zlib'
+          }
+        ],
+        b'framingmediatypes': [
+          b'application/mercurial-exp-framing-0005'
+        ],
+        b'rawrepoformats': [
+          b'generaldelta',
+          b'revlogv1'
+        ]
+      }
+    },
+    b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash'
+  }
 
 capabilities command returns expected info
 
@@ -254,6 +340,83 @@
   received frame(size=463; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
   s>     0\r\n
   s>     \r\n
-  response: [{b'status': b'ok'}, {b'commands': {b'branchmap': {b'args': {}, b'permissions': [b'pull']}, b'capabilities': {b'args': {}, b'permissions': [b'pull']}, b'heads': {b'args': {b'publiconly': False}, b'permissions': [b'pull']}, b'known': {b'args': {b'nodes': [b'deadbeef']}, b'permissions': [b'pull']}, b'listkeys': {b'args': {b'namespace': b'ns'}, b'permissions': [b'pull']}, b'lookup': {b'args': {b'key': b'foo'}, b'permissions': [b'pull']}, b'pushkey': {b'args': {b'key': b'key', b'namespace': b'ns', b'new': b'new', b'old': b'old'}, b'permissions': [b'push']}}, b'compression': [{b'name': b'zlib'}], b'framingmediatypes': [b'application/mercurial-exp-framing-0005'], b'rawrepoformats': [b'generaldelta', b'revlogv1']}]
+  response: [
+    {
+      b'status': b'ok'
+    },
+    {
+      b'commands': {
+        b'branchmap': {
+          b'args': {},
+          b'permissions': [
+            b'pull'
+          ]
+        },
+        b'capabilities': {
+          b'args': {},
+          b'permissions': [
+            b'pull'
+          ]
+        },
+        b'heads': {
+          b'args': {
+            b'publiconly': False
+          },
+          b'permissions': [
+            b'pull'
+          ]
+        },
+        b'known': {
+          b'args': {
+            b'nodes': [
+              b'deadbeef'
+            ]
+          },
+          b'permissions': [
+            b'pull'
+          ]
+        },
+        b'listkeys': {
+          b'args': {
+            b'namespace': b'ns'
+          },
+          b'permissions': [
+            b'pull'
+          ]
+        },
+        b'lookup': {
+          b'args': {
+            b'key': b'foo'
+          },
+          b'permissions': [
+            b'pull'
+          ]
+        },
+        b'pushkey': {
+          b'args': {
+            b'key': b'key',
+            b'namespace': b'ns',
+            b'new': b'new',
+            b'old': b'old'
+          },
+          b'permissions': [
+            b'push'
+          ]
+        }
+      },
+      b'compression': [
+        {
+          b'name': b'zlib'
+        }
+      ],
+      b'framingmediatypes': [
+        b'application/mercurial-exp-framing-0005'
+      ],
+      b'rawrepoformats': [
+        b'generaldelta',
+        b'revlogv1'
+      ]
+    }
+  ]
 
   $ cat error.log
--- a/tests/test-wireproto-command-heads.t	Wed Aug 22 08:20:51 2018 +0800
+++ b/tests/test-wireproto-command-heads.t	Mon Aug 27 09:13:58 2018 -0700
@@ -58,7 +58,11 @@
   received frame(size=75; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
   s>     0\r\n
   s>     \r\n
-  response: [b'\x1dok\x91\xd4J\xab\xa6\xd5\xe5\x80\xbc0\xa9\x94\x850\xdb\xe0\x0b', b'\xaeI.6\xb0\xc83\x9f\xfa\xf3(\xd0\x0b\x85\xb4R]\xe1\x16^', b')Dm-\xc5A\x9c_\x97Dz\x8b\xc0b\xe4\xcc2\x8b\xf2A']
+  response: [
+    b'\x1dok\x91\xd4J\xab\xa6\xd5\xe5\x80\xbc0\xa9\x94\x850\xdb\xe0\x0b',
+    b'\xaeI.6\xb0\xc83\x9f\xfa\xf3(\xd0\x0b\x85\xb4R]\xe1\x16^',
+    b')Dm-\xc5A\x9c_\x97Dz\x8b\xc0b\xe4\xcc2\x8b\xf2A'
+  ]
 
 Requesting just the public heads works
 
@@ -91,6 +95,8 @@
   received frame(size=33; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
   s>     0\r\n
   s>     \r\n
-  response: [b'x\xd2\xdc\xa46\xb2\xf5\xb1\x88\xac&~)\xb8\x1e\x07&m8\xfc']
+  response: [
+    b'x\xd2\xdc\xa46\xb2\xf5\xb1\x88\xac&~)\xb8\x1e\x07&m8\xfc'
+  ]
 
   $ cat error.log
--- a/tests/test-wireproto-command-known.t	Wed Aug 22 08:20:51 2018 +0800
+++ b/tests/test-wireproto-command-known.t	Mon Aug 27 09:13:58 2018 -0700
@@ -83,7 +83,9 @@
   received frame(size=13; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
   s>     0\r\n
   s>     \r\n
-  response: [True]
+  response: [
+    True
+  ]
 
 Multiple nodes works
 
@@ -116,6 +118,10 @@
   received frame(size=15; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
   s>     0\r\n
   s>     \r\n
-  response: [True, False, True]
+  response: [
+    True,
+    False,
+    True
+  ]
 
   $ cat error.log
--- a/tests/test-wireproto-command-listkeys.t	Wed Aug 22 08:20:51 2018 +0800
+++ b/tests/test-wireproto-command-listkeys.t	Mon Aug 27 09:13:58 2018 -0700
@@ -54,7 +54,11 @@
   received frame(size=43; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
   s>     0\r\n
   s>     \r\n
-  response: {b'bookmarks': b'', b'namespaces': b'', b'phases': b''}
+  response: {
+    b'bookmarks': b'',
+    b'namespaces': b'',
+    b'phases': b''
+  }
 
 Request for phases works
 
@@ -87,7 +91,10 @@
   received frame(size=72; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
   s>     0\r\n
   s>     \r\n
-  response: {b'be0ef73c17ade3fc89dc41701eb9fc3a91b58282': b'1', b'publishing': b'True'}
+  response: {
+    b'be0ef73c17ade3fc89dc41701eb9fc3a91b58282': b'1',
+    b'publishing': b'True'
+  }
 
 Request for bookmarks works
 
@@ -120,6 +127,8 @@
   received frame(size=56; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
   s>     0\r\n
   s>     \r\n
-  response: {b'@': b'26805aba1e600a82e93661149f2313866a221a7b'}
+  response: {
+    b'@': b'26805aba1e600a82e93661149f2313866a221a7b'
+  }
 
   $ cat error.log
--- a/tests/test-wireproto-command-pushkey.t	Wed Aug 22 08:20:51 2018 +0800
+++ b/tests/test-wireproto-command-pushkey.t	Mon Aug 27 09:13:58 2018 -0700
@@ -84,6 +84,8 @@
   received frame(size=56; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
   s>     0\r\n
   s>     \r\n
-  response: {b'@': b'426bada5c67598ca65036d57d9e4b64b0c1ce7a0'}
+  response: {
+    b'@': b'426bada5c67598ca65036d57d9e4b64b0c1ce7a0'
+  }
 
   $ cat error.log