with: use context manager for wlock in copy
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27812 28d0c0ef327b
parent 27811 09820fb88e14
child 27813 ff20fe74e5c6
with: use context manager for wlock in copy
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
@@ -1483,15 +1483,12 @@
             self._repo.ui.warn(_("copy failed: %s is not a file or a "
                                  "symbolic link\n") % dest)
         else:
-            wlock = self._repo.wlock()
-            try:
+            with self._repo.wlock():
                 if self._repo.dirstate[dest] in '?':
                     self._repo.dirstate.add(dest)
                 elif self._repo.dirstate[dest] in 'r':
                     self._repo.dirstate.normallookup(dest)
                 self._repo.dirstate.copy(source, dest)
-            finally:
-                wlock.release()
 
     def match(self, pats=[], include=None, exclude=None, default='glob',
               listsubrepos=False, badfn=None):