amend: use context manager for locks (issue5887) stable
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 14 May 2018 15:25:38 -0700
branchstable
changeset 3744 4a70392f1723
parent 3743 648552969e88
child 3745 9fa3585b160f
amend: use context manager for locks (issue5887)
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."""