Mercurial > public > mercurial-scm > hg-stable
diff mercurial/debugcommands.py @ 46464:f25c770c217b
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
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Tue, 26 Jan 2021 00:19:36 +0100 |
parents | bc884e31b8c8 |
children | 3e3b81b6e7da |
line wrap: on
line diff
--- 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'))],