changeset 47277:921648d31553

changelogv2: use a dedicated version number If we want to change the format, we need a new version number. We start with that. Differential Revision: https://phab.mercurial-scm.org/D10663
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 29 Mar 2021 20:46:56 +0200
parents a07381751dc9
children 55d280bc59fa
files mercurial/revlog.py mercurial/revlogutils/constants.py mercurial/revlogutils/docket.py
diffstat 3 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Tue May 04 03:05:52 2021 +0200
+++ b/mercurial/revlog.py	Mon Mar 29 20:46:56 2021 +0200
@@ -35,6 +35,7 @@
 from .pycompat import getattr
 from .revlogutils.constants import (
     ALL_KINDS,
+    CHANGELOGV2,
     COMP_MODE_DEFAULT,
     COMP_MODE_INLINE,
     COMP_MODE_PLAIN,
@@ -460,7 +461,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:
@@ -650,6 +651,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:
--- a/mercurial/revlogutils/constants.py	Tue May 04 03:05:52 2021 +0200
+++ b/mercurial/revlogutils/constants.py	Mon Mar 29 20:46:56 2021 +0200
@@ -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
 
@@ -141,6 +144,7 @@
     REVLOGV0: REVLOGV0_FLAGS,
     REVLOGV1: REVLOGV1_FLAGS,
     REVLOGV2: REVLOGV2_FLAGS,
+    CHANGELOGV2: CHANGELOGV2_FLAGS,
 }
 
 _no = lambda flags: False
@@ -173,6 +177,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,
+    },
 }
 
 
--- a/mercurial/revlogutils/docket.py	Tue May 04 03:05:52 2021 +0200
+++ b/mercurial/revlogutils/docket.py	Mon Mar 29 20:46:56 2021 +0200
@@ -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(