comparison 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
comparison
equal deleted inserted replaced
46463:cfb6c10c08c2 46464:f25c770c217b
3715 ui.writenoi18n(b'path %s\n' % k) 3715 ui.writenoi18n(b'path %s\n' % k)
3716 ui.writenoi18n(b' source %s\n' % v[0]) 3716 ui.writenoi18n(b' source %s\n' % v[0])
3717 ui.writenoi18n(b' revision %s\n' % v[1]) 3717 ui.writenoi18n(b' revision %s\n' % v[1])
3718 3718
3719 3719
3720 @command(b'debugshell', optionalrepo=True)
3721 def debugshell(ui, repo):
3722 """run an interactive Python interpreter
3723
3724 The local namespace is provided with a reference to the ui and
3725 the repo instance (if available).
3726 """
3727 import code
3728
3729 imported_objects = {
3730 'ui': ui,
3731 'repo': repo,
3732 }
3733
3734 code.interact(local=imported_objects)
3735
3736
3720 @command( 3737 @command(
3721 b'debugsuccessorssets', 3738 b'debugsuccessorssets',
3722 [(b'', b'closest', False, _(b'return closest successors sets only'))], 3739 [(b'', b'closest', False, _(b'return closest successors sets only'))],
3723 _(b'[REV]'), 3740 _(b'[REV]'),
3724 ) 3741 )