branchmap: close cache file properly
authorYuya Nishihara <yuya@tcha.org>
Fri, 17 Aug 2018 10:25:39 +0900
changeset 39137 dd1614906a20
parent 39136 b892df0766e1
child 39138 8547c8590ac1
branchmap: close cache file properly Follows up 2a4bfbb52111.
mercurial/branchmap.py
--- 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