changeset 32918:04c9dd951a41

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