[PATCH 2 of 6] dispatch: set profiling.enabled when profiling is enabled
Gregory Szorc
gregory.szorc at gmail.com
Sun Aug 14 20:03:54 EDT 2016
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1471217758 25200
# Sun Aug 14 16:35:58 2016 -0700
# Node ID fd888ffaab6720688e4ad3f0358be09509effb6f
# Parent 40cbc513713837acd6a9f593bfd48759eabcce33
dispatch: set profiling.enabled when profiling is enabled
We do this for other global command arguments. We don't for --profile
for reasons that are unknown to me. Probably because nobody has needed
it.
An upcoming patch will introduce a new consumer of the profiling
code. It doesn't have access to command line arguments. So let's
set the config option during argument processing.
We also remove a check for "options['profile']" because it is now
redundant.
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -814,16 +814,20 @@ def _dispatch(req):
uis.add(req.repo.ui)
if options['verbose'] or options['debug'] or options['quiet']:
for opt in ('verbose', 'debug', 'quiet'):
val = str(bool(options[opt]))
for ui_ in uis:
ui_.setconfig('ui', opt, val, '--' + opt)
+ if options['profile']:
+ for ui_ in uis:
+ ui_.setconfig('profiling', 'enabled', 'true', '--profile')
+
if options['traceback']:
for ui_ in uis:
ui_.setconfig('ui', 'traceback', 'on', '--traceback')
if options['noninteractive']:
for ui_ in uis:
ui_.setconfig('ui', 'interactive', 'off', '-y')
@@ -899,17 +903,17 @@ def _runcommand(ui, options, cmd, cmdfun
``profiling.enabled`` - boolean config that enables or disables profiling
"""
def checkargs():
try:
return cmdfunc()
except error.SignatureError:
raise error.CommandError(cmd, _("invalid arguments"))
- if options['profile'] or ui.configbool('profiling', 'enabled'):
+ if ui.configbool('profiling', 'enabled'):
return profiling.profile(ui, checkargs)
else:
return checkargs()
def _exceptionwarning(ui):
"""Produce a warning message for the current active exception"""
# For compatibility checking, we discard the portion of the hg
More information about the Mercurial-devel
mailing list