diff mercurial/cext/revlog.c @ 47235:6b1eae313b2f

revlogv2: store version information in the docket only Having it duplicated in the index was both useless and a risk of discrepancy. Differential Revision: https://phab.mercurial-scm.org/D10625
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 03 May 2021 12:34:21 +0200
parents 47ffc754989a
children 130c9f7ed914
line wrap: on
line diff
--- 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);