[PATCH 1 of 9] rebase: use context manager for locking in rebase()

Martin von Zweigbergk martinvonz at google.com
Mon Jun 19 16:47:53 EDT 2017


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1497896285 25200
#      Mon Jun 19 11:18:05 2017 -0700
# Node ID 13b76c56433d09394036c0885bc5593287d0d305
# Parent  661025fd3e1cd5d5e2dee12b7f64312d6cd48a0b
rebase: use context manager for locking in rebase()

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -683,11 +683,7 @@
     """
     rbsrt = rebaseruntime(repo, ui, opts)
 
-    lock = wlock = None
-    try:
-        wlock = repo.wlock()
-        lock = repo.lock()
-
+    with repo.wlock(), repo.lock():
         # Validate input and define rebasing points
         destf = opts.get('dest', None)
         srcf = opts.get('source', None)
@@ -753,8 +749,6 @@
                 release(dsguard)
                 raise
         rbsrt._finishrebase()
-    finally:
-        release(lock, wlock)
 
 def _definesets(ui, repo, destf=None, srcf=None, basef=None, revf=None,
                 destspace=None):


More information about the Mercurial-devel mailing list