Patchwork D10562: revlog: replace REVLOGV2 check related to sidedata with `hassidedata` checks

login
register
mail settings
Submitter phabricator
Date May 3, 2021, 11:48 a.m.
Message ID <differential-rev-PHID-DREV-xolhoy44kf2h5fgknu26-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48882/
State New
Headers show

Comments

phabricator - May 3, 2021, 11:48 a.m.
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is more flexible and semantically more correct. The associated revlog's
  attribute exist since 827cb4fe62a3 <https://phab.mercurial-scm.org/rHG827cb4fe62a3fb3d0ca880e08f3daa5e2c413c3f>, so well we start linking sidedata to
  revlogv2.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlog.py
  tests/testlib/ext-sidedata.py

CHANGE DETAILS




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

Patch

diff --git a/tests/testlib/ext-sidedata.py b/tests/testlib/ext-sidedata.py
--- a/tests/testlib/ext-sidedata.py
+++ b/tests/testlib/ext-sidedata.py
@@ -42,7 +42,7 @@ 
     text, sd = orig(self, nodeorrev, *args, **kwargs)
     if getattr(self, 'sidedatanocheck', False):
         return text, sd
-    if self.version & 0xFFFF != 2:
+    if self.hassidedata:
         return text, sd
     if nodeorrev != nullrev and nodeorrev != self.nullid:
         cat1 = sd.get(sidedata.SD_TEST1)
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -715,7 +715,7 @@ 
         return self.index[rev][1]
 
     def sidedata_length(self, rev):
-        if self.version & 0xFFFF != REVLOGV2:
+        if not self.hassidedata:
             return 0
         return self.index[rev][9]
 
@@ -1771,7 +1771,7 @@ 
         # revision or might need to be processed to retrieve the revision.
         rev, rawtext, validated = self._rawtext(node, rev, _df=_df)
 
-        if self.version & 0xFFFF == REVLOGV2:
+        if self.hassidedata:
             if rev is None:
                 rev = self.rev(node)
             sidedata = self._sidedata(rev)
@@ -2246,7 +2246,7 @@ 
 
         deltainfo = deltacomputer.finddeltainfo(revinfo, fh)
 
-        if sidedata and self.version & 0xFFFF == REVLOGV2:
+        if sidedata and self.hassidedata:
             serialized_sidedata = sidedatautil.serialize_sidedata(sidedata)
             sidedata_offset = offset + deltainfo.deltalen
         else:
@@ -3072,7 +3072,7 @@ 
         return d
 
     def rewrite_sidedata(self, helpers, startrev, endrev):
-        if self.version & 0xFFFF != REVLOGV2:
+        if not self.hassidedata:
             return
         # inline are not yet supported because they suffer from an issue when
         # rewriting them (since it's not an append-only operation).