Patchwork [4,of,7] profile: indent part of '__enter__'

login
register
mail settings
Submitter Pierre-Yves David
Date June 12, 2017, 4:17 p.m.
Message ID <0f3d18d09dd1c744a115.1497284268@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21342/
State Accepted
Headers show

Comments

Pierre-Yves David - June 12, 2017, 4:17 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1497280848 -7200
#      Mon Jun 12 17:20:48 2017 +0200
# Node ID 0f3d18d09dd1c744a1158b1d2b6b881f87fac391
# Parent  9a398916971d4e35674b525440c86f19e3261902
# 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 0f3d18d09dd1
profile: indent part of '__enter__'

We are about to introduce a try except. We start with adding the indent to make
the next patch clearer.

Patch

diff --git a/mercurial/profiling.py b/mercurial/profiling.py
--- a/mercurial/profiling.py
+++ b/mercurial/profiling.py
@@ -188,26 +188,27 @@  class profile(object):
 
         self._output = self._ui.config('profiling', 'output')
 
-        if self._output == 'blackbox':
-            self._fp = util.stringio()
-        elif self._output:
-            path = self._ui.expandpath(self._output)
-            self._fp = open(path, 'wb')
-        else:
-            self._fpdoclose = False
-            self._fp = self._ui.ferr
+        if True:
+            if self._output == 'blackbox':
+                self._fp = util.stringio()
+            elif self._output:
+                path = self._ui.expandpath(self._output)
+                self._fp = open(path, 'wb')
+            else:
+                self._fpdoclose = False
+                self._fp = self._ui.ferr
 
-        if proffn is not None:
-            pass
-        elif profiler == 'ls':
-            proffn = lsprofile
-        elif profiler == 'flame':
-            proffn = flameprofile
-        else:
-            proffn = statprofile
+            if proffn is not None:
+                pass
+            elif profiler == 'ls':
+                proffn = lsprofile
+            elif profiler == 'flame':
+                proffn = flameprofile
+            else:
+                proffn = statprofile
 
-        self._profiler = proffn(self._ui, self._fp)
-        self._profiler.__enter__()
+            self._profiler = proffn(self._ui, self._fp)
+            self._profiler.__enter__()
 
     def __exit__(self, exception_type, exception_value, traceback):
         if self._profiler is None: