changeset 32786:0ead06d54ffe

profile: make the contextmanager object available to the callers This will allow calling methods on the object in the code using the context manager.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 09 Jun 2017 11:42:45 +0100
parents 37ec8f24d912
children 545f69cd6042
files mercurial/profiling.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/profiling.py	Fri Jun 09 11:41:47 2017 +0100
+++ b/mercurial/profiling.py	Fri Jun 09 11:42:45 2017 +0100
@@ -160,6 +160,7 @@
         self._entered = True
         if self._enabled:
             self.start()
+        return self
 
     def start(self):
         """Start profiling.
@@ -230,5 +231,5 @@
     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