with: use context manager for wlock in revert
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27803 a8e8950ebd4d
parent 27802 ed44a66fd7ae
child 27804 aa41199a74e2
with: use context manager for wlock in revert
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Fri Jan 15 13:14:45 2016 -0800
+++ b/mercurial/cmdutil.py	Fri Jan 15 13:14:46 2016 -0800
@@ -2868,8 +2868,7 @@
     #   <asb path in repo> -> (<path from CWD>, <exactly specified by matcher?>)
     names = {}
 
-    wlock = repo.wlock()
-    try:
+    with repo.wlock():
         ## filling of the `names` mapping
         # walk dirstate to fill `names`
 
@@ -3122,8 +3121,6 @@
                 except KeyError:
                     raise error.Abort("subrepository '%s' does not exist in %s!"
                                       % (sub, short(ctx.node())))
-    finally:
-        wlock.release()
 
 def _revertprefetch(repo, ctx, *files):
     """Let extension changing the storage layer prefetch content"""