Patchwork D3744: backout: use context manager for locks

login
register
mail settings
Submitter phabricator
Date June 15, 2018, 12:49 p.m.
Message ID <5c72195cac8a9a09743bfef1246d406d@localhost.localdomain>
Download mbox | patch
Permalink /patch/32172/
State Not Applicable
Headers show

Comments

phabricator - June 15, 2018, 12:49 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9b1536b02221: backout: use context manager for locks (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3744?vs=9073&id=9088

REVISION DETAIL
  https://phab.mercurial-scm.org/D3744

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -560,13 +560,8 @@ 
     Returns 0 on success, 1 if nothing to backout or there are unresolved
     files.
     '''
-    wlock = lock = None
-    try:
-        wlock = repo.wlock()
-        lock = repo.lock()
+    with repo.wlock(), repo.lock():
         return _dobackout(ui, repo, node, rev, **opts)
-    finally:
-        release(lock, wlock)
 
 def _dobackout(ui, repo, node=None, rev=None, **opts):
     opts = pycompat.byteskwargs(opts)