Patchwork [7,of,7] remotedebug: allow to request --traceback from the remote server

login
register
mail settings
Submitter Paul Morelle
Date June 20, 2018, 4:36 p.m.
Message ID <aa4b26d92e20d9532392.1529512588@belenos.localdomain>
Download mbox | patch
Permalink /patch/32350/
State Accepted
Headers show

Comments

Paul Morelle - June 20, 2018, 4:36 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1529494410 -7200
#      Wed Jun 20 13:33:30 2018 +0200
# Node ID aa4b26d92e20d95323929a306b3d63c44ceb3d69
# Parent  f663c257cf788d3f3d00398dbf64d9b572536377
# EXP-Topic remote-debug
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r aa4b26d92e20
remotedebug: allow to request --traceback from the remote server

Getting a full traceback is useful in the case of a crash.
This changeset makes it possible for an authorized user to receive it
from the client side.

Patch

diff -r f663c257cf78 -r aa4b26d92e20 mercurial/configitems.py
--- a/mercurial/configitems.py	Wed Jun 20 13:00:41 2018 +0200
+++ b/mercurial/configitems.py	Wed Jun 20 13:33:30 2018 +0200
@@ -345,6 +345,9 @@ 
 coreconfigitem('devel', 'remote.profile',
     default=False,
 )
+coreconfigitem('devel', 'remote.traceback',
+    default=False,
+)
 coreconfigitem('devel', 'servercafile',
     default='',
 )
diff -r f663c257cf78 -r aa4b26d92e20 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Wed Jun 20 13:00:41 2018 +0200
+++ b/mercurial/dispatch.py	Wed Jun 20 13:33:30 2018 +0200
@@ -297,7 +297,7 @@ 
             if not ('*' in rd_access or user in rd_access) and other_args:
                 unsafe()
             while other_args:
-                if other_args[0] in ('--debug', '--profile'):
+                if other_args[0] in ('--debug', '--profile', '--traceback'):
                     other_args.pop(0)
                 else:
                     unsafe()
diff -r f663c257cf78 -r aa4b26d92e20 mercurial/sshpeer.py
--- a/mercurial/sshpeer.py	Wed Jun 20 13:00:41 2018 +0200
+++ b/mercurial/sshpeer.py	Wed Jun 20 13:33:30 2018 +0200
@@ -154,6 +154,8 @@ 
         serverspawn += ' --debug'
     if ui.configbool('devel', 'remote.profile'):
         serverspawn += ' --profile'
+    if ui.configbool('devel', 'remote.traceback'):
+        serverspawn += ' --traceback'
     cmd = '%s %s %s' % (sshcmd, args, procutil.shellquote(serverspawn))
     ui.debug('running %s\n' % cmd)
     cmd = procutil.quotecommand(cmd)
diff -r f663c257cf78 -r aa4b26d92e20 tests/test-remote-debugging.t
--- a/tests/test-remote-debugging.t	Wed Jun 20 13:00:41 2018 +0200
+++ b/tests/test-remote-debugging.t	Wed Jun 20 13:33:30 2018 +0200
@@ -106,11 +106,71 @@ 
   remote: Sample count: * (glob)
   remote: Total time: * seconds (* wall) (glob)
 
