localrepo: use context manager for locks in commit()
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 16 Jan 2019 17:34:59 -0800
changeset 41363 b87a009d1b3b
parent 41362 57c462db87fd
child 41364 0132221c25cd
localrepo: use context manager for locks in commit() Differential Revision: https://phab.mercurial-scm.org/D5623
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Wed Jan 16 17:33:47 2019 -0800
+++ b/mercurial/localrepo.py	Wed Jan 16 17:34:59 2019 -0800
@@ -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