[PATCH 1 of 8] formatter: close raw template file explicitly

Yuya Nishihara yuya at tcha.org
Wed Jun 14 09:40:32 EDT 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1494049222 -32400
#      Sat May 06 14:40:22 2017 +0900
# Node ID ce83b5ca8a012516342b2228da00da3c70f6218a
# Parent  e65ff29dbeb02ce08e4a64f381ccd37949354dcf
formatter: close raw template file explicitly

diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -399,7 +399,8 @@ def lookuptemplate(ui, topic, tmpl):
         # is it a mapfile for a style?
         if os.path.basename(tmpl).startswith("map-"):
             return None, os.path.realpath(tmpl)
-        tmpl = open(tmpl).read()
+        with open(tmpl) as f:
+            tmpl = f.read()
         return tmpl, None
 
     # constant string?


More information about the Mercurial-devel mailing list