# HG changeset patch # User FUJIWARA Katsunori # Date 2014-06-19 15:21:19 # Node ID fe9db58b0b2d1f0c36ba197c880150ad55ab9a19 # Parent a858d3de0d325c23bd3343b23905928648e2480e subrepo: ensure "lock.release()" execution at the end of "storeclean()" Before this patch, "lock.release()" for "self._repo" in "storeclean()" of "hgsubrepo" may not be executed, if unexpected exception is raised, because it isn't executed in "finally" clause. This patch ensures "lock.release()" execution at the end of "storeclean()" by moving it into "finally" clause. This patch chooses moving almost all lines in "storeclean()" into "_storeclean()" instead of indenting them for "try/finally" clauses, to keep diff simple for review-ability. diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -525,8 +525,14 @@ class hgsubrepo(abstractsubrepo): self._initrepo(r, state[0], create) def storeclean(self, path): + lock = self._repo.lock() + try: + return self._storeclean(path) + finally: + lock.release() + + def _storeclean(self, path): clean = True - lock = self._repo.lock() itercache = self._calcstorehash(path) try: for filehash in self._readstorehashcache(path): @@ -543,7 +549,6 @@ class hgsubrepo(abstractsubrepo): clean = False except StopIteration: pass - lock.release() return clean def _calcstorehash(self, remotepath):