[PATCH] contrib: add debugshell extension

Greg Ward greg-hg at gerg.ca
Tue Jul 20 13:57:22 CDT 2010


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

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

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?

Greg


More information about the Mercurial-devel mailing list