backout: use context manager for locks
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 14 Jun 2018 15:08:19 -0700
changeset 38321 9b1536b02221
parent 38320 eef4668be8a3
child 38322 e218ed5ba484
backout: use context manager for locks Differential Revision: https://phab.mercurial-scm.org/D3744
mercurial/commands.py
--- a/mercurial/commands.py	Thu Jun 14 15:28:32 2018 -0700
+++ b/mercurial/commands.py	Thu Jun 14 15:08:19 2018 -0700
@@ -560,13 +560,8 @@
     Returns 0 on success, 1 if nothing to backout or there are unresolved
     files.
     '''
-    wlock = lock = None
-    try:
-        wlock = repo.wlock()
-        lock = repo.lock()
+    with repo.wlock(), repo.lock():
         return _dobackout(ui, repo, node, rev, **opts)
-    finally:
-        release(lock, wlock)
 
 def _dobackout(ui, repo, node=None, rev=None, **opts):
     opts = pycompat.byteskwargs(opts)