changeset 21889:ee7e8dcffc92

subrepo: ensure "close()" execution at the end of "_cachestorehash()" Before this patch, "close()" for the file object opened in "_cachestorehash()" may not be executed, if unexpected exception is raised, because it isn't executed in "finally" clause. This patch ensures "close()" execution at the end of "_cachestorehash()" by moving it into "finally" clause.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 20 Jun 2014 00:21:19 +0900
parents dfb8f757750c
children 0f916db7f297
files mercurial/subrepo.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Fri Jun 20 00:21:19 2014 +0900
+++ b/mercurial/subrepo.py	Fri Jun 20 00:21:19 2014 +0900
@@ -596,8 +596,10 @@
             if not os.path.exists(cachedir):
                 util.makedirs(cachedir, notindexed=True)
             fd = open(cachefile, 'w')
-            fd.writelines(storehash)
-            fd.close()
+            try:
+                fd.writelines(storehash)
+            finally:
+                fd.close()
         finally:
             lock.release()