# HG changeset patch # User Pierre-Yves David # Date 1570040190 14400 # Node ID e51f5d06a99ca1017d37283c546e3ac2a3eb228b # Parent 9fa941faef94a18e493cd571246f8c1a8730bf35 sidedatacopies: only read from copies when in this mode If we know we expect data from sidedata, we read them from sidedata and nothing else. This avoid looking into extra for revision without sidedata entries. Such revision will be introduced in the next changesets. Differential Revision: https://phab.mercurial-scm.org/D7067 diff -r 9fa941faef94 -r e51f5d06a99c mercurial/changelog.py --- a/mercurial/changelog.py Sun Oct 13 20:06:09 2019 +0900 +++ b/mercurial/changelog.py Wed Oct 02 14:16:30 2019 -0400 @@ -215,9 +215,10 @@ r'_offsets', r'_text', r'_sidedata', + r'_cpsd', ) - def __new__(cls, text, sidedata): + def __new__(cls, text, sidedata, cpsd): if not text: return _changelogrevision(extra=_defaultextra) @@ -250,6 +251,7 @@ self._offsets = (nl1, nl2, nl3, doublenl) self._text = text self._sidedata = sidedata + self._cpsd = cpsd return self @@ -308,8 +310,10 @@ @property def filesadded(self): - if sidedatamod.SD_FILESADDED in self._sidedata: + if self._cpsd: rawindices = self._sidedata.get(sidedatamod.SD_FILESADDED) + if not rawindices: + return [] else: rawindices = self.extra.get(b'filesadded') if rawindices is None: @@ -318,8 +322,10 @@ @property def filesremoved(self): - if sidedatamod.SD_FILESREMOVED in self._sidedata: + if self._cpsd: rawindices = self._sidedata.get(sidedatamod.SD_FILESREMOVED) + if not rawindices: + return [] else: rawindices = self.extra.get(b'filesremoved') if rawindices is None: @@ -328,8 +334,10 @@ @property def p1copies(self): - if sidedatamod.SD_P1COPIES in self._sidedata: + if self._cpsd: rawcopies = self._sidedata.get(sidedatamod.SD_P1COPIES) + if not rawcopies: + return {} else: rawcopies = self.extra.get(b'p1copies') if rawcopies is None: @@ -338,8 +346,10 @@ @property def p2copies(self): - if sidedatamod.SD_P2COPIES in self._sidedata: + if self._cpsd: rawcopies = self._sidedata.get(sidedatamod.SD_P2COPIES) + if not rawcopies: + return {} else: rawcopies = self.extra.get(b'p2copies') if rawcopies is None: @@ -581,13 +591,18 @@ ``changelogrevision`` instead, as it is faster for partial object access. """ - c = changelogrevision(*self._revisiondata(node)) + d, s = self._revisiondata(node) + c = changelogrevision( + d, s, self._copiesstorage == b'changeset-sidedata' + ) return (c.manifest, c.user, c.date, c.files, c.description, c.extra) def changelogrevision(self, nodeorrev): """Obtain a ``changelogrevision`` for a node or revision.""" text, sidedata = self._revisiondata(nodeorrev) - return changelogrevision(text, sidedata) + return changelogrevision( + text, sidedata, self._copiesstorage == b'changeset-sidedata' + ) def readfiles(self, node): """