changeset 28470:16cfbbc69800

with: use context manager for wlock in _kwfwrite
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:46 -0800
parents a72735028336
children 98391f38ceb8
files hgext/keyword.py
diffstat 1 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -357,14 +357,11 @@
     if len(wctx.parents()) > 1:
         raise error.Abort(_('outstanding uncommitted merge'))
     kwt = kwtools['templater']
-    wlock = repo.wlock()
-    try:
+    with repo.wlock():
         status = _status(ui, repo, wctx, kwt, *pats, **opts)
         if status.modified or status.added or status.removed or status.deleted:
             raise error.Abort(_('outstanding uncommitted changes'))
         kwt.overwrite(wctx, status.clean, True, expand)
-    finally:
-        wlock.release()
 
 @command('kwdemo',
          [('d', 'default', None, _('show default keyword template maps')),