changeset 41166:9365b8cb90e0

histedit: use context manager for locks Differential Revision: https://phab.mercurial-scm.org/D5542
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 09 Jan 2019 15:34:24 -0800
parents a3a24ad10efb
children 870a89c6909d
files hgext/histedit.py
diffstat 1 files changed, 3 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Wed Jan 09 15:32:26 2019 -0800
+++ b/hgext/histedit.py	Wed Jan 09 15:34:24 2019 -0800
@@ -207,7 +207,6 @@
     exchange,
     extensions,
     hg,
-    lock,
     logcmdutil,
     merge as mergemod,
     mergeutil,
@@ -225,7 +224,6 @@
 )
 
 pickle = util.pickle
-release = lock.release
 cmdtable = {}
 command = registrar.command(cmdtable)
 
@@ -1601,12 +1599,10 @@
 
 def _texthistedit(ui, repo, *freeargs, **opts):
     state = histeditstate(repo)
-    try:
-        state.wlock = repo.wlock()
-        state.lock = repo.lock()
+    with repo.wlock() as wlock, repo.lock() as lock:
+        state.wlock = wlock
+        state.lock = lock
         _histedit(ui, repo, state, *freeargs, **opts)
-    finally:
-        release(state.lock, state.wlock)
 
 goalcontinue = 'continue'
 goalabort = 'abort'