diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c +++ b/mercurial/cext/revlog.c @@ -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); diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -1150,7 +1150,6 @@ ) # "out of experimental" todo list. # -# * stop storing version information in the index (it is already in the docket) # * properly hide uncommitted content to other process # * expose transaction content hooks during pre-commit validation # * include management of a persistent nodemap in the main docket diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py +++ b/mercurial/pure/parsers.py @@ -15,6 +15,7 @@ sha1nodeconstants, ) from .. import ( + error, pycompat, util, ) @@ -311,10 +312,14 @@ """return the raw binary string representing a revision""" entry = self[rev] p = revlog_constants.INDEX_ENTRY_V2.pack(*entry) - if rev == 0: - p = p[revlog_constants.INDEX_HEADER.size :] return p + def pack_header(self, header): + """pack header information as binary""" + msg = 'version header should go in the docket, not the index: %d' + msg %= header + raise error.ProgrammingError(msg) + class IndexObject2(Index2Mixin, IndexObject): pass diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -2017,7 +2017,7 @@ self._inline = False for i in self: e = self.index.entry_binary(i) - if i == 0: + if i == 0 and self._docket is None: header = self._format_flags | self._format_version header = self.index.pack_header(header) e = header + e @@ -2380,7 +2380,7 @@ self.index.append(e) entry = self.index.entry_binary(curr) - if curr == 0: + if curr == 0 and self._docket is None: header = self._format_flags | self._format_version header = self.index.pack_header(header) entry = header + entry @@ -3207,7 +3207,7 @@ rev = startrev + i self.index.replace_sidedata_info(rev, e[8], e[9], e[0]) packed = self.index.entry_binary(rev) - if rev == 0: + if rev == 0 and self._docket is None: header = self._format_flags | self._format_version header = self.index.pack_header(header) packed = header + packed