equal
deleted
inserted
replaced
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 mercurial |
5 import mercurial |
5 import code |
6 import code |
6 |
7 |
7 def pdb(ui, repo, msg, **opts): |
8 def pdb(ui, repo, msg, **opts): |
8 objects = { |
9 objects = { |
25 def debugshell(ui, repo, **opts): |
26 def debugshell(ui, repo, **opts): |
26 bannermsg = "loaded repo : %s\n" \ |
27 bannermsg = "loaded repo : %s\n" \ |
27 "using source: %s" % (repo.root, |
28 "using source: %s" % (repo.root, |
28 mercurial.__path__[0]) |
29 mercurial.__path__[0]) |
29 |
30 |
30 pdb(ui, repo, bannermsg, **opts) |
31 pdbmap = { |
|
32 'pdb' : 'code', |
|
33 'ipdb' : 'IPython' |
|
34 } |
|
35 |
|
36 debugger = ui.config("ui", "debugger") |
|
37 if not debugger: |
|
38 debugger = 'pdb' |
|
39 |
|
40 # if IPython doesn't exist, fallback to code.interact |
|
41 try: |
|
42 __import__(pdbmap[debugger]) |
|
43 except ImportError: |
|
44 ui.warn("%s debugger specified but %s module was not found\n" |
|
45 % (debugger, pdbmap[debugger])) |
|
46 debugger = 'pdb' |
|
47 |
|
48 getattr(sys.modules[__name__], debugger)(ui, repo, bannermsg, **opts) |
31 |
49 |
32 cmdtable = { |
50 cmdtable = { |
33 "debugshell|dbsh": (debugshell, []) |
51 "debugshell|dbsh": (debugshell, []) |
34 } |
52 } |