Mercurial > public > mercurial-scm > hg-stable
diff mercurial/profiling.py @ 32808:eede022fc142
profile: drop maybeprofile
It seems sufficiently simple to use "profile(enabled=X)" to not justify having
a dedicated context manager just to read the config.
(I do not have a too strong opinion about this).
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 09 Jun 2017 12:29:29 +0100 |
parents | 0ead06d54ffe |
children | c0b2c8f25ad9 |
line wrap: on
line diff
--- a/mercurial/profiling.py Fri Jun 09 12:36:07 2017 +0100 +++ b/mercurial/profiling.py Fri Jun 09 12:29:29 2017 +0100 @@ -219,17 +219,3 @@ val = val.replace('%', '%%') self._ui.log('profile', val) self._fp.close() - -@contextlib.contextmanager -def maybeprofile(ui): - """Profile if enabled, else do nothing. - - This context manager can be used to optionally profile if profiling - is enabled. Otherwise, it does nothing. - - The purpose of this context manager is to make calling code simpler: - just use a single code path for calling into code you may want to profile - and this function determines whether to start profiling. - """ - with profile(ui, enabled=ui.configbool('profiling', 'enabled')) as p: - yield p