subrepo: ensure "close()" execution at the end of "_readstorehashcache()"
Before this patch, "close()" for the file object opened in
"_readstorehashcache()" 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
"_readstorehashcache()" 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
@@ -576,8 +576,10 @@
if not os.path.exists(cachefile):
return ''
fd = open(cachefile, 'r')
- pullstate = fd.readlines()
- fd.close()
+ try:
+ pullstate = fd.readlines()
+ finally:
+ fd.close()
return pullstate
def _cachestorehash(self, remotepath):