view contrib/debugshell.py @ 19771:3bc675361206

debugshell: abstract out pdb code.interact
author Sean Farley <sean.michael.farley@gmail.com>
date Sun, 14 Jul 2013 12:10:52 -0500
parents 6b7b99867ada
children 6ccec36a1fd9
line wrap: on
line source

# debugshell extension
"""a python shell with repo, changelog & manifest objects"""

import mercurial
import code

def pdb(ui, repo, msg, **opts):
    objects = {
        'mercurial': mercurial,
        'repo': repo,
        'cl': repo.changelog,
        'mf': repo.manifest,
    }

    code.interact(msg, local=objects)

def debugshell(ui, repo, **opts):
    bannermsg = "loaded repo : %s\n" \
                "using source: %s" % (repo.root,
                                      mercurial.__path__[0])

    pdb(ui, repo, bannermsg, **opts)

cmdtable = {
    "debugshell|dbsh": (debugshell, [])
}