changeset 27809:37a75d69eb43

with: use context manager for wlock in workingctx.add
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:46 -0800
parents 0c48c566bab0
children 8c81975fe145
files mercurial/context.py
diffstat 1 files changed, 2 insertions(+), 5 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
@@ -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)