changeset 39137:dd1614906a20

branchmap: close cache file properly Follows up 2a4bfbb52111.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 17 Aug 2018 10:25:39 +0900
parents b892df0766e1
children 8547c8590ac1
files mercurial/branchmap.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/branchmap.py	Fri Aug 17 10:24:29 2018 +0900
+++ b/mercurial/branchmap.py	Fri Aug 17 10:25:39 2018 +0900
@@ -38,6 +38,7 @@
     return filename
 
 def read(repo):
+    f = None
     try:
         f = repo.cachevfs(_filename(repo))
         cachekey = next(f).rstrip('\n').split(" ", 2)
@@ -79,6 +80,11 @@
             msg += ': %s\n'
             repo.ui.debug(msg % pycompat.bytestr(inst))
         partial = None
+
+    finally:
+        if f:
+            f.close()
+
     return partial
 
 ### Nearest subset relation