with: use context manager for wlock in remove
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:45 -0800
changeset 27802 ed44a66fd7ae
parent 27801 7be6371c732e
child 27803 a8e8950ebd4d
with: use context manager for wlock in remove
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Fri Jan 15 13:14:45 2016 -0800
+++ b/mercurial/cmdutil.py	Fri Jan 15 13:14:45 2016 -0800
@@ -2421,16 +2421,13 @@
         if ui.verbose or not m.exact(f):
             ui.status(_('removing %s\n') % m.rel(f))
 
-    wlock = repo.wlock()
-    try:
+    with repo.wlock():
         if not after:
             for f in list:
                 if f in added:
                     continue # we never unlink added files on remove
                 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
         repo[None].forget(list)
-    finally:
-        wlock.release()
 
     return ret