changeset 40018:426cb2859013

debugcommands: print all CBOR objects application/mercurial-cbor may contain multiple objects. Let's print all of them. Differential Revision: https://phab.mercurial-scm.org/D4769
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 26 Sep 2018 14:54:15 -0700
parents 1f12a3ad93f2
children f80db6adabbe
files mercurial/debugcommands.py tests/test-wireproto-command-capabilities.t
diffstat 2 files changed, 204 insertions(+), 198 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Wed Oct 03 22:48:19 2018 +0900
+++ b/mercurial/debugcommands.py	Wed Sep 26 14:54:15 2018 -0700
@@ -3334,7 +3334,7 @@
             ct = res.headers.get(r'Content-Type')
             if ct == r'application/mercurial-cbor':
                 ui.write(_('cbor> %s\n') %
-                         stringutil.pprint(cborutil.decodeall(body)[0],
+                         stringutil.pprint(cborutil.decodeall(body),
                                            bprefix=True,
                                            indent=2))
 
--- a/tests/test-wireproto-command-capabilities.t	Wed Oct 03 22:48:19 2018 +0900
+++ b/tests/test-wireproto-command-capabilities.t	Wed Sep 26 14:54:15 2018 -0700
@@ -146,11 +146,13 @@
   s>     Content-Length: *\r\n (glob)
   s>     \r\n
   s>     \xa3GapibaseDapi/Dapis\xa0Nv1capabilitiesY\x01\xd3batch branchmap $USUAL_BUNDLE2_CAPS$ 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$ 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$ 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
 
@@ -183,11 +185,13 @@
   s>     Content-Length: *\r\n (glob)
   s>     \r\n
   s>     \xa3GapibaseDapi/Dapis\xa0Nv1capabilitiesY\x01\xd3batch branchmap $USUAL_BUNDLE2_CAPS$ 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$ 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$ 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
 
@@ -213,204 +217,206 @@
   s>     Content-Length: *\r\n (glob)
   s>     \r\n
   s>     \xa3GapibaseDapi/Dapis\xa1Pexp-http-v2-0002\xa5Hcommands\xaaIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullMchangesetdata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x84IbookmarksGparentsEphaseHrevisionInoderange\xa3Gdefault\xf6Hrequired\xf4DtypeDlistEnodes\xa3Gdefault\xf6Hrequired\xf4DtypeDlistJnodesdepth\xa3Gdefault\xf6Hrequired\xf4DtypeCintKpermissions\x81DpullHfiledata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x82GparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolEnodes\xa2Hrequired\xf5DtypeDlistDpath\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullEheads\xa2Dargs\xa1Jpubliconly\xa3Gdefault\xf4Hrequired\xf4DtypeDboolKpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\xa3Gdefault\x80Hrequired\xf4DtypeDlistKpermissions\x81DpullHlistkeys\xa2Dargs\xa1Inamespace\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullFlookup\xa2Dargs\xa1Ckey\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullLmanifestdata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x82GparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolEnodes\xa2Hrequired\xf5DtypeDlistDtree\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullGpushkey\xa2Dargs\xa4Ckey\xa2Hrequired\xf5DtypeEbytesInamespace\xa2Hrequired\xf5DtypeEbytesCnew\xa2Hrequired\xf5DtypeEbytesCold\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpushKcompression\x81\xa1DnameDzlibQframingmediatypes\x81X&application/mercurial-exp-framing-0005Rpathfilterprefixes\xd9\x01\x02\x82Epath:Lrootfilesin:Nrawrepoformats\x82LgeneraldeltaHrevlogv1Nv1capabilitiesY\x01\xd3batch branchmap $USUAL_BUNDLE2_CAPS$ 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-0002': {
-        b'commands': {
-          b'branchmap': {
-            b'args': {},
-            b'permissions': [
-              b'pull'
-            ]
-          },
-          b'capabilities': {
-            b'args': {},
-            b'permissions': [
-              b'pull'
-            ]
-          },
-          b'changesetdata': {
-            b'args': {
-              b'fields': {
-                b'default': set([]),
-                b'required': False,
-                b'type': b'set',
-                b'validvalues': set([
-                  b'bookmarks',
-                  b'parents',
-                  b'phase',
-                  b'revision'
-                ])
-              },
-              b'noderange': {
-                b'default': None,
-                b'required': False,
-                b'type': b'list'
-              },
-              b'nodes': {
-                b'default': None,
-                b'required': False,
-                b'type': b'list'
-              },
-              b'nodesdepth': {
-                b'default': None,
-                b'required': False,
-                b'type': b'int'
-              }
+  cbor> [
+    {
+      b'apibase': b'api/',
+      b'apis': {
+        b'exp-http-v2-0002': {
+          b'commands': {
+            b'branchmap': {
+              b'args': {},
+              b'permissions': [
+                b'pull'
+              ]
+            },
+            b'capabilities': {
+              b'args': {},
+              b'permissions': [
+                b'pull'
+              ]
             },
-            b'permissions': [
-              b'pull'
-            ]
-          },
-          b'filedata': {
-            b'args': {
-              b'fields': {
-                b'default': set([]),
-                b'required': False,
-                b'type': b'set',
-                b'validvalues': set([
-                  b'parents',
-                  b'revision'
-                ])
-              },
-              b'haveparents': {
-                b'default': False,
-                b'required': False,
-                b'type': b'bool'
-              },
-              b'nodes': {
-                b'required': True,
-                b'type': b'list'
+            b'changesetdata': {
+              b'args': {
+                b'fields': {
+                  b'default': set([]),
+                  b'required': False,
+                  b'type': b'set',
+                  b'validvalues': set([
+                    b'bookmarks',
+                    b'parents',
+                    b'phase',
+                    b'revision'
+                  ])
+                },
+                b'noderange': {
+                  b'default': None,
+                  b'required': False,
+                  b'type': b'list'
+                },
+                b'nodes': {
+                  b'default': None,
+                  b'required': False,
+                  b'type': b'list'
+                },
+                b'nodesdepth': {
+                  b'default': None,
+                  b'required': False,
+                  b'type': b'int'
+                }
               },
-              b'path': {
-                b'required': True,
-                b'type': b'bytes'
-              }
+              b'permissions': [
+                b'pull'
+              ]
             },
-            b'permissions': [
-              b'pull'
-            ]
-          },
-          b'heads': {
-            b'args': {
-              b'publiconly': {
-                b'default': False,
-                b'required': False,
-                b'type': b'bool'
-              }
+            b'filedata': {
+              b'args': {
+                b'fields': {
+                  b'default': set([]),
+                  b'required': False,
+                  b'type': b'set',
+                  b'validvalues': set([
+                    b'parents',
+                    b'revision'
+                  ])
+                },
+                b'haveparents': {
+                  b'default': False,
+                  b'required': False,
+                  b'type': b'bool'
+                },
+                b'nodes': {
+                  b'required': True,
+                  b'type': b'list'
+                },
+                b'path': {
+                  b'required': True,
+                  b'type': b'bytes'
+                }
+              },
+              b'permissions': [
+                b'pull'
+              ]
             },
-            b'permissions': [
-              b'pull'
-            ]
-          },
-          b'known': {
-            b'args': {
-              b'nodes': {
-                b'default': [],
-                b'required': False,
-                b'type': b'list'
-              }
+            b'heads': {
+              b'args': {
+                b'publiconly': {
+                  b'default': False,
+                  b'required': False,
+                  b'type': b'bool'
+                }
+              },
+              b'permissions': [
+                b'pull'
+              ]
             },
-            b'permissions': [
-              b'pull'
-            ]
-          },
-          b'listkeys': {
-            b'args': {
-              b'namespace': {
-                b'required': True,
-                b'type': b'bytes'
-              }
-            },
-            b'permissions': [
-              b'pull'
-            ]
-          },
-          b'lookup': {
-            b'args': {
-              b'key': {
-                b'required': True,
-                b'type': b'bytes'
-              }
+            b'known': {
+              b'args': {
+                b'nodes': {
+                  b'default': [],
+                  b'required': False,
+                  b'type': b'list'
+                }
+              },
+              b'permissions': [
+                b'pull'
+              ]
             },
-            b'permissions': [
-              b'pull'
-            ]
-          },
-          b'manifestdata': {
-            b'args': {
-              b'fields': {
-                b'default': set([]),
-                b'required': False,
-                b'type': b'set',
-                b'validvalues': set([
-                  b'parents',
-                  b'revision'
-                ])
+            b'listkeys': {
+              b'args': {
+                b'namespace': {
+                  b'required': True,
+                  b'type': b'bytes'
+                }
               },
-              b'haveparents': {
-                b'default': False,
-                b'required': False,
-                b'type': b'bool'
-              },
-              b'nodes': {
-                b'required': True,
-                b'type': b'list'
+              b'permissions': [
+                b'pull'
+              ]
+            },
+            b'lookup': {
+              b'args': {
+                b'key': {
+                  b'required': True,
+                  b'type': b'bytes'
+                }
               },
-              b'tree': {
-                b'required': True,
-                b'type': b'bytes'
-              }
+              b'permissions': [
+                b'pull'
+              ]
             },
-            b'permissions': [
-              b'pull'
-            ]
-          },
-          b'pushkey': {
-            b'args': {
-              b'key': {
-                b'required': True,
-                b'type': b'bytes'
-              },
-              b'namespace': {
-                b'required': True,
-                b'type': b'bytes'
-              },
-              b'new': {
-                b'required': True,
-                b'type': b'bytes'
+            b'manifestdata': {
+              b'args': {
+                b'fields': {
+                  b'default': set([]),
+                  b'required': False,
+                  b'type': b'set',
+                  b'validvalues': set([
+                    b'parents',
+                    b'revision'
+                  ])
+                },
+                b'haveparents': {
+                  b'default': False,
+                  b'required': False,
+                  b'type': b'bool'
+                },
+                b'nodes': {
+                  b'required': True,
+                  b'type': b'list'
+                },
+                b'tree': {
+                  b'required': True,
+                  b'type': b'bytes'
+                }
               },
-              b'old': {
-                b'required': True,
-                b'type': b'bytes'
-              }
+              b'permissions': [
+                b'pull'
+              ]
             },
-            b'permissions': [
-              b'push'
-            ]
-          }
-        },
-        b'compression': [
-          {
-            b'name': b'zlib'
-          }
-        ],
-        b'framingmediatypes': [
-          b'application/mercurial-exp-framing-0005'
-        ],
-        b'pathfilterprefixes': set([
-          b'path:',
-          b'rootfilesin:'
-        ]),
-        b'rawrepoformats': [
-          b'generaldelta',
-          b'revlogv1'
-        ]
-      }
-    },
-    b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS$ 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'
-  }
+            b'pushkey': {
+              b'args': {
+                b'key': {
+                  b'required': True,
+                  b'type': b'bytes'
+                },
+                b'namespace': {
+                  b'required': True,
+                  b'type': b'bytes'
+                },
+                b'new': {
+                  b'required': True,
+                  b'type': b'bytes'
+                },
+                b'old': {
+                  b'required': True,
+                  b'type': b'bytes'
+                }
+              },
+              b'permissions': [
+                b'push'
+              ]
+            }
+          },
+          b'compression': [
+            {
+              b'name': b'zlib'
+            }
+          ],
+          b'framingmediatypes': [
+            b'application/mercurial-exp-framing-0005'
+          ],
+          b'pathfilterprefixes': set([
+            b'path:',
+            b'rootfilesin:'
+          ]),
+          b'rawrepoformats': [
+            b'generaldelta',
+            b'revlogv1'
+          ]
+        }
+      },
+      b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS$ 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