profile: make the contextmanager object available to the callers
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 09 Jun 2017 11:42:45 +0100
changeset 32786 0ead06d54ffe
parent 32785 37ec8f24d912
child 32787 545f69cd6042
profile: make the contextmanager object available to the callers This will allow calling methods on the object in the code using the context manager.
mercurial/profiling.py
--- 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