mercurial/dispatch.py
changeset 29795 e3501546f7e4
parent 29794 5d44197c208b
child 29833 61a4cdc98307
--- a/mercurial/dispatch.py	Sun Aug 14 18:25:22 2016 -0700
+++ b/mercurial/dispatch.py	Sun Aug 14 17:51:12 2016 -0700
@@ -898,21 +898,12 @@
             repo.close()
 
 def _runcommand(ui, options, cmd, cmdfunc):
-    """Enables the profiler if applicable.
-
-    ``profiling.enabled`` - boolean config that enables or disables profiling
-    """
-    def checkargs():
+    """Run a command function, possibly with profiling enabled."""
+    with profiling.maybeprofile(ui):
         try:
             return cmdfunc()
         except error.SignatureError:
-            raise error.CommandError(cmd, _("invalid arguments"))
-
-    if ui.configbool('profiling', 'enabled'):
-        with profiling.profile(ui):
-            return checkargs()
-    else:
-        return checkargs()
+            raise error.CommandError(cmd, _('invalid arguments'))
 
 def _exceptionwarning(ui):
     """Produce a warning message for the current active exception"""