changeset 45277:0041a42c6f28

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 25 Jul 2020 15:37:05 +0200
parents efe8a67793b6
children 3f54242781e9
files mercurial/commit.py
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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 = {}