with: use context manager for wlock in workingctx.add
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27809 37a75d69eb43
parent 27808 0c48c566bab0
child 27810 8c81975fe145
with: use context manager for wlock in workingctx.add
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
@@ -1415,9 +1415,8 @@
 
     def add(self, list, prefix=""):
         join = lambda f: os.path.join(prefix, f)
-        wlock = self._repo.wlock()
-        ui, ds = self._repo.ui, self._repo.dirstate
-        try:
+        with self._repo.wlock():
+            ui, ds = self._repo.ui, self._repo.dirstate
             rejected = []
             lstat = self._repo.wvfs.lstat
             for f in list:
@@ -1445,8 +1444,6 @@
                 else:
                     ds.add(f)
             return rejected
-        finally:
-            wlock.release()
 
     def forget(self, files, prefix=""):
         join = lambda f: os.path.join(prefix, f)