Mercurial > hg
comparison mercurial/pure/parsers.py @ 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 | 130c9f7ed914 |
comparison
equal
deleted
inserted
replaced
47243:3b04cf976c67 | 47244:78230d036e5d |
---|---|
288 inside the transaction that creates the revision `rev`. | 288 inside the transaction that creates the revision `rev`. |
289 """ | 289 """ |
290 if rev < 0: | 290 if rev < 0: |
291 raise KeyError | 291 raise KeyError |
292 self._check_index(rev) | 292 self._check_index(rev) |
293 sidedata_format = b">Qi" | 293 if rev < self._lgt: |
294 packed_size = struct.calcsize(sidedata_format) | |
295 if rev >= self._lgt: | |
296 packed = _pack(sidedata_format, sidedata_offset, sidedata_length) | |
297 old = self._extra[rev - self._lgt] | |
298 offset_flags = struct.pack(b">Q", offset_flags) | |
299 new = offset_flags + old[8:64] + packed + old[64 + packed_size :] | |
300 self._extra[rev - self._lgt] = new | |
301 else: | |
302 msg = b"cannot rewrite entries outside of this transaction" | 294 msg = b"cannot rewrite entries outside of this transaction" |
303 raise KeyError(msg) | 295 raise KeyError(msg) |
296 else: | |
297 entry = list(self[rev]) | |
298 entry[0] = offset_flags | |
299 entry[8] = sidedata_offset | |
300 entry[9] = sidedata_length | |
301 entry = tuple(entry) | |
302 new = self._pack_entry(entry) | |
303 self._extra[rev - self._lgt] = new | |
304 | 304 |
305 def _unpack_entry(self, data): | 305 def _unpack_entry(self, data): |
306 return self.index_format.unpack(data) | 306 return self.index_format.unpack(data) |
307 | 307 |
308 def _pack_entry(self, entry): | 308 def _pack_entry(self, entry): |