# HG changeset patch # User Pierre-Yves David # Date 1595531382 -7200 # Node ID ada51c1b691662b7108f1cef7e198a168554e1a9 # Parent 4eb6466e6889dfa234631737dba1bd59f7dc0a82 commitctx: move copy meta config reading in a dedicated function The logic is non trivial, make it contained in a function is clearer. It also unlock easy re-use of that logic without having the pass the value around. diff -r 4eb6466e6889 -r ada51c1b6916 mercurial/commit.py --- a/mercurial/commit.py Thu Jul 23 21:03:30 2020 +0200 +++ b/mercurial/commit.py Thu Jul 23 21:09:42 2020 +0200 @@ -24,6 +24,25 @@ ) +def _write_copy_meta(repo): + """return a (changelog, filelog) boolean tuple + + changelog: copy related information should be stored in the changeset + filelof: copy related information should be written in the file revision + """ + if repo.filecopiesmode == b'changeset-sidedata': + writechangesetcopy = True + writefilecopymeta = True + else: + writecopiesto = repo.ui.config(b'experimental', b'copies.write-to') + writefilecopymeta = writecopiesto != b'changeset-only' + writechangesetcopy = writecopiesto in ( + b'changeset-only', + b'compatibility', + ) + return writechangesetcopy, writefilecopymeta + + def commitctx(repo, ctx, error=False, origctx=None): """Add a new revision to the target repository. Revision information is passed via the context argument. @@ -44,16 +63,8 @@ p1, p2 = ctx.p1(), ctx.p2() user = ctx.user() - if repo.filecopiesmode == b'changeset-sidedata': - writechangesetcopy = True - writefilecopymeta = True - else: - writecopiesto = repo.ui.config(b'experimental', b'copies.write-to') - writefilecopymeta = writecopiesto != b'changeset-only' - writechangesetcopy = writecopiesto in ( - b'changeset-only', - b'compatibility', - ) + writechangesetcopy, writefilecopymeta = _write_copy_meta(repo) + p1copies, p2copies = None, None if writechangesetcopy: p1copies = ctx.p1copies()