with: use context manager for wlock in workingctx.forget
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27810 8c81975fe145
parent 27809 37a75d69eb43
child 27811 09820fb88e14
with: use context manager for wlock in workingctx.forget
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
@@ -1447,8 +1447,7 @@
 
     def forget(self, files, prefix=""):
         join = lambda f: os.path.join(prefix, f)
-        wlock = self._repo.wlock()
-        try:
+        with self._repo.wlock():
             rejected = []
             for f in files:
                 if f not in self._repo.dirstate:
@@ -1459,8 +1458,6 @@
                 else:
                     self._repo.dirstate.drop(f)
             return rejected
-        finally:
-            wlock.release()
 
     def undelete(self, list):
         pctxs = self.parents()