profile: properly propagate exception from the sub-context manager
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 12 Jun 2017 17:24:10 +0200
changeset 32829 6675d23da748
parent 32828 062eb859d3ee
child 32830 ff02bb5979c1
profile: properly propagate exception from the sub-context manager Context manager has a mechanism to control extension propagation. It is not used by profiling right now, but making the code correct will help prevent bug in the future.
mercurial/profiling.py
--- a/mercurial/profiling.py	Mon Jun 12 17:25:37 2017 +0200
+++ b/mercurial/profiling.py	Mon Jun 12 17:24:10 2017 +0200
@@ -214,8 +214,10 @@
             raise
 
     def __exit__(self, exception_type, exception_value, traceback):
+        propagate = None
         if self._profiler is not None:
-            self._profiler.__exit__(exception_type, exception_value, traceback)
+            propagate = self._profiler.__exit__(exception_type, exception_value,
+                                                traceback)
             if self._output == 'blackbox':
                 val = 'Profile:\n%s' % self._fp.getvalue()
                 # ui.log treats the input as a format string,
@@ -223,6 +225,7 @@
                 val = val.replace('%', '%%')
                 self._ui.log('profile', val)
         self._closefp()
+        return propagate
 
     def _closefp(self):
         if self._fpdoclose and self._fp is not None: