[PATCH 02 of 35] debugshell: declare command using decorator
Gregory Szorc
gregory.szorc at gmail.com
Mon May 5 05:51:07 UTC 2014
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1399263571 25200
# Sun May 04 21:19:31 2014 -0700
# Branch stable
# Node ID 24436ea8cf91fa45945a4d9b82d6841f1537afd3
# Parent a40ee6509498e00f2c4003cc5b1712738ee784fa
debugshell: declare command using decorator
diff --git a/contrib/debugshell.py b/contrib/debugshell.py
--- a/contrib/debugshell.py
+++ b/contrib/debugshell.py
@@ -1,14 +1,18 @@
# debugshell extension
"""a python shell with repo, changelog & manifest objects"""
import sys
import mercurial
import code
+from mercurial import cmdutil
+
+cmdtable = {}
+command = cmdutil.command(cmdtable)
def pdb(ui, repo, msg, **opts):
objects = {
'mercurial': mercurial,
'repo': repo,
'cl': repo.changelog,
'mf': repo.manifest,
}
@@ -19,16 +23,17 @@ def ipdb(ui, repo, msg, **opts):
import IPython
cl = repo.changelog
mf = repo.manifest
cl, mf # use variables to appease pyflakes
IPython.embed()
+ at command('debugshell|dbsh', [])
def debugshell(ui, repo, **opts):
bannermsg = "loaded repo : %s\n" \
"using source: %s" % (repo.root,
mercurial.__path__[0])
pdbmap = {
'pdb' : 'code',
'ipdb' : 'IPython'
@@ -42,12 +47,8 @@ def debugshell(ui, repo, **opts):
try:
__import__(pdbmap[debugger])
except ImportError:
ui.warn("%s debugger specified but %s module was not found\n"
% (debugger, pdbmap[debugger]))
debugger = 'pdb'
getattr(sys.modules[__name__], debugger)(ui, repo, bannermsg, **opts)
-
-cmdtable = {
- "debugshell|dbsh": (debugshell, [])
-}
More information about the Mercurial-devel
mailing list