Patchwork D10663: changelogv2: use a dedicated version number

login
register
mail settings
Submitter phabricator
Date May 4, 2021, 2:20 p.m.
Message ID <differential-rev-PHID-DREV-napvkfl7duxwdz4vsp67-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48981/
State Superseded
Headers show

Comments

phabricator - May 4, 2021, 2:20 p.m.
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  If we want to change the format, we need a new version number. We start with
  that.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlog.py
  mercurial/revlogutils/constants.py
  mercurial/revlogutils/docket.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlogutils/docket.py b/mercurial/revlogutils/docket.py
--- a/mercurial/revlogutils/docket.py
+++ b/mercurial/revlogutils/docket.py
@@ -145,7 +145,8 @@ 
 
 def default_docket(revlog, version_header):
     """given a revlog version a new docket object for the given revlog"""
-    if (version_header & 0xFFFF) != constants.REVLOGV2:
+    rl_version = version_header & 0xFFFF
+    if rl_version not in (constants.REVLOGV2, constants.CHANGELOGV2):
         return None
     comp = util.compengines[revlog._compengine].revlogheader()
     docket = RevlogDocket(
diff --git a/mercurial/revlogutils/constants.py b/mercurial/revlogutils/constants.py
--- a/mercurial/revlogutils/constants.py
+++ b/mercurial/revlogutils/constants.py
@@ -36,6 +36,8 @@ 
 REVLOGV1 = 1
 # Dummy value until file format is finalized.
 REVLOGV2 = 0xDEAD
+# Dummy value until file format is finalized.
+CHANGELOGV2 = 0xD34D
 
 ##  global revlog header flags
 # Shared across v1 and v2.
@@ -48,6 +50,7 @@ 
 REVLOGV0_FLAGS = 0
 REVLOGV1_FLAGS = FLAG_INLINE_DATA | FLAG_GENERALDELTA
 REVLOGV2_FLAGS = FLAG_INLINE_DATA
+CHANGELOGV2_FLAGS = 0
 
 ### individual entry
 
@@ -125,6 +128,7 @@ 
     REVLOGV0: REVLOGV0_FLAGS,
     REVLOGV1: REVLOGV1_FLAGS,
     REVLOGV2: REVLOGV2_FLAGS,
+    CHANGELOGV2: CHANGELOGV2_FLAGS,
 }
 
 _no = lambda flags: False
@@ -157,6 +161,13 @@ 
         b'sidedata': True,
         b'docket': True,
     },
+    CHANGELOGV2: {
+        b'inline': _no,
+        # General delta is useless for changelog since we don't do any delta
+        b'generaldelta': _no,
+        b'sidedata': True,
+        b'docket': True,
+    },
 }
 
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -35,6 +35,7 @@ 
 from .pycompat import getattr
 from .revlogutils.constants import (
     ALL_KINDS,
+    CHANGELOGV2,
     COMP_MODE_DEFAULT,
     COMP_MODE_INLINE,
     COMP_MODE_PLAIN,
@@ -459,7 +460,7 @@ 
         opts = self.opener.options
 
         if b'changelogv2' in opts and self.revlog_kind == KIND_CHANGELOG:
-            new_header = REVLOGV2
+            new_header = CHANGELOGV2
         elif b'revlogv2' in opts:
             new_header = REVLOGV2
         elif b'revlogv1' in opts:
@@ -649,6 +650,8 @@ 
             self._parse_index = revlogv0.parse_index_v0
         elif self._format_version == REVLOGV2:
             self._parse_index = parse_index_v2
+        elif self._format_version == CHANGELOGV2:
+            self._parse_index = parse_index_v2
         elif devel_nodemap:
             self._parse_index = parse_index_v1_nodemap
         elif use_rust_index: