changeset 3744:4a70392f1723 stable

amend: use context manager for locks (issue5887)
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 14 May 2018 15:25:38 -0700
parents 648552969e88
children 9fa3585b160f
files hgext3rd/evolve/cmdrewrite.py
diffstat 1 files changed, 1 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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."""