subrepo: ensure "close()" execution at the end of "_calcfilehash()"
Before this patch, "close()" for the file object opened in
"_calcfilehash()" 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 "_calcfilehash()"
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
@@ -35,8 +35,10 @@
data = ''
if os.path.exists(filename):
fd = open(filename, 'rb')
- data = fd.read()
- fd.close()
+ try:
+ data = fd.read()
+ finally:
+ fd.close()
return util.sha1(data).hexdigest()
class SubrepoAbort(error.Abort):