rebase: use context manager for locking in pullrebase()
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 19 Jun 2017 11:18:12 -0700
changeset 32918 04c9dd951a41
parent 32917 070920db8b87
child 32919 daceeed34ad2
rebase: use context manager for locking in pullrebase()
hgext/rebase.py
--- a/hgext/rebase.py	Mon Jun 19 11:18:05 2017 -0700
+++ b/hgext/rebase.py	Mon Jun 19 11:18:12 2017 -0700
@@ -1378,10 +1378,7 @@
             hint = _('use hg pull followed by hg rebase -d DEST')
             raise error.Abort(msg, hint=hint)
 
-        wlock = lock = None
-        try:
-            wlock = repo.wlock()
-            lock = repo.lock()
+        with repo.wlock(), repo.lock():
             if opts.get('update'):
                 del opts['update']
                 ui.debug('--update and --rebase are not compatible, ignoring '
@@ -1425,8 +1422,6 @@
                         # not passing argument to get the bare update behavior
                         # with warning and trumpets
                         commands.update(ui, repo)
-        finally:
-            release(lock, wlock)
     else:
         if opts.get('tool'):
             raise error.Abort(_('--tool can only be used with --rebase'))