Mercurial > public > mercurial-scm > hg
comparison mercurial/subrepo.py @ 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 |
comparison
equal
deleted
inserted
replaced
21887:9aaffb22d7d7 | 21888:dfb8f757750c |
---|---|
574 '''read the store hash cache for a given remote repository''' | 574 '''read the store hash cache for a given remote repository''' |
575 cachefile = self._getstorehashcachepath(remotepath) | 575 cachefile = self._getstorehashcachepath(remotepath) |
576 if not os.path.exists(cachefile): | 576 if not os.path.exists(cachefile): |
577 return '' | 577 return '' |
578 fd = open(cachefile, 'r') | 578 fd = open(cachefile, 'r') |
579 pullstate = fd.readlines() | 579 try: |
580 fd.close() | 580 pullstate = fd.readlines() |
581 finally: | |
582 fd.close() | |
581 return pullstate | 583 return pullstate |
582 | 584 |
583 def _cachestorehash(self, remotepath): | 585 def _cachestorehash(self, remotepath): |
584 '''cache the current store hash | 586 '''cache the current store hash |
585 | 587 |