Mercurial > hg
changeset 47244:78230d036e5d
revlog: simplify the replace_sidedata_info code
We already know how to serialize and de-serialize and enty. So lets just do that
and modify the entry tuple directly.
This avoid having to duplicated binary operation in complicated code.
Differential Revision: https://phab.mercurial-scm.org/D10641
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 04 May 2021 00:02:48 +0200 |
parents | 3b04cf976c67 |
children | de63be070e02 |
files | mercurial/pure/parsers.py |
diffstat | 1 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/pure/parsers.py Mon May 03 23:59:15 2021 +0200 +++ b/mercurial/pure/parsers.py Tue May 04 00:02:48 2021 +0200 @@ -290,17 +290,17 @@ if rev < 0: raise KeyError self._check_index(rev) - sidedata_format = b">Qi" - packed_size = struct.calcsize(sidedata_format) - if rev >= self._lgt: - packed = _pack(sidedata_format, sidedata_offset, sidedata_length) - old = self._extra[rev - self._lgt] - offset_flags = struct.pack(b">Q", offset_flags) - new = offset_flags + old[8:64] + packed + old[64 + packed_size :] - self._extra[rev - self._lgt] = new - else: + if rev < self._lgt: msg = b"cannot rewrite entries outside of this transaction" raise KeyError(msg) + else: + entry = list(self[rev]) + entry[0] = offset_flags + entry[8] = sidedata_offset + entry[9] = sidedata_length + entry = tuple(entry) + new = self._pack_entry(entry) + self._extra[rev - self._lgt] = new def _unpack_entry(self, data): return self.index_format.unpack(data)