Mercurial > hg
comparison contrib/debugshell.py @ 19773:51799a965446
debugshell: check ui.debugger for which debugger to use
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Sun, 14 Jul 2013 12:16:40 -0500 |
parents | 6ccec36a1fd9 |
children | cccc44304b2c |
comparison
equal
deleted
inserted
replaced
19772:6ccec36a1fd9 | 19773:51799a965446 |
---|---|
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 } |