# HG changeset patch # User Bryan O'Sullivan # Date 2016-01-15 21:14:50 # Node ID b2efdb66c4069f7dffb612898b651fbe0ff0f494 # Parent 002108b219e36e1f85f77a94e0530fe8c1b80e92 with: use context manager in subrepo _cachestorehash diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -679,13 +679,10 @@ class hgsubrepo(abstractsubrepo): store may be "clean" versus a given remote repo, but not versus another ''' cachefile = _getstorehashcachename(remotepath) - lock = self._repo.lock() - try: + with self._repo.lock(): storehash = list(self._calcstorehash(remotepath)) vfs = self._cachestorehashvfs vfs.writelines(cachefile, storehash, mode='w', notindexed=True) - finally: - lock.release() def _getctx(self): '''fetch the context for this subrepo revision, possibly a workingctx