contrib/debugshell.py
author Yuya Nishihara <yuya@tcha.org>
Sat, 25 Dec 2010 21:59:00 +0900
branchstable
changeset 13225 e3bf16703e26
parent 11633 6b7b99867ada
child 19771 3bc675361206
permissions -rw-r--r--
util: fix ellipsis() not to break multi-byte sequence (issue2564) It tries to convert localstr to unicode before truncating. Because we cannot assume that the given text is encoded in local encoding, it falls back to raw string in case of unicode error.

# 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)

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