sshpeer: add support for request tracing
authorBoris Feld <boris.feld@octobus.net>
Fri, 12 Jan 2018 11:52:57 +0000
changeset 35699 f7ef49e44d7c
parent 35698 0c4b23ccf1a5
child 35700 a71316bfac87
sshpeer: add support for request tracing The new 'devel.debug.peer-request' option now also display some information about request going through ssh peer.
mercurial/sshpeer.py
tests/test-ssh.t
--- a/mercurial/sshpeer.py	Fri Jan 12 10:41:03 2018 +0000
+++ b/mercurial/sshpeer.py	Fri Jan 12 11:52:57 2018 +0000
@@ -283,6 +283,17 @@
 
     def _callstream(self, cmd, **args):
         args = pycompat.byteskwargs(args)
+        if (self.ui.debugflag
+            and self.ui.configbool('devel', 'debug.peer-request')):
+            dbg = self.ui.debug
+            line = 'devel-peer-request: %s\n'
+            dbg(line % cmd)
+            for key, value in sorted(args.items()):
+                if not isinstance(value, dict):
+                    dbg(line % '  %s: %d bytes' % (key, len(value)))
+                else:
+                    for dk, dv in sorted(value.items()):
+                        dbg(line % '  %s-%s: %d' % (key, dk, len(dv)))
         self.ui.debug("sending %s command\n" % cmd)
         self._pipeo.write("%s\n" % cmd)
         _func, names = wireproto.commands[cmd]
--- a/tests/test-ssh.t	Fri Jan 12 10:41:03 2018 +0000
+++ b/tests/test-ssh.t	Fri Jan 12 11:52:57 2018 +0000
@@ -478,19 +478,32 @@
 
 debug output
 
-  $ hg pull --debug ssh://user@dummy/remote
+  $ hg pull --debug ssh://user@dummy/remote --config devel.debug.peer-request=yes
   pulling from ssh://user@dummy/remote
   running .* ".*/dummyssh" ['"]user@dummy['"] ('|")hg -R remote serve --stdio('|") (re)
+  devel-peer-request: hello
   sending hello command
+  devel-peer-request: between
+  devel-peer-request:   pairs: 81 bytes
   sending between command
   remote: 384
   remote: capabilities: lookup changegroupsubset branchmap pushkey known getbundle unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS$ unbundle=HG10GZ,HG10BZ,HG10UN
   remote: 1
   query 1; heads
+  devel-peer-request: batch
+  devel-peer-request:   cmds: 141 bytes
   sending batch command
   searching for changes
   all remote heads known locally
   no changes found
+  devel-peer-request: getbundle
+  devel-peer-request:   bookmarks: 1 bytes
+  devel-peer-request:   bundlecaps: 233 bytes
+  devel-peer-request:   cg: 1 bytes
+  devel-peer-request:   common: 122 bytes
+  devel-peer-request:   heads: 122 bytes
+  devel-peer-request:   listkeys: 9 bytes
+  devel-peer-request:   phases: 1 bytes
   sending getbundle command
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "bookmarks" supported