# HG changeset patch # User FUJIWARA Katsunori # Date 2014-06-19 15:21:19 # Node ID dfb8f757750cf75abb2bb1e27514f8c43b66d893 # Parent 9aaffb22d7d7e59d5079368536011a17bc2804de 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. diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -576,8 +576,10 @@ class hgsubrepo(abstractsubrepo): 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):