Patchwork [1,of,2] profiling: add config option for enabling profiling

mail settings
Submitter Durham Goode
Date Sept. 7, 2015, 7:11 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/10414/
State Accepted
Delegated to: Augie Fackler
Headers show


Durham Goode - Sept. 7, 2015, 7:11 p.m.
# HG changeset patch
# User Durham Goode <>
# Date 1441650940 25200
#      Mon Sep 07 11:35:40 2015 -0700
# Node ID 2cd61d6e66c1034c97b7095fdf1d7908dd437b26
# Parent  9a9e7437460958362bf2637f145184a31332e78d
profiling: add config option for enabling profiling

Previously you could only enable profiling via the --profile option. This is
awkward when trying to debug a server side operation. Let's add a config option
to enable profiling.

In the future, this could be extended to allow profiling a certain percentage of
operations (and potentially reporting that information to an external service).


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -1001,13 +1001,17 @@  def statprofile(ui, func, fp):
 def _runcommand(ui, options, cmd, cmdfunc):
+    """Enables the profiler if applicable.
+    ``profiling.enabled`` - boolean config that enables or disables profiling
+    """
     def checkargs():
             return cmdfunc()
         except error.SignatureError:
             raise error.CommandError(cmd, _("invalid arguments"))
-    if options['profile']:
+    if options['profile'] or ui.configbool('profiling', 'enabled'):
         profiler = os.getenv('HGPROF')
         if profiler is None:
             profiler = ui.config('profiling', 'type', default='ls')