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

login
register
mail settings
Submitter via Mercurial-devel
Date June 19, 2017, 8:47 p.m.
Message ID <34b34f533358a963f30c.1497905274@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/21508/
State Accepted
Headers show

Comments

via Mercurial-devel - June 19, 2017, 8:47 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@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()

Patch

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'))