[PATCH 4 of 6] profile: make the contextmanager object available to the callers
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri Jun 9 08:33:00 EDT 2017
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1497004965 -3600
# Fri Jun 09 11:42:45 2017 +0100
# Node ID 1642a7b657e057cd0404cd4f33528e3cc272dfee
# Parent 83187f3e565e3f5cfa68056554cd0c6dff97daa4
# EXP-Topic profile
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
# hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 1642a7b657e0
profile: make the contextmanager object available to the callers
This will allow calling methods on the object in the code using the context
manager.
diff --git a/mercurial/profiling.py b/mercurial/profiling.py
--- a/mercurial/profiling.py
+++ b/mercurial/profiling.py
@@ -160,6 +160,7 @@ class profile(object):
self._entered = True
if self._enabled:
self.start()
+ return self
def start(self):
"""Start profiling.
@@ -230,5 +231,5 @@ def maybeprofile(ui):
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')):
- yield
+ with profile(ui, enabled=ui.configbool('profiling', 'enabled')) as p:
+ yield p
More information about the Mercurial-devel
mailing list