with: use context manager for wlock in keyword demo
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27816 98391f38ceb8
parent 27815 16cfbbc69800
child 27817 476e402e57c3
with: use context manager for wlock in keyword demo
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
@@ -444,11 +444,8 @@
     repo[None].add([fn])
     ui.note(_('\nkeywords written to %s:\n') % fn)
     ui.note(keywords)
-    wlock = repo.wlock()
-    try:
+    with repo.wlock():
         repo.dirstate.setbranch('demobranch')
-    finally:
-        wlock.release()
     for name, cmd in ui.configitems('hooks'):
         if name.split('.', 1)[0].find('commit') > -1:
             repo.ui.setconfig('hooks', name, '', 'keyword')