[Updated] D10648: revlogv2: preserve the compression mode on disk
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Mon May 17 21:55:38 UTC 2021
Closed by commit rHG6bfa6c2c5f15: revlogv2: preserve the compression mode on disk (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10648?vs=27887&id=28041
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10648/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D10648
AFFECTED FILES
mercurial/cext/revlog.c
mercurial/pure/parsers.py
mercurial/revlogutils/constants.py
CHANGE DETAILS
diff --git a/mercurial/revlogutils/constants.py b/mercurial/revlogutils/constants.py
--- a/mercurial/revlogutils/constants.py
+++ b/mercurial/revlogutils/constants.py
@@ -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
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -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"""
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -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)
To: marmoute, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210517/f393e1ae/attachment-0002.html>
More information about the Mercurial-patches
mailing list