Patchwork D3745: commit: use context manager for locks

login
register
mail settings
Submitter phabricator
Date June 15, 2018, 12:49 p.m.
Message ID <6e4556b5a9d345020bf1ec70c8c8903e@localhost.localdomain>
Download mbox | patch
Permalink /patch/32173/
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 rHGe218ed5ba484: commit: use context manager for locks (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3745?vs=9074&id=9089

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

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
@@ -1523,13 +1523,8 @@ 
 
           hg commit --amend --date now
     """
-    wlock = lock = None
-    try:
-        wlock = repo.wlock()
-        lock = repo.lock()
+    with repo.wlock(), repo.lock():
         return _docommit(ui, repo, *pats, **opts)
-    finally:
-        release(lock, wlock)
 
 def _docommit(ui, repo, *pats, **opts):
     if opts.get(r'interactive'):