diff -r 616b8f412676 -r 6b1eae313b2f mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c Mon May 03 12:34:11 2021 +0200 +++ b/mercurial/cext/revlog.c Mon May 03 12:34:21 2021 +0200 @@ -354,6 +354,13 @@ if (!PyArg_ParseTuple(args, "I", &header)) { return NULL; } + if (self->format_version != format_v1) { + PyErr_Format(PyExc_RuntimeError, + "version header should go in the docket, not the " + "index: %lu", + header); + return NULL; + } putbe32(header, out); return PyBytes_FromStringAndSize(out, 4); } @@ -378,7 +385,7 @@ data = index_deref(self, rev); if (data == NULL) return NULL; - if (rev == 0) { + if (rev == 0 && self->format_version == format_v1) { /* the header is eating the start of the first entry */ return PyBytes_FromStringAndSize(data + 4, self->entry_size - 4);