with: use context manager in subrepo _cachestorehash
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:50 -0800
changeset 27843 b2efdb66c406
parent 27842 002108b219e3
child 27844 469b86c49503
with: use context manager in subrepo _cachestorehash
mercurial/subrepo.py
--- a/mercurial/subrepo.py	Fri Jan 15 13:14:50 2016 -0800
+++ b/mercurial/subrepo.py	Fri Jan 15 13:14:50 2016 -0800
@@ -679,13 +679,10 @@
         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