# HG changeset patch # User Yuya Nishihara # Date 2017-05-06 05:40:22 # Node ID 526f9f12f707d38889817f9ebc6f42f35e1e62ff # Parent 3abba5bc34546951b11b1bd3f5e5c77b90d950d1 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?