Patchwork [07,of,15] commitctx: directly pass a ChangingFiles object to changelog.add

login
register
mail settings
Submitter Pierre-Yves David
Date July 29, 2020, 4:57 p.m.
Message ID <a728c320f0d7c71c7335.1596041857@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/46930/
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 1595685309 -7200
#      Sat Jul 25 15:55:09 2020 +0200
# Node ID a728c320f0d7c71c733524969e728e533e2d34d6
# Parent  88cc2b7a810243e8c101933fd99778ce772ac316
# EXP-Topic files-change
# Available At https://foss.heptapod.net/octobus/mercurial-devel/
#              hg pull https://foss.heptapod.net/octobus/mercurial-devel/ -r a728c320f0d7
commitctx: directly pass a ChangingFiles object to changelog.add

We pass the rich object to the changelog and it read the field it needs.

Patch

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -524,10 +524,6 @@  class changelog(revlog.revlog):
         user,
         date=None,
         extra=None,
-        p1copies=None,
-        p2copies=None,
-        filesadded=None,
-        filesremoved=None,
     ):
         # Convert to UTF-8 encoded bytestrings as the very first
         # thing: calling any method on a localstr object will turn it
@@ -559,19 +555,23 @@  class changelog(revlog.revlog):
                 raise error.StorageError(
                     _(b'the name \'%s\' is reserved') % branch
                 )
-        sortedfiles = sorted(files)
+        sortedfiles = sorted(files.touched)
         sidedata = None
         if self._copiesstorage == b'changeset-sidedata':
             sidedata = {}
+            p1copies = files.copied_from_p1
             if p1copies:
                 p1copies = metadata.encodecopies(sortedfiles, p1copies)
                 sidedata[sidedatamod.SD_P1COPIES] = p1copies
+            p2copies = files.copied_from_p2
             if p2copies:
                 p2copies = metadata.encodecopies(sortedfiles, p2copies)
                 sidedata[sidedatamod.SD_P2COPIES] = p2copies
+            filesadded = files.added
             if filesadded:
                 filesadded = metadata.encodefileindices(sortedfiles, filesadded)
                 sidedata[sidedatamod.SD_FILESADDED] = filesadded
+            filesremoved = files.removed
             if filesremoved:
                 filesremoved = metadata.encodefileindices(
                     sortedfiles, filesremoved
diff --git a/mercurial/commit.py b/mercurial/commit.py
--- a/mercurial/commit.py
+++ b/mercurial/commit.py
@@ -84,7 +84,7 @@  def commitctx(repo, ctx, error=False, or
         repo.changelog.delayupdate(tr)
         n = repo.changelog.add(
             mn,
-            files.touched,
+            files,
             ctx.description(),
             tr,
             p1.node(),
@@ -92,10 +92,6 @@  def commitctx(repo, ctx, error=False, or
             user,
             ctx.date(),
             extra,
-            files.copied_from_p1,
-            files.copied_from_p2,
-            files.added,
-            files.removed,
         )
         xp1, xp2 = p1.hex(), p2 and p2.hex() or b''
         repo.hook(
diff --git a/tests/test-convert-identity.t b/tests/test-convert-identity.t
--- a/tests/test-convert-identity.t
+++ b/tests/test-convert-identity.t
@@ -8,9 +8,10 @@  versions.
   > convert =
   > EOF
   $ cat <<'EOF' > changefileslist.py
-  > from mercurial import (changelog, extensions)
+  > from mercurial import (changelog, extensions, metadata)
   > def wrap(orig, clog, manifest, files, *args, **kwargs):
-  >   return orig(clog, manifest, [b"a"], *args, **kwargs)
+  >   files = metadata.ChangingFiles(touched=[b"a"])
+  >   return orig(clog, manifest, files, *args, **kwargs)
   > def extsetup(ui):
   >   extensions.wrapfunction(changelog.changelog, 'add', wrap)
   > EOF