##// END OF EJS Templates
dispatch: add ability to specify a custom pdb module as a debugger...
Sean Farley -
r19640:472fa3b7 default
parent child Browse files
Show More
@@ -88,6 +88,13 b' def _runcatch(req):'
88
88
89 try:
89 try:
90 try:
90 try:
91 debugger = 'pdb'
92 debugtrace = {
93 'pdb' : pdb.set_trace
94 }
95 debugmortem = {
96 'pdb' : pdb.post_mortem
97 }
91
98
92 # read --config before doing anything else
99 # read --config before doing anything else
93 # (e.g. to change trust settings for reading .hg/hgrc)
100 # (e.g. to change trust settings for reading .hg/hgrc)
@@ -99,11 +106,29 b' def _runcatch(req):'
99 for cfg in cfgs:
106 for cfg in cfgs:
100 req.repo.ui.setconfig(*cfg)
107 req.repo.ui.setconfig(*cfg)
101
108
109 debugger = ui.config("ui", "debugger")
110 if not debugger:
111 debugger = 'pdb'
112
113 try:
114 debugmod = __import__(debugger)
115 except ImportError:
116 debugmod = pdb
117
118 debugtrace[debugger] = debugmod.set_trace
119 debugmortem[debugger] = debugmod.post_mortem
120
102 # enter the debugger before command execution
121 # enter the debugger before command execution
103 if '--debugger' in req.args:
122 if '--debugger' in req.args:
104 ui.warn(_("entering debugger - "
123 ui.warn(_("entering debugger - "
105 "type c to continue starting hg or h for help\n"))
124 "type c to continue starting hg or h for help\n"))
106 pdb.set_trace()
125
126 if (debugger != 'pdb' and
127 debugtrace[debugger] == debugtrace['pdb']):
128 ui.warn(_("%s debugger specified "
129 "but its module was not found\n") % debugger)
130
131 debugtrace[debugger]()
107 try:
132 try:
108 return _dispatch(req)
133 return _dispatch(req)
109 finally:
134 finally:
@@ -112,7 +137,7 b' def _runcatch(req):'
112 # enter the debugger when we hit an exception
137 # enter the debugger when we hit an exception
113 if '--debugger' in req.args:
138 if '--debugger' in req.args:
114 traceback.print_exc()
139 traceback.print_exc()
115 pdb.post_mortem(sys.exc_info()[2])
140 debugmortem[debugger](sys.exc_info()[2])
116 ui.traceback()
141 ui.traceback()
117 raise
142 raise
118
143
General Comments 0
You need to be logged in to leave comments. Login now