Mercurial > hg
changeset 43146:0171483b082f
sidedatacopies: read rename information from sidedata
Repository using the new format now use changeset centric algorithm and read the
copies information from the changelog sidedata.
Differential Revision: https://phab.mercurial-scm.org/D6953
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 09 Oct 2019 22:59:38 +0200 |
parents | 4296cc3c4ae1 |
children | 54e943b28101 |
files | mercurial/changelog.py mercurial/context.py mercurial/copies.py tests/test-copies-unrelated.t tests/test-copies.t |
diffstat | 5 files changed, 88 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/changelog.py Thu Oct 10 00:06:41 2019 +0200 +++ b/mercurial/changelog.py Wed Oct 09 22:59:38 2019 +0200 @@ -362,28 +362,40 @@ @property def filesadded(self): - rawindices = self.extra.get(b'filesadded') + if sidedatamod.SD_FILESADDED in self._sidedata: + rawindices = self._sidedata.get(sidedatamod.SD_FILESADDED) + else: + rawindices = self.extra.get(b'filesadded') if rawindices is None: return None return decodefileindices(self.files, rawindices) @property def filesremoved(self): - rawindices = self.extra.get(b'filesremoved') + if sidedatamod.SD_FILESREMOVED in self._sidedata: + rawindices = self._sidedata.get(sidedatamod.SD_FILESREMOVED) + else: + rawindices = self.extra.get(b'filesremoved') if rawindices is None: return None return decodefileindices(self.files, rawindices) @property def p1copies(self): - rawcopies = self.extra.get(b'p1copies') + if sidedatamod.SD_P1COPIES in self._sidedata: + rawcopies = self._sidedata.get(sidedatamod.SD_P1COPIES) + else: + rawcopies = self.extra.get(b'p1copies') if rawcopies is None: return None return decodecopies(self.files, rawcopies) @property def p2copies(self): - rawcopies = self.extra.get(b'p2copies') + if sidedatamod.SD_P2COPIES in self._sidedata: + rawcopies = self._sidedata.get(sidedatamod.SD_P2COPIES) + else: + rawcopies = self.extra.get(b'p2copies') if rawcopies is None: return None return decodecopies(self.files, rawcopies)
--- a/mercurial/context.py Thu Oct 10 00:06:41 2019 +0200 +++ b/mercurial/context.py Wed Oct 09 22:59:38 2019 +0200 @@ -533,55 +533,76 @@ return sorted(modified) def filesadded(self): - source = self._repo.ui.config(b'experimental', b'copies.read-from') filesadded = self._changeset.filesadded - if source == b'changeset-only': - if filesadded is None: + compute_on_none = True + if self._repo.filecopiesmode == b'changeset-sidedata': + compute_on_none = False + else: + source = self._repo.ui.config(b'experimental', b'copies.read-from') + if source == b'changeset-only': + compute_on_none = False + elif source != b'compatibility': + # filelog mode, ignore any changelog content + filesadded = None + if filesadded is None: + if compute_on_none: + filesadded = scmutil.computechangesetfilesadded(self) + else: filesadded = [] - elif source == b'compatibility': - if filesadded is None: - filesadded = scmutil.computechangesetfilesadded(self) - else: - filesadded = scmutil.computechangesetfilesadded(self) return filesadded def filesremoved(self): - source = self._repo.ui.config(b'experimental', b'copies.read-from') filesremoved = self._changeset.filesremoved - if source == b'changeset-only': - if filesremoved is None: + compute_on_none = True + if self._repo.filecopiesmode == b'changeset-sidedata': + compute_on_none = False + else: + source = self._repo.ui.config(b'experimental', b'copies.read-from') + if source == b'changeset-only': + compute_on_none = False + elif source != b'compatibility': + # filelog mode, ignore any changelog content + filesremoved = None + if filesremoved is None: + if compute_on_none: + filesremoved = scmutil.computechangesetfilesremoved(self) + else: filesremoved = [] - elif source == b'compatibility': - if filesremoved is None: - filesremoved = scmutil.computechangesetfilesremoved(self) - else: - filesremoved = scmutil.computechangesetfilesremoved(self) return filesremoved @propertycache def _copies(self): - source = self._repo.ui.config(b'experimental', b'copies.read-from') p1copies = self._changeset.p1copies p2copies = self._changeset.p2copies - # If config says to get copy metadata only from changeset, then return - # that, defaulting to {} if there was no copy metadata. - # In compatibility mode, we return copy data from the changeset if - # it was recorded there, and otherwise we fall back to getting it from - # the filelogs (below). - if source == b'changeset-only': - if p1copies is None: - p1copies = {} - if p2copies is None: - p2copies = {} - elif source == b'compatibility': - if p1copies is None: - # we are in compatiblity mode and there is not data in the - # changeset), we get the copy metadata from the filelogs. + compute_on_none = True + if self._repo.filecopiesmode == b'changeset-sidedata': + compute_on_none = False + else: + source = self._repo.ui.config(b'experimental', b'copies.read-from') + # If config says to get copy metadata only from changeset, then + # return that, defaulting to {} if there was no copy metadata. In + # compatibility mode, we return copy data from the changeset if it + # was recorded there, and otherwise we fall back to getting it from + # the filelogs (below). + # + # If we are in compatiblity mode and there is not data in the + # changeset), we get the copy metadata from the filelogs. + # + # otherwise, when config said to read only from filelog, we get the + # copy metadata from the filelogs. + if source == b'changeset-only': + compute_on_none = False + elif source != b'compatibility': + # filelog mode, ignore any changelog content + p1copies = p2copies = None + if p1copies is None: + if compute_on_none: p1copies, p2copies = super(changectx, self)._copies - else: - # config said to read only from filelog, we get the copy metadata - # from the filelogs. - p1copies, p2copies = super(changectx, self)._copies + else: + if p1copies is None: + p1copies = {} + if p2copies is None: + p2copies = {} return p1copies, p2copies def description(self):
--- a/mercurial/copies.py Thu Oct 10 00:06:41 2019 +0200 +++ b/mercurial/copies.py Wed Oct 09 22:59:38 2019 +0200 @@ -188,6 +188,8 @@ def usechangesetcentricalgo(repo): """Checks if we should use changeset-centric copy algorithms""" + if repo.filecopiesmode == b'changeset-sidedata': + return True readfrom = repo.ui.config(b'experimental', b'copies.read-from') changesetsource = (b'changeset-only', b'compatibility') return readfrom in changesetsource
--- a/tests/test-copies-unrelated.t Thu Oct 10 00:06:41 2019 +0200 +++ b/tests/test-copies-unrelated.t Wed Oct 09 22:59:38 2019 +0200 @@ -179,8 +179,8 @@ o 0 add x x $ hg debugpathcopies 0 5 - x -> y (no-filelog no-sidedata !) -#if no-filelog no-sidedata + x -> y (no-filelog !) +#if no-filelog $ hg graft -r 2 grafting 2:* "modify x again" (glob) merging y and x to y @@ -347,8 +347,8 @@ o 0 base a $ hg debugpathcopies 1 5 - x -> y (no-filelog no-sidedata !) -#if no-filelog no-sidedata + x -> y (no-filelog !) +#if no-filelog $ hg graft -r 2 grafting 2:* "modify x" (glob) merging y and x to y
--- a/tests/test-copies.t Thu Oct 10 00:06:41 2019 +0200 +++ b/tests/test-copies.t Wed Oct 09 22:59:38 2019 +0200 @@ -309,7 +309,6 @@ x -> z $ hg debugpathcopies 0 2 x -> z (filelog !) - x -> z (sidedata !) Copy file that exists on both sides of the merge, different content $ newrepo @@ -338,12 +337,14 @@ x $ hg debugp1copies -r 2 x -> z (changeset !) + x -> z (sidedata !) $ hg debugp2copies -r 2 - x -> z (no-changeset !) + x -> z (no-changeset no-sidedata !) $ hg debugpathcopies 1 2 x -> z (changeset !) + x -> z (sidedata !) $ hg debugpathcopies 0 2 - x -> z (no-changeset !) + x -> z (no-changeset no-sidedata !) Copy x->y on one side of merge and copy x->z on the other side. Pathcopies from one parent of the merge to the merge should include the copy from the other side. @@ -403,7 +404,7 @@ $ hg debugpathcopies 2 3 y -> z $ hg debugpathcopies 1 3 - y -> z (no-filelog no-sidedata !) + y -> z (no-filelog !) Create x and y, then rename x to z on one side of merge, and rename y to z and modify z on the other side. When storing copies in the changeset, we don't @@ -448,18 +449,16 @@ o 0 add x and y x y $ hg debugpathcopies 1 4 - y -> z (no-filelog no-sidedata !) + y -> z (no-filelog !) $ hg debugpathcopies 2 4 - x -> z (no-filelog no-sidedata !) + x -> z (no-filelog !) $ hg debugpathcopies 0 4 x -> z (filelog !) - x -> z (sidedata !) - y -> z (compatibility !) - y -> z (changeset !) + y -> z (no-filelog !) $ hg debugpathcopies 1 5 - y -> z (no-filelog no-sidedata !) + y -> z (no-filelog !) $ hg debugpathcopies 2 5 - x -> z (no-filelog no-sidedata !) + x -> z (no-filelog !) $ hg debugpathcopies 0 5 x -> z