with: use context manager for wlock in checklookup
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27813 ff20fe74e5c6
parent 27812 28d0c0ef327b
child 27814 a72735028336
with: use context manager for wlock in checklookup
mercurial/context.py
--- a/mercurial/context.py	Fri Jan 15 13:14:46 2016 -0800
+++ b/mercurial/context.py	Fri Jan 15 13:14:46 2016 -0800
@@ -1548,17 +1548,15 @@
                 # so we don't wait on the lock
                 # wlock can invalidate the dirstate, so cache normal _after_
                 # taking the lock
-                wlock = self._repo.wlock(False)
-                normal = self._repo.dirstate.normal
-                try:
+                with self._repo.wlock(False):
+                    normal = self._repo.dirstate.normal
                     for f in fixup:
                         normal(f)
                     # write changes out explicitly, because nesting
                     # wlock at runtime may prevent 'wlock.release()'
-                    # below from doing so for subsequent changing files
+                    # after this block from doing so for subsequent
+                    # changing files
                     self._repo.dirstate.write(self._repo.currenttransaction())
-                finally:
-                    wlock.release()
             except error.LockError:
                 pass
         return modified, fixup