Mercurial > hg
diff mercurial/pure/parsers.py @ 46717:502e795b55ac
revlog-index: add `replace_sidedata_info` method
During a `pull` operation where the server does not provide sidedata, the client
that requires it should generate them on-the-fly. In the generic case, we need
to wait for the changelog + manifests + filelogs to be added, since we don't
know what the sidedata computers might need: this means rewriting the sidedata
of index entries from within the pull transaction (and no further back) right
after we've added them.
Both Python and C implementations only allow for rewriting the sidedata offset
and length for revs within the transaction where they were created.
Differential Revision: https://phab.mercurial-scm.org/D10031
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 15 Feb 2021 11:08:28 +0100 |
parents | 913485776542 |
children | d4ba4d51f85f |
line wrap: on
line diff
--- a/mercurial/pure/parsers.py Fri Feb 19 11:04:17 2021 +0100 +++ b/mercurial/pure/parsers.py Mon Feb 15 11:08:28 2021 +0100 @@ -259,6 +259,27 @@ assert index_size == 96, index_size null_item = (0, 0, 0, -1, -1, -1, -1, nullid, 0, 0) + def replace_sidedata_info(self, i, sidedata_offset, sidedata_length): + """ + Replace an existing index entry's sidedata offset and length with new + ones. + This cannot be used outside of the context of sidedata rewriting, + inside the transaction that creates the revision `i`. + """ + if i < 0: + raise KeyError + self._check_index(i) + sidedata_format = b">Qi" + packed_size = struct.calcsize(sidedata_format) + if i >= self._lgt: + packed = _pack(sidedata_format, sidedata_offset, sidedata_length) + old = self._extra[i - self._lgt] + new = old[:64] + packed + old[64 + packed_size :] + self._extra[i - self._lgt] = new + else: + msg = b"cannot rewrite entries outside of this transaction" + raise KeyError(msg) + class IndexObject2(Index2Mixin, IndexObject): pass