+Test basic remote traceback output
+----------------------------------
+
+  $ echo 'raise Exception("This extensions is broken")' > $TESTTMP/badext.py
+  $ cat << EOF >> $TESTTMP/remote/.hg/hgrc
+  > [extensions]
+  > bad=$TESTTMP/badext.py
+  > EOF
+
+  $ hg pull --config "devel.remote.traceback=yes"
+  pulling from ssh://user@dummy/remote/
+  remote: *** failed to import extension bad from $TESTTMP/badext.py: This extensions is broken
+  remote: Traceback (most recent call last):
+  remote:   File "*/mercurial/extensions.py", line *, in loadall (glob)
+  remote:     load(ui, name, path)
+  remote:   File "*/mercurial/extensions.py", line *, in load (glob)
+  remote:     mod = _importext(name, path, bind(_reportimporterror, ui))
+  remote:   File "*/mercurial/extensions.py", line *, in _importext (glob)
+  remote:     mod = loadpath(path, 'hgext.%s' % name)
+  remote:   File "*/mercurial/extensions.py", line *, in loadpath (glob)
+  remote:     return imp.load_source(module_name, path)
+  remote:   File "$TESTTMP/badext.py", line 1, in <module> (glob)
+  remote:     raise Exception("This extensions is broken")
+  remote: Exception: This extensions is broken
+  searching for changes
+  no changes found
+  remote: Traceback (most recent call last):
+  remote:   File "*/mercurial/scmutil.py", line *, in callcatch (glob)
+  remote:     return func()
+  remote:   File "*/mercurial/dispatch.py", line *, in _runcatchfunc (glob)
+  remote:     return _dispatch(req)
+  remote:   File "*/mercurial/dispatch.py", line *, in _dispatch (glob)
+  remote:     cmdpats, cmdoptions)
+  remote:   File "*/mercurial/dispatch.py", line *, in runcommand (glob)
+  remote:     ret = _runcommand(ui, options, cmd, d)
+  remote:   File "*/mercurial/dispatch.py", line *, in _runcommand (glob)
+  remote:     return cmdfunc()
+  remote:   File "*/mercurial/dispatch.py", line *, in <lambda> (glob)
+  remote:     d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
+  remote:   File "*/mercurial/util.py", line 1556, in check (glob)
+  remote:     return func(*args, **kwargs)
+  remote:   File "*/mercurial/commands.py", line *, in serve (glob)
+  remote:     s.serve_forever()
+  remote:   File "*/mercurial/wireprotoserver.py", line *, in serve_forever (glob)
+  remote:     sys.exit(0)
+  remote: SystemExit: 0
+
 Test basic combined remote debug option
 ---------------------------------------
 
-  $ hg pull --config "devel.remote.debug=yes" --config "devel.remote.profile=yes" | grep -v --extended-regexp 'line +[0-9]+:'
+  $ hg pull --config "devel.remote.debug=yes" --config "devel.remote.profile=yes" --config "devel.remote.traceback=yes" | grep -v --extended-regexp 'line +[0-9]+:'
   pulling from ssh://user@dummy/remote/
+  remote: *** failed to import extension bad from $TESTTMP/badext.py: This extensions is broken
+  remote: Traceback (most recent call last):
+  remote:   File "*/mercurial/extensions.py", line *, in loadall (glob)
+  remote:     load(ui, name, path)
+  remote:   File "*/mercurial/extensions.py", line *, in load (glob)
+  remote:     mod = _importext(name, path, bind(_reportimporterror, ui))
+  remote:   File "*/mercurial/extensions.py", line *, in _importext (glob)
+  remote:     mod = loadpath(path, 'hgext.%s' % name)
+  remote:   File "*/mercurial/extensions.py", line *, in loadpath (glob)
+  remote:     return imp.load_source(module_name, path)
+  remote:   File "$TESTTMP/badext.py", line 1, in <module> (glob)
+  remote:     raise Exception("This extensions is broken")
+  remote: Exception: This extensions is broken
   searching for changes
   no changes found
   remote: listing keys for "bookmarks"
@@ -120,3 +180,23 @@ 
   remote: ---
   remote: Sample count: * (glob)
   remote: Total time: * seconds (* wall) (glob)
+  remote: Traceback (most recent call last):
+  remote:   File "*/mercurial/scmutil.py", line *, in callcatch (glob)
+  remote:     return func()
+  remote:   File "*/mercurial/dispatch.py", line *, in _runcatchfunc (glob)
+  remote:     return _dispatch(req)
+  remote:   File "*/mercurial/dispatch.py", line *, in _dispatch (glob)
+  remote:     cmdpats, cmdoptions)
+  remote:   File "*/mercurial/dispatch.py", line *, in runcommand (glob)
+  remote:     ret = _runcommand(ui, options, cmd, d)
+  remote:   File "*/mercurial/dispatch.py", line *, in _runcommand (glob)
+  remote:     return cmdfunc()
+  remote:   File "*/mercurial/dispatch.py", line *, in <lambda> (glob)
+  remote:     d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
+  remote:   File "*/mercurial/util.py", line 1556, in check (glob)
+  remote:     return func(*args, **kwargs)
+  remote:   File "*/mercurial/commands.py", line *, in serve (glob)
+  remote:     s.serve_forever()
+  remote:   File "*/mercurial/wireprotoserver.py", line *, in serve_forever (glob)
+  remote:     sys.exit(0)
+  remote: SystemExit: 0