[PATCH 3 of 4] debugshell: add function to embed ipython

Augie Fackler raf at durin42.com
Tue Sep 24 12:58:09 CDT 2013


On Mon, Sep 23, 2013 at 03:26:22PM -0500, Kevin Bullock wrote:
> On 21 Sep 2013, at 11:27 PM, Sean Farley wrote:
> 
>> kbullock+mercurial at ringworld.org writes:
>> 
>>> On 20 Sep 2013, at 3:28 PM, Sean Farley wrote:
>>> 
>>>> # HG changeset patch
>>>> # User Sean Farley <sean.michael.farley at gmail.com>
>>>> # Date 1373821356 18000
>>>> #      Sun Jul 14 12:02:36 2013 -0500
>>>> # Node ID 4c1a591f6674905b8b2ecd09ae2a85de0ba7e84c
>>>> # Parent  aa9ff65add03b8e535c115c67d5c12c64231b019
>>>> debugshell: add function to embed ipython
>>>> 
>>>> diff --git a/contrib/debugshell.py b/contrib/debugshell.py
>>>> --- a/contrib/debugshell.py
>>>> +++ b/contrib/debugshell.py
>>>> @@ -12,10 +12,18 @@
>>>>       'mf': repo.manifest,
>>>>   }
>>>> 
>>>>   code.interact(msg, local=objects)
>>>> 
>>>> +def ipdb(ui, repo, msg, **opts):
>>>> +    import IPython
>>>> +
>>>> +    cl = repo.changelog
>>>> +    mf = repo.manifest
>>> 
>>> Do ipdb users not also get 'mercurial' and 'repo', or do these come in automagically because of the way we're sucking in IPython?
>> 
>> It's because IPython doesn't have code.interact and instead needs to be
>> called with IPython.embed() which doesn't take a 'local=objects'
>> parameter.
> 
> Right, but does the IPython REPL then just get access to whatever's in scope when you call .embed()?
> 

from IPython.frontend.terminal import embed
ipshell = embed.InteractiveShellEmbed(banner1='Welcome to the REPL!',
                                     user_ns=globals())
ipshell()

is how I do this in a tool at work. I have no idea offhand if that's a
current version of ipython though.

> 
> pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
> Kevin R. Bullock
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list