changeset 27812:28d0c0ef327b

with: use context manager for wlock in copy
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:46 -0800
parents 09820fb88e14
children ff20fe74e5c6
files mercurial/context.py
diffstat 1 files changed, 1 insertions(+), 4 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
@@ -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):