# HG changeset patch # User Pierre-Yves David # Date 1595684225 -7200 # Node ID 0041a42c6f28e8133209f6040e583927937e1db7 # Parent efe8a67793b673cf86dc9db63cf9b6e19f52bdcf commitctx: gather more code dealing with copy-in-extra Now that we have a function that deal with the copy-in-extra special case, we can gather more code meant to deal with this special case. Making the rest of the code simpler. diff -r efe8a67793b6 -r 0041a42c6f28 mercurial/commit.py --- a/mercurial/commit.py Sat Jul 25 15:33:45 2020 +0200 +++ b/mercurial/commit.py Sat Jul 25 15:37:05 2020 +0200 @@ -149,16 +149,6 @@ if origctx and origctx.manifestnode() == mn: touched = origctx.files() - if not writefilecopymeta: - # If writing only to changeset extras, use None to indicate that - # no entry should be written. If writing to both, write an empty - # entry to prevent the reader from falling back to reading - # filelogs. - p1copies = p1copies or None - p2copies = p2copies or None - filesadded = filesadded or None - filesremoved = filesremoved or None - return mn, touched, p1copies, p2copies, filesadded, filesremoved @@ -427,6 +417,16 @@ repo, extra, files, p1copies, p2copies, filesadded, filesremoved ): """encode copy information into a `extra` dictionnary""" + if not _write_copy_meta(repo)[1]: + # If writing only to changeset extras, use None to indicate that + # no entry should be written. If writing to both, write an empty + # entry to prevent the reader from falling back to reading + # filelogs. + p1copies = p1copies or None + p2copies = p2copies or None + filesadded = filesadded or None + filesremoved = filesremoved or None + extrasentries = p1copies, p2copies, filesadded, filesremoved if extra is None and any(x is not None for x in extrasentries): extra = {}