[PATCH] contrib: add debugshell extension

Vishakh Harikumar vsh426 at gmail.com
Wed Jul 21 05:30:53 CDT 2010


On Wed, Jul 21, 2010 at 12:27 AM, Greg Ward <greg-hg at gerg.ca> wrote:
> On Tue, Jul 20, 2010 at 2:14 PM, Vishakh H <vsh426 at gmail.com> wrote:
>> # HG changeset patch
>> # User Vishakh H <vsh426 at gmail.com>
>> # Date 1279648789 -19800
>> # Node ID f167d6a2da5cf379bb9efb6830e49d5521539c9a
>> # Parent  47ca289a3a08516dd9b05d5ebe88aee07cf42d89
>> contrib: add debugshell extension
>
> I like it!
>
>> diff --git a/contrib/debugshell.py b/contrib/debugshell.py
>> new file mode 100644
>> --- /dev/null
>> +++ b/contrib/debugshell.py
>> @@ -0,0 +1,21 @@
>> +# debugshell extension
>> +"""a python shell with repo, changelog & manifest objects"""
>> +
>> +import mercurial
>> +import code
>> +
>> +def debugshell(ui, repo, **opts):
>> +    objects = {
>> +        'mercurial': mercurial,
>> +        'repo': repo,
>> +        'cl': repo.changelog,
>> +        'mf': repo.manifest,
>> +    }
>> +    bannermsg = "loaded repo : %s\n" \
>> +                "using source: %s" % (repo.root,
>> +                                      mercurial.__path__[0])
>> +    code.interact(bannermsg, local=objects)
>
> Would be even better if the bannermsg told me what identifiers are
> available.  E.g.
>
>  loaded repo: <repo.root>
>  using source: <mercurial.__path__>
>  available identifiers: mercurial, repo, cl, mf

i agree. after adding any more objects that might be useful.

> Also, you could add mercurial.__version__.version to the "using source" line.

i think thats only available from 'installed' hg. thats why i put the source
location bit, it was more relevant. but version would be useful when available.

> Hmmm: is there really any value in making the 'mercurial' package
> available?  Won't I still have to explicitly import other mercurial.*
> modules that I'm interested in?

mostly for one off stuff like mercurial.error.*Error and similar.

> Greg
>

cheers
-- 
vsh


More information about the Mercurial-devel mailing list