Patchwork D3745: commit: use context manager for locks

login
register
mail settings
Submitter phabricator
Date June 14, 2018, 11:34 p.m.
Message ID <differential-rev-PHID-DREV-avnmb47ps3saxspemjix-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32155/
State Superseded
Headers show

Comments

phabricator - June 14, 2018, 11:34 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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