Mercurial > public > mercurial-scm > hg
comparison mercurial/subrepo.py @ 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 | 652e07debf10 |
children | b9e8fdc35daf |
comparison
equal
deleted
inserted
replaced
21884:a858d3de0d32 | 21885:fe9db58b0b2d |
---|---|
523 self._repo.ui.setconfig(s, k, v, 'subrepo') | 523 self._repo.ui.setconfig(s, k, v, 'subrepo') |
524 self._repo.ui.setconfig('ui', '_usedassubrepo', 'True', 'subrepo') | 524 self._repo.ui.setconfig('ui', '_usedassubrepo', 'True', 'subrepo') |
525 self._initrepo(r, state[0], create) | 525 self._initrepo(r, state[0], create) |
526 | 526 |
527 def storeclean(self, path): | 527 def storeclean(self, path): |
528 lock = self._repo.lock() | |
529 try: | |
530 return self._storeclean(path) | |
531 finally: | |
532 lock.release() | |
533 | |
534 def _storeclean(self, path): | |
528 clean = True | 535 clean = True |
529 lock = self._repo.lock() | |
530 itercache = self._calcstorehash(path) | 536 itercache = self._calcstorehash(path) |
531 try: | 537 try: |
532 for filehash in self._readstorehashcache(path): | 538 for filehash in self._readstorehashcache(path): |
533 if filehash != itercache.next(): | 539 if filehash != itercache.next(): |
534 clean = False | 540 clean = False |
541 itercache.next() | 547 itercache.next() |
542 # the cached and current pull states have a different size | 548 # the cached and current pull states have a different size |
543 clean = False | 549 clean = False |
544 except StopIteration: | 550 except StopIteration: |
545 pass | 551 pass |
546 lock.release() | |
547 return clean | 552 return clean |
548 | 553 |
549 def _calcstorehash(self, remotepath): | 554 def _calcstorehash(self, remotepath): |
550 '''calculate a unique "store hash" | 555 '''calculate a unique "store hash" |
551 | 556 |