Patchwork [05,of,15] commitctx: gather more code dealing with copy-in-extra

login
register
mail settings
Submitter Pierre-Yves David
Date July 29, 2020, 4:57 p.m.
Message ID <6b4ada6dca3ff5591c5d.1596041855@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/46918/
State Accepted
Headers show

Comments

Pierre-Yves David - July 29, 2020, 4:57 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1595684225 -7200
#      Sat Jul 25 15:37:05 2020 +0200
# Node ID 6b4ada6dca3ff5591c5dea32ffbe2fa22f4e5ed7
# Parent  abdea95834b108e194df0f686f01fb4fd1847691
# EXP-Topic files-change
# Available At https://foss.heptapod.net/octobus/mercurial-devel/
#              hg pull https://foss.heptapod.net/octobus/mercurial-devel/ -r 6b4ada6dca3f
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.

Patch

diff --git a/mercurial/commit.py b/mercurial/commit.py
--- a/mercurial/commit.py
+++ b/mercurial/commit.py
@@ -149,16 +149,6 @@  def _prepare_files(tr, ctx, error=False,
     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 @@  def _extra_with_copies(
     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 = {}