copies: prepare changelog for more copies storage mode
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 25 Sep 2019 03:48:41 +0200
changeset 43026 0b87eb2fba67
parent 43025 3518da504303
child 43027 041f042afcc5
copies: prepare changelog for more copies storage mode We want to store copies information in sidedata, the logic will be quite similar to the one used for extra, but sightly different (not in extra, no hash impact). We start with small refactoring to make our work easier and the coming changesets cleaners. Differential Revision: https://phab.mercurial-scm.org/D6936
mercurial/changelog.py
mercurial/localrepo.py
--- a/mercurial/changelog.py	Fri Sep 27 05:17:30 2019 +0200
+++ b/mercurial/changelog.py	Wed Sep 25 03:48:41 2019 +0200
@@ -391,6 +391,7 @@
         self._delaybuf = None
         self._divert = False
         self.filteredrevs = frozenset()
+        self._copiesstorage = opener.options.get('copies-storage')
 
     def tiprev(self):
         for i in pycompat.xrange(len(self) -1, -2, -1):
@@ -633,21 +634,22 @@
             elif branch in (".", "null", "tip"):
                 raise error.StorageError(_('the name \'%s\' is reserved')
                                          % branch)
-        extrasentries = p1copies, p2copies, filesadded, filesremoved
-        if extra is None and any(x is not None for x in extrasentries):
-            extra = {}
         sortedfiles = sorted(files)
         if extra is not None:
             for name in ('p1copies', 'p2copies', 'filesadded', 'filesremoved'):
                 extra.pop(name, None)
-        if p1copies is not None:
-            extra['p1copies'] = encodecopies(sortedfiles, p1copies)
-        if p2copies is not None:
-            extra['p2copies'] = encodecopies(sortedfiles, p2copies)
-        if filesadded is not None:
-            extra['filesadded'] = encodefileindices(sortedfiles, filesadded)
-        if filesremoved is not None:
-            extra['filesremoved'] = encodefileindices(sortedfiles, filesremoved)
+        if self._copiesstorage == 'extra':
+            extrasentries = p1copies, p2copies, filesadded, filesremoved
+            if extra is None and any(x is not None for x in extrasentries):
+                extra = {}
+            if p1copies is not None:
+                extra['p1copies'] = encodecopies(sortedfiles, p1copies)
+            if p2copies is not None:
+                extra['p2copies'] = encodecopies(sortedfiles, p2copies)
+            if filesadded is not None:
+                extra['filesadded'] = encodefileindices(sortedfiles, filesadded)
+            if filesremoved is not None:
+                extra['filesremoved'] = encodefileindices(sortedfiles, filesremoved)
 
         if extra:
             extra = encodeextra(extra)
--- a/mercurial/localrepo.py	Fri Sep 27 05:17:30 2019 +0200
+++ b/mercurial/localrepo.py	Wed Sep 25 03:48:41 2019 +0200
@@ -751,6 +751,11 @@
     else: # explicitly mark repo as using revlogv0
         options['revlogv0'] = True
 
+    writecopiesto = ui.config('experimental', 'copies.write-to')
+    copiesextramode = ('changeset-only', 'compatibility')
+    if (writecopiesto in copiesextramode):
+        options['copies-storage'] = 'extra'
+
     return options
 
 def resolverevlogstorevfsoptions(ui, requirements, features):