comparison contrib/debugshell.py @ 21243:8b5c039f2b4f

debugshell: declare command using decorator
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 04 May 2014 21:19:31 -0700
parents cccc44304b2c
children e4b512bb6386
comparison
equal deleted inserted replaced
21242:4c94229c51fb 21243:8b5c039f2b4f
2 """a python shell with repo, changelog & manifest objects""" 2 """a python shell with repo, changelog & manifest objects"""
3 3
4 import sys 4 import sys
5 import mercurial 5 import mercurial
6 import code 6 import code
7 from mercurial import cmdutil
8
9 cmdtable = {}
10 command = cmdutil.command(cmdtable)
7 11
8 def pdb(ui, repo, msg, **opts): 12 def pdb(ui, repo, msg, **opts):
9 objects = { 13 objects = {
10 'mercurial': mercurial, 14 'mercurial': mercurial,
11 'repo': repo, 15 'repo': repo,
22 mf = repo.manifest 26 mf = repo.manifest
23 cl, mf # use variables to appease pyflakes 27 cl, mf # use variables to appease pyflakes
24 28
25 IPython.embed() 29 IPython.embed()
26 30
31 @command('debugshell|dbsh', [])
27 def debugshell(ui, repo, **opts): 32 def debugshell(ui, repo, **opts):
28 bannermsg = "loaded repo : %s\n" \ 33 bannermsg = "loaded repo : %s\n" \
29 "using source: %s" % (repo.root, 34 "using source: %s" % (repo.root,
30 mercurial.__path__[0]) 35 mercurial.__path__[0])
31 36
45 ui.warn("%s debugger specified but %s module was not found\n" 50 ui.warn("%s debugger specified but %s module was not found\n"
46 % (debugger, pdbmap[debugger])) 51 % (debugger, pdbmap[debugger]))
47 debugger = 'pdb' 52 debugger = 'pdb'
48 53
49 getattr(sys.modules[__name__], debugger)(ui, repo, bannermsg, **opts) 54 getattr(sys.modules[__name__], debugger)(ui, repo, bannermsg, **opts)
50
51 cmdtable = {
52 "debugshell|dbsh": (debugshell, [])
53 }