# HG changeset patch # User Pierre-Yves David # Date 2020-07-23 21:58:23 # Node ID bd7515273fd6d25af48bf5ffe766df8bf96682ad # Parent 39f4ec4039a8708063588771129b63c870e07a9b commitctx: gather more preparation code within the lock context This is a small change that exist mostly for clarification. I am about to move a large amount of code in its own function. having all that code next to each other will make the next changeset clearer. diff --git a/mercurial/commit.py b/mercurial/commit.py --- a/mercurial/commit.py +++ b/mercurial/commit.py @@ -63,14 +63,14 @@ def commitctx(repo, ctx, error=False, or p1, p2 = ctx.p1(), ctx.p2() user = ctx.user() - writechangesetcopy, writefilecopymeta = _write_copy_meta(repo) + with repo.lock(), repo.transaction(b"commit") as tr: + writechangesetcopy, writefilecopymeta = _write_copy_meta(repo) - p1copies, p2copies = None, None - if writechangesetcopy: - p1copies = ctx.p1copies() - p2copies = ctx.p2copies() - filesadded, filesremoved = None, None - with repo.lock(), repo.transaction(b"commit") as tr: + p1copies, p2copies = None, None + if writechangesetcopy: + p1copies = ctx.p1copies() + p2copies = ctx.p2copies() + filesadded, filesremoved = None, None if ctx.manifestnode(): # reuse an existing manifest revision repo.ui.debug(b'reusing known manifest\n')