with: use context manager for wlock in kw_amend
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27817 476e402e57c3
parent 27816 98391f38ceb8
child 27818 484895cc0f60
with: use context manager for wlock in kw_amend
hgext/keyword.py
--- a/hgext/keyword.py	Fri Jan 15 13:14:46 2016 -0800
+++ b/hgext/keyword.py	Fri Jan 15 13:14:46 2016 -0800
@@ -653,8 +653,7 @@
 
     def kw_amend(orig, ui, repo, commitfunc, old, extra, pats, opts):
         '''Wraps cmdutil.amend expanding keywords after amend.'''
-        wlock = repo.wlock()
-        try:
+        with repo.wlock():
             kwt.postcommit = True
             newid = orig(ui, repo, commitfunc, old, extra, pats, opts)
             if newid != old.node():
@@ -663,8 +662,6 @@
                 kwt.overwrite(ctx, ctx.files(), False, True)
                 kwt.restrict = False
             return newid
-        finally:
-            wlock.release()
 
     def kw_copy(orig, ui, repo, pats, opts, rename=False):
         '''Wraps cmdutil.copy so that copy/rename destinations do not