with: use context manager for wlock in kw_copy
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27818 484895cc0f60
parent 27817 476e402e57c3
child 27819 e401dfd79ec7
with: use context manager for wlock in kw_copy
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
@@ -673,8 +673,7 @@
         For the latter we have to follow the symlink to find out whether its
         target is configured for expansion and we therefore must unexpand the
         keywords in the destination.'''
-        wlock = repo.wlock()
-        try:
+        with repo.wlock():
             orig(ui, repo, pats, opts, rename)
             if opts.get('dry_run'):
                 return
@@ -694,8 +693,6 @@
             candidates = [f for f in repo.dirstate.copies() if
                           'l' not in wctx.flags(f) and haskwsource(f)]
             kwt.overwrite(wctx, candidates, False, False)
-        finally:
-            wlock.release()
 
     def kw_dorecord(orig, ui, repo, commitfunc, *pats, **opts):
         '''Wraps record.dorecord expanding keywords after recording.'''