D6936: copies: prepare changelog for more copies storage mode

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Tue Oct 1 08:34:15 EDT 2019


marmoute created this revision.
marmoute added reviewers: martinvonz, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6936

AFFECTED FILES
  mercurial/changelog.py
  mercurial/localrepo.py

CHANGE DETAILS

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -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):
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -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)



To: marmoute, martinvonz, durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list