revlogv2: preserve the compression mode on disk
The value is still the same and still not treated, but now it exists one disk.
Differential Revision: https://phab.mercurial-scm.org/D10648
--- a/mercurial/cext/revlog.c Tue May 04 01:49:37 2021 +0200
+++ b/mercurial/cext/revlog.c Mon May 03 18:41:51 2021 +0200
@@ -338,12 +338,13 @@
if (self->format_version == format_v1) {
sidedata_offset = 0;
sidedata_comp_len = 0;
+ data_comp_mode = comp_mode_inline;
} else {
sidedata_offset = getbe64(data + 64);
sidedata_comp_len = getbe32(data + 72);
+ data_comp_mode = data[76];
}
- data_comp_mode = comp_mode_inline;
return Py_BuildValue(tuple_format, offset_flags, comp_len, uncomp_len,
base_rev, link_rev, parent_1, parent_2, c_node_id,
self->nodelen, sidedata_offset, sidedata_comp_len,
@@ -466,7 +467,8 @@
PyErr_SetString(PyExc_TypeError, "invalid node");
return NULL;
}
- if (data_comp_mode != comp_mode_inline) {
+ if (self->format_version == format_v1 &&
+ data_comp_mode != comp_mode_inline) {
PyErr_Format(PyExc_ValueError,
"invalid data compression mode: %i",
data_comp_mode);
@@ -499,8 +501,9 @@
if (self->format_version == format_v2) {
putbe64(sidedata_offset, data + 64);
putbe32(sidedata_comp_len, data + 72);
+ data[76] = (char)data_comp_mode;
/* Padding for 96 bytes alignment */
- memset(data + 76, 0, self->entry_size - 76);
+ memset(data + 77, 0, self->entry_size - 77);
}
if (self->ntinitialized)
--- a/mercurial/pure/parsers.py Tue May 04 01:49:37 2021 +0200
+++ b/mercurial/pure/parsers.py Mon May 03 18:41:51 2021 +0200
@@ -315,12 +315,10 @@
self._extra[rev - self._lgt] = new
def _unpack_entry(self, data):
- return self.index_format.unpack(data) + (
- revlog_constants.COMP_MODE_INLINE,
- )
+ return self.index_format.unpack(data)
def _pack_entry(self, entry):
- return self.index_format.pack(*entry[:10])
+ return self.index_format.pack(*entry[:11])
def entry_binary(self, rev):
"""return the raw binary string representing a revision"""
--- a/mercurial/revlogutils/constants.py Tue May 04 01:49:37 2021 +0200
+++ b/mercurial/revlogutils/constants.py Mon May 03 18:41:51 2021 +0200
@@ -85,9 +85,10 @@
# 32 bytes: nodeid
# 8 bytes: sidedata offset
# 4 bytes: sidedata compressed length
-# 20 bytes: Padding to align to 96 bytes (see RevlogV2Plan wiki page)
-INDEX_ENTRY_V2 = struct.Struct(b">Qiiiiii20s12xQi20x")
-assert INDEX_ENTRY_V2.size == 32 * 3
+# 1 bytes: compression mode (2 lower bit are data_compression_mode)
+# 19 bytes: Padding to align to 96 bytes (see RevlogV2Plan wiki page)
+INDEX_ENTRY_V2 = struct.Struct(b">Qiiiiii20s12xQiB19x")
+assert INDEX_ENTRY_V2.size == 32 * 3, INDEX_ENTRY_V2.size
# revlog index flags