rebase: use context manager for locking in rebase()
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 19 Jun 2017 11:18:05 -0700
changeset 32917 070920db8b87
parent 32916 88c1d13b637b
child 32918 04c9dd951a41
rebase: use context manager for locking in rebase()
hgext/rebase.py
--- a/hgext/rebase.py	Mon Jun 19 21:53:54 2017 -0400
+++ b/hgext/rebase.py	Mon Jun 19 11:18:05 2017 -0700
@@ -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):