# HG changeset patch # User Martin von Zweigbergk # Date 1529013914 25200 # Node ID e218ed5ba484fec05e605da9cd821f35271d63d8 # Parent 9b1536b02221741135effe9ffdb1a3f3f1cda8fc commit: use context manager for locks Differential Revision: https://phab.mercurial-scm.org/D3745 diff -r 9b1536b02221 -r e218ed5ba484 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'):