--- a/mercurial/cext/revlog.c Tue May 04 01:15:03 2021 +0200
+++ b/mercurial/cext/revlog.c Mon May 03 18:19:16 2021 +0200
@@ -118,9 +118,9 @@
static int index_find_node(indexObject *self, const char *node);
#if LONG_MAX == 0x7fffffffL
-static const char *const tuple_format = PY23("Kiiiiiis#Ki", "Kiiiiiiy#Ki");
+static const char *const tuple_format = PY23("Kiiiiiis#KiB", "Kiiiiiiy#KiB");
#else
-static const char *const tuple_format = PY23("kiiiiiis#ki", "kiiiiiiy#ki");
+static const char *const tuple_format = PY23("kiiiiiis#kiB", "kiiiiiiy#kiB");
#endif
/* A RevlogNG v1 index entry is 64 bytes long. */
@@ -132,6 +132,8 @@
static const long format_v1 = 1; /* Internal only, could be any number */
static const long format_v2 = 2; /* Internal only, could be any number */
+static const char comp_mode_inline = 2;
+
static void raise_revlog_error(void)
{
PyObject *mod = NULL, *dict = NULL, *errclass = NULL;
@@ -294,6 +296,7 @@
uint64_t offset_flags, sidedata_offset;
int comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2,
sidedata_comp_len;
+ char data_comp_mode;
const char *c_node_id;
const char *data;
Py_ssize_t length = index_length(self);
@@ -340,9 +343,11 @@
sidedata_comp_len = getbe32(data + 72);
}
+ 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);
+ self->nodelen, sidedata_offset, sidedata_comp_len,
+ data_comp_mode);
}
/*
* Pack header information in binary
@@ -443,6 +448,7 @@
{
uint64_t offset_flags, sidedata_offset;
int rev, comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2;
+ char data_comp_mode;
Py_ssize_t c_node_id_len, sidedata_comp_len;
const char *c_node_id;
char *data;
@@ -450,8 +456,9 @@
if (!PyArg_ParseTuple(obj, tuple_format, &offset_flags, &comp_len,
&uncomp_len, &base_rev, &link_rev, &parent_1,
&parent_2, &c_node_id, &c_node_id_len,
- &sidedata_offset, &sidedata_comp_len)) {
- PyErr_SetString(PyExc_TypeError, "10-tuple required");
+ &sidedata_offset, &sidedata_comp_len,
+ &data_comp_mode)) {
+ PyErr_SetString(PyExc_TypeError, "11-tuple required");
return NULL;
}
@@ -459,6 +466,12 @@
PyErr_SetString(PyExc_TypeError, "invalid node");
return NULL;
}
+ if (data_comp_mode != comp_mode_inline) {
+ PyErr_Format(PyExc_ValueError,
+ "invalid data compression mode: %i",
+ data_comp_mode);
+ return NULL;
+ }
if (self->new_length == self->added_length) {
size_t new_added_length =
@@ -2761,9 +2774,9 @@
self->entry_size = v1_entry_size;
}
- self->nullentry =
- Py_BuildValue(PY23("iiiiiiis#ii", "iiiiiiiy#ii"), 0, 0, 0, -1, -1,
- -1, -1, nullid, self->nodelen, 0, 0);
+ self->nullentry = Py_BuildValue(PY23("iiiiiiis#iiB", "iiiiiiiy#iiB"), 0,
+ 0, 0, -1, -1, -1, -1, nullid,
+ self->nodelen, 0, 0, comp_mode_inline);
if (!self->nullentry)
return -1;