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.
--- 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()