# HG changeset patch # User Martin von Zweigbergk # Date 1526336738 25200 # Node ID 4a70392f1723c9e31d8b7fa68b2fc942d024901d # Parent 648552969e88374dba13871d3a772af5947d3764 amend: use context manager for locks (issue5887) diff -r 648552969e88 -r 4a70392f1723 hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py Thu May 10 21:37:28 2018 -0700 +++ b/hgext3rd/evolve/cmdrewrite.py Mon May 14 15:25:38 2018 -0700 @@ -140,15 +140,11 @@ opts['amend'] = True _resolveoptions(ui, opts) _alias, commitcmd = cmdutil.findcmd('commit', commands.table) - try: - wlock = repo.wlock() - lock = repo.lock() + with repo.wlock(), repo.lock(): if not (edit or opts['message'] or log): opts['message'] = repo['.'].description() rewriteutil.precheck(repo, [repo['.'].rev()], action='amend') return commitcmd[0](ui, repo, *pats, **opts) - finally: - lockmod.release(lock, wlock) def amendpatch(ui, repo, *pats, **opts): """logic for --patch flag of `hg amend` command."""