diff mercurial/changelog.py @ 43142:beed7ce61681

sidedatacopies: write copies information in sidedata when applicable If the format of the repository indicate it stores copies information into changeset's sidedata, then we actually write that information into sidedata at commit time. It will be put to use in later changesets. Currently, we store all field unconditionally, but that is likely to change in the future for the sake of efficiency. Differential Revision: https://phab.mercurial-scm.org/D6950
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 06 Oct 2019 23:36:51 -0400
parents 687b865b95ad
children 037a8759eda1
line wrap: on
line diff
--- a/mercurial/changelog.py	Sun Oct 06 23:36:51 2019 -0400
+++ b/mercurial/changelog.py	Sun Oct 06 23:36:51 2019 -0400
@@ -27,6 +27,8 @@
     stringutil,
 )
 
+from .revlogutils import sidedata as sidedatamod
+
 _defaultextra = {b'branch': b'default'}
 
 
@@ -676,6 +678,7 @@
                     _(b'the name \'%s\' is reserved') % branch
                 )
         sortedfiles = sorted(files)
+        sidedata = None
         if extra is not None:
             for name in (
                 b'p1copies',
@@ -704,13 +707,25 @@
                 extra[b'filesadded'] = filesadded
             if filesremoved is not None:
                 extra[b'filesremoved'] = filesremoved
+        elif self._copiesstorage == b'changeset-sidedata':
+            sidedata = {}
+            if p1copies is not None:
+                sidedata[sidedatamod.SD_P1COPIES] = p1copies
+            if p2copies is not None:
+                sidedata[sidedatamod.SD_P2COPIES] = p2copies
+            if filesadded is not None:
+                sidedata[sidedatamod.SD_FILESADDED] = filesadded
+            if filesremoved is not None:
+                sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved
 
         if extra:
             extra = encodeextra(extra)
             parseddate = b"%s %s" % (parseddate, extra)
         l = [hex(manifest), user, parseddate] + sortedfiles + [b"", desc]
         text = b"\n".join(l)
-        return self.addrevision(text, transaction, len(self), p1, p2)
+        return self.addrevision(
+            text, transaction, len(self), p1, p2, sidedata=sidedata
+        )
 
     def branchinfo(self, rev):
         """return the branch name and open/close state of a revision