dispatch: only do __import__(debugger) when a debugger is requested stable
authorJordi Gutiérrez Hermoso <jordigh@octave.org>
Fri, 07 Mar 2014 14:06:52 -0500
branchstable
changeset 20826 dd2e25e49862
parent 20825 dda11e799529
child 20829 9a09a625bc93
child 20857 6eb55310fcbc
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.
mercurial/dispatch.py
--- a/mercurial/dispatch.py	Tue Mar 25 19:34:17 2014 +0900
+++ b/mercurial/dispatch.py	Fri Mar 07 14:06:52 2014 -0500
@@ -108,13 +108,17 @@
 
             # if we are in HGPLAIN mode, then disable custom debugging
             debugger = ui.config("ui", "debugger")
+            debugmod = pdb
             if not debugger or ui.plain():
                 debugger = 'pdb'
-
-            try:
-                debugmod = __import__(debugger)
-            except ImportError:
-                debugmod = pdb
+            elif '--debugger' in req.args:
+                # This import can be slow for fancy debuggers, so only
+                # do it when absolutely necessary, i.e. when actual
+                # debugging has been requested
+                try:
+                    debugmod = __import__(debugger)
+                except ImportError:
+                    pass # Leave debugmod = pdb
 
             debugtrace[debugger] = debugmod.set_trace
             debugmortem[debugger] = debugmod.post_mortem