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

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


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

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -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'))


More information about the Mercurial-devel mailing list