with: use context manager for wlock in kw_dorecord
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27819 e401dfd79ec7
parent 27818 484895cc0f60
child 27820 d2e9cc9edc08
with: use context manager for wlock in kw_dorecord
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
@@ -696,8 +696,7 @@
 
     def kw_dorecord(orig, ui, repo, commitfunc, *pats, **opts):
         '''Wraps record.dorecord expanding keywords after recording.'''
-        wlock = repo.wlock()
-        try:
+        with repo.wlock():
             # record returns 0 even when nothing has changed
             # therefore compare nodes before and after
             kwt.postcommit = True
@@ -712,8 +711,6 @@
                 kwt.overwrite(recctx, added, False, True, True)
                 kwt.restrict = True
             return ret
-        finally:
-            wlock.release()
 
     def kwfilectx_cmp(orig, self, fctx):
         # keyword affects data size, comparing wdir and filelog size does