comparison mercurial/dispatch.py @ 20826:dd2e25e49862 stable

dispatch: only do __import__(debugger) when a debugger is requested When having ui.debugger=somedebugger in one's ~/.hgrc, this then somedebugger would be imported for every hg command. With this patch, this import only happens if the --debugger parameter is passed.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Fri, 07 Mar 2014 14:06:52 -0500
parents 69a0d22b9677
children 9a09a625bc93
comparison
equal deleted inserted replaced
20825:dda11e799529 20826:dd2e25e49862
106 for cfg in cfgs: 106 for cfg in cfgs:
107 req.repo.ui.setconfig(*cfg) 107 req.repo.ui.setconfig(*cfg)
108 108
109 # if we are in HGPLAIN mode, then disable custom debugging 109 # if we are in HGPLAIN mode, then disable custom debugging
110 debugger = ui.config("ui", "debugger") 110 debugger = ui.config("ui", "debugger")
111 debugmod = pdb
111 if not debugger or ui.plain(): 112 if not debugger or ui.plain():
112 debugger = 'pdb' 113 debugger = 'pdb'
113 114 elif '--debugger' in req.args:
114 try: 115 # This import can be slow for fancy debuggers, so only
115 debugmod = __import__(debugger) 116 # do it when absolutely necessary, i.e. when actual
116 except ImportError: 117 # debugging has been requested
117 debugmod = pdb 118 try:
119 debugmod = __import__(debugger)
120 except ImportError:
121 pass # Leave debugmod = pdb
118 122
119 debugtrace[debugger] = debugmod.set_trace 123 debugtrace[debugger] = debugmod.set_trace
120 debugmortem[debugger] = debugmod.post_mortem 124 debugmortem[debugger] = debugmod.post_mortem
121 125
122 # enter the debugger before command execution 126 # enter the debugger before command execution