changeset 21885:fe9db58b0b2d

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.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 20 Jun 2014 00:21:19 +0900
parents a858d3de0d32
children b9e8fdc35daf
files mercurial/subrepo.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Mon Jul 07 18:45:46 2014 +0900
+++ b/mercurial/subrepo.py	Fri Jun 20 00:21:19 2014 +0900
@@ -525,8 +525,14 @@
         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 @@
                 clean = False
             except StopIteration:
                 pass
-        lock.release()
         return clean
 
     def _calcstorehash(self, remotepath):