Patchwork [1,of,7] profiling: move 'fp' closing logic into its own function

login
register
mail settings
Submitter Pierre-Yves David
Date June 12, 2017, 4:17 p.m.
Message ID <ffbf377689412a98a606.1497284265@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21344/
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 1497280415 -7200
#      Mon Jun 12 17:13:35 2017 +0200
# Node ID ffbf377689412a98a606c7576c3a40977f6d34f2
# Parent  6f775d10e83b928c99d5d6a7caa559c79fd925e1
# 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 ffbf37768941
profiling: move 'fp' closing logic into its own function

We are about to make the logic more robust and reuse it in more place, we start
by isolating what we have.

Patch

diff --git a/mercurial/profiling.py b/mercurial/profiling.py
--- a/mercurial/profiling.py
+++ b/mercurial/profiling.py
@@ -218,4 +218,7 @@  class profile(object):
                 # so we need to escape any % signs.
                 val = val.replace('%', '%%')
                 self._ui.log('profile', val)
-            self._fp.close()
+            self._closefp()
+
+    def _closefp(self):
+        self._fp.close()