# HG changeset patch # User Pierre-Yves David # Date 2019-09-25 01:48:41 # Node ID 0b87eb2fba67c15a8c8af7c5074a17f52056aa9c # Parent 3518da5043032c41ade95e9e6832059e815abbbb 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 diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -391,6 +391,7 @@ class changelog(revlog.revlog): 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 @@ class changelog(revlog.revlog): 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) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -751,6 +751,11 @@ def resolvestorevfsoptions(ui, requireme 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):