Patchwork D6936: copies: prepare changelog for more copies storage mode

login
register
mail settings
Submitter phabricator
Date Oct. 1, 2019, 5:08 p.m.
Message ID <77c56f48e8418060bb6003dcea33d471@localhost.localdomain>
Download mbox | patch
Permalink /patch/41908/
State Not Applicable
Headers show

Comments

phabricator - Oct. 1, 2019, 5:08 p.m.
Closed by commit rHG0b87eb2fba67: copies: prepare changelog for more copies storage mode (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6936?vs=16733&id=16757

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6936/new/

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

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

CHANGE DETAILS




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

Patch

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)