Mercurial > hg-stable
changeset 21888:dfb8f757750c
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.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 20 Jun 2014 00:21:19 +0900 |
parents | 9aaffb22d7d7 |
children | ee7e8dcffc92 |
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 @@ -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):