commit: use context manager for locks
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 14 Jun 2018 15:05:14 -0700
changeset 38331 e218ed5ba484
parent 38330 9b1536b02221
child 38332 48c52385e062
commit: use context manager for locks Differential Revision: https://phab.mercurial-scm.org/D3745
mercurial/commands.py
--- a/mercurial/commands.py	Thu Jun 14 15:08:19 2018 -0700
+++ b/mercurial/commands.py	Thu Jun 14 15:05:14 2018 -0700
@@ -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'):