# HG changeset patch # User Joerg Sonnenberger # Date 1611616776 -3600 # Node ID f25c770c217b2a1b35c66bc5e68aac968af2a275 # Parent cfb6c10c08c218e80ff43a3f935cd1e44cfb451a debugshell: add a simple command for starting an interactive shell This simplifies interactive exploration of the Mercurial APIs. The ui and repo instances are provided as local variables. Differential Revision: https://phab.mercurial-scm.org/D9866 diff -r cfb6c10c08c2 -r f25c770c217b mercurial/debugcommands.py --- a/mercurial/debugcommands.py Mon Jan 25 11:34:23 2021 +0100 +++ b/mercurial/debugcommands.py Tue Jan 26 00:19:36 2021 +0100 @@ -3717,6 +3717,23 @@ ui.writenoi18n(b' revision %s\n' % v[1]) +@command(b'debugshell', optionalrepo=True) +def debugshell(ui, repo): + """run an interactive Python interpreter + + The local namespace is provided with a reference to the ui and + the repo instance (if available). + """ + import code + + imported_objects = { + 'ui': ui, + 'repo': repo, + } + + code.interact(local=imported_objects) + + @command( b'debugsuccessorssets', [(b'', b'closest', False, _(b'return closest successors sets only'))], diff -r cfb6c10c08c2 -r f25c770c217b tests/test-completion.t --- a/tests/test-completion.t Mon Jan 25 11:34:23 2021 +0100 +++ b/tests/test-completion.t Tue Jan 26 00:19:36 2021 +0100 @@ -130,6 +130,7 @@ debugrevspec debugserve debugsetparents + debugshell debugsidedata debugssl debugstrip @@ -319,6 +320,7 @@ debugrevspec: optimize, show-revs, show-set, show-stage, no-optimized, verify-optimized debugserve: sshstdio, logiofd, logiofile debugsetparents: + debugshell: debugsidedata: changelog, manifest, dir debugssl: debugstrip: rev, force, no-backup, nobackup, , keep, bookmark, soft diff -r cfb6c10c08c2 -r f25c770c217b tests/test-help.t --- a/tests/test-help.t Mon Jan 25 11:34:23 2021 +0100 +++ b/tests/test-help.t Tue Jan 26 00:19:36 2021 +0100 @@ -1069,6 +1069,7 @@ debugsetparents manually set the parents of the current working directory (DANGEROUS) + debugshell run an interactive Python interpreter debugsidedata dump the side data for a cl/manifest/file revision debugssl test a secure connection to a server