changeset 27813:ff20fe74e5c6

with: use context manager for wlock in checklookup
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:46 -0800
parents 28d0c0ef327b
children a72735028336
files mercurial/context.py
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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