Patchwork D7067: sidedatacopies: only read from copies when in this mode

login
register
mail settings
Submitter phabricator
Date Oct. 12, 2019, 4:45 p.m.
Message ID <differential-rev-PHID-DREV-tbymulea7pmb4lzaagah-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42267/
State Superseded
Headers show

Comments

phabricator - Oct. 12, 2019, 4:45 p.m.
marmoute created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/changelog.py

CHANGE DETAILS




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

Patch

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