##// END OF EJS Templates
debugshell: appease pyflakes
Matt Mackall -
r19794:cccc4430 default
parent child Browse files
Show More
@@ -1,52 +1,53 b''
1 # debugshell extension
1 # debugshell extension
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
7
8 def pdb(ui, repo, msg, **opts):
8 def pdb(ui, repo, msg, **opts):
9 objects = {
9 objects = {
10 'mercurial': mercurial,
10 'mercurial': mercurial,
11 'repo': repo,
11 'repo': repo,
12 'cl': repo.changelog,
12 'cl': repo.changelog,
13 'mf': repo.manifest,
13 'mf': repo.manifest,
14 }
14 }
15
15
16 code.interact(msg, local=objects)
16 code.interact(msg, local=objects)
17
17
18 def ipdb(ui, repo, msg, **opts):
18 def ipdb(ui, repo, msg, **opts):
19 import IPython
19 import IPython
20
20
21 cl = repo.changelog
21 cl = repo.changelog
22 mf = repo.manifest
22 mf = repo.manifest
23 cl, mf # use variables to appease pyflakes
23
24
24 IPython.embed()
25 IPython.embed()
25
26
26 def debugshell(ui, repo, **opts):
27 def debugshell(ui, repo, **opts):
27 bannermsg = "loaded repo : %s\n" \
28 bannermsg = "loaded repo : %s\n" \
28 "using source: %s" % (repo.root,
29 "using source: %s" % (repo.root,
29 mercurial.__path__[0])
30 mercurial.__path__[0])
30
31
31 pdbmap = {
32 pdbmap = {
32 'pdb' : 'code',
33 'pdb' : 'code',
33 'ipdb' : 'IPython'
34 'ipdb' : 'IPython'
34 }
35 }
35
36
36 debugger = ui.config("ui", "debugger")
37 debugger = ui.config("ui", "debugger")
37 if not debugger:
38 if not debugger:
38 debugger = 'pdb'
39 debugger = 'pdb'
39
40
40 # if IPython doesn't exist, fallback to code.interact
41 # if IPython doesn't exist, fallback to code.interact
41 try:
42 try:
42 __import__(pdbmap[debugger])
43 __import__(pdbmap[debugger])
43 except ImportError:
44 except ImportError:
44 ui.warn("%s debugger specified but %s module was not found\n"
45 ui.warn("%s debugger specified but %s module was not found\n"
45 % (debugger, pdbmap[debugger]))
46 % (debugger, pdbmap[debugger]))
46 debugger = 'pdb'
47 debugger = 'pdb'
47
48
48 getattr(sys.modules[__name__], debugger)(ui, repo, bannermsg, **opts)
49 getattr(sys.modules[__name__], debugger)(ui, repo, bannermsg, **opts)
49
50
50 cmdtable = {
51 cmdtable = {
51 "debugshell|dbsh": (debugshell, [])
52 "debugshell|dbsh": (debugshell, [])
52 }
53 }
General Comments 0
You need to be logged in to leave comments. Login now