D5623: localrepo: use context manager for locks in commit()

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Jan 25 15:02:00 EST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb87a009d1b3b: localrepo: use context manager for locks in commit() (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5623?vs=13306&id=13451

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

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2409,11 +2409,8 @@
             match.explicitdir = vdirs.append
             match.bad = fail
 
-        wlock = lock = None
-        try:
-            wlock = self.wlock()
-            lock = self.lock() # for recent changelog (see issue4368)
-
+        # lock() for recent changelog (see issue4368)
+        with self.wlock(), self.lock():
             wctx = self[None]
             merge = len(wctx.parents()) > 1
 
@@ -2485,9 +2482,6 @@
                         _('note: commit message saved in %s\n') % msgfn)
                 raise
 
-        finally:
-            lockmod.release(lock, wlock)
-
         def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
             # hack for command that use a temporary commit (eg: histedit)
             # temporary commit got stripped before hook release



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


More information about the Mercurial-devel mailing list