comparison mercurial/subrepo.py @ 21889:ee7e8dcffc92

subrepo: ensure "close()" execution at the end of "_cachestorehash()" Before this patch, "close()" for the file object opened in "_cachestorehash()" 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 "_cachestorehash()" by moving it into "finally" clause.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 20 Jun 2014 00:21:19 +0900
parents dfb8f757750c
children db8a27d92818
comparison
equal deleted inserted replaced
21888:dfb8f757750c 21889:ee7e8dcffc92
594 storehash = list(self._calcstorehash(remotepath)) 594 storehash = list(self._calcstorehash(remotepath))
595 cachedir = os.path.dirname(cachefile) 595 cachedir = os.path.dirname(cachefile)
596 if not os.path.exists(cachedir): 596 if not os.path.exists(cachedir):
597 util.makedirs(cachedir, notindexed=True) 597 util.makedirs(cachedir, notindexed=True)
598 fd = open(cachefile, 'w') 598 fd = open(cachefile, 'w')
599 fd.writelines(storehash) 599 try:
600 fd.close() 600 fd.writelines(storehash)
601 finally:
602 fd.close()
601 finally: 603 finally:
602 lock.release() 604 lock.release()
603 605
604 @annotatesubrepoerror 606 @annotatesubrepoerror
605 def _initrepo(self, parentrepo, source, create): 607 def _initrepo(self, parentrepo, source, create):