Patchwork D5542: histedit: use context manager for locks

login
register
mail settings
Submitter phabricator
Date Jan. 10, 2019, 11:26 a.m.
Message ID <89298e39bea27450718d3ffc574e7814@localhost.localdomain>
Download mbox | patch
Permalink /patch/37615/
State Not Applicable
Headers show

Comments

phabricator - Jan. 10, 2019, 11:26 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9365b8cb90e0: histedit: use context manager for locks (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5542?vs=13119&id=13131

REVISION DETAIL
  https://phab.mercurial-scm.org/D5542

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS




To: martinvonz, durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -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'