changeset 4375:07ccf1686024

evolve: use context managers for locks and transaction
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 22 Jan 2019 22:36:29 -0800
parents 86bf0b106949
children 0fbf895ce160
files hgext3rd/evolve/evolvecmd.py
diffstat 1 files changed, 1 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py	Tue Jan 22 10:17:58 2019 -0800
+++ b/hgext3rd/evolve/evolvecmd.py	Tue Jan 22 22:36:29 2019 -0800
@@ -19,7 +19,6 @@
     copies,
     error,
     hg,
-    lock as lockmod,
     merge,
     mergeutil,
     node as nodemod,
@@ -71,11 +70,7 @@
     else:
         displayer = compat.changesetdisplayer(ui, repo,
                                               {'template': shorttemplate})
-    wlock = lock = tr = None
-    try:
-        wlock = repo.wlock()
-        lock = repo.lock()
-        tr = repo.transaction("evolve")
+    with repo.wlock(), repo.lock(), repo.transaction("evolve"):
         if 'orphan' == category:
             result = _solveunstable(ui, repo, ctx, evolvestate, displayer,
                                     dryrun, confirm, progresscb,
@@ -89,10 +84,7 @@
                                      dryrun, confirm, progresscb)
         else:
             assert False, "unknown trouble category: %s" % (category)
-        tr.close()
         return result
-    finally:
-        lockmod.release(tr, lock, wlock)
 
 def _solveunstable(ui, repo, orig, evolvestate, displayer, dryrun=False,
                    confirm=False, progresscb=None, lastsolved=None):