# HG changeset patch # User Martin von Zweigbergk # Date 1548225389 28800 # Node ID 07ccf1686024d69112ba053e60e7041999462746 # Parent 86bf0b106949cd98c15bc3015b34eaf219331f37 evolve: use context managers for locks and transaction diff -r 86bf0b106949 -r 07ccf1686024 hgext3rd/evolve/evolvecmd.py --- 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):