Patchwork D10341: sidedata: gate sidedata functionality to revlogv2 in more places

login
register
mail settings
Submitter phabricator
Date April 9, 2021, 8:51 a.m.
Message ID <differential-rev-PHID-DREV-ayzwmpscpefe3uodlddd-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48661/
State Superseded
Headers show

Comments

phabricator - April 9, 2021, 8:51 a.m.
Alphare created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/localrepo.py
  mercurial/revlog.py

CHANGE DETAILS




To: Alphare, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2365,7 +2365,7 @@ 
 
         deltainfo = deltacomputer.finddeltainfo(revinfo, fh)
 
-        if sidedata:
+        if sidedata and self.version & 0xFFFF == REVLOGV2:
             serialized_sidedata = sidedatautil.serialize_sidedata(sidedata)
             sidedata_offset = offset + deltainfo.deltalen
         else:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -3360,6 +3360,9 @@ 
         return self.pathto(fp.name[len(self.root) + 1 :])
 
     def register_wanted_sidedata(self, category):
+        if requirementsmod.REVLOGV2_REQUIREMENT not in self.requirements:
+            # Only revlogv2 repos can want sidedata.
+            return
         self._wanted_sidedata.add(pycompat.bytestr(category))
 
     def register_sidedata_computer(self, kind, category, keys, computer):
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -293,7 +293,12 @@ 
 
         # Only useful if we're adding sidedata categories. If both peers have
         # the same categories, then we simply don't do anything.
-        if self.version == b'04' and srctype == b'pull':
+        adding_sidedata = (
+            requirements.REVLOGV2_REQUIREMENT in repo.requirements
+            and self.version == b'04'
+            and srctype == b'pull'
+        )
+        if adding_sidedata:
             sidedata_helpers = get_sidedata_helpers(
                 repo,
                 sidedata_categories or set(),