changeset 32935:070920db8b87

rebase: use context manager for locking in rebase()
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 19 Jun 2017 11:18:05 -0700
parents 88c1d13b637b
children 04c9dd951a41
files hgext/rebase.py
diffstat 1 files changed, 1 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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):