revlog: simplify entry update logic in `rewrite_sidedata`
We don't need to rebuild the full entry. So lets just gather the data we need
to pass to `replace_sidedata_info`.
Differential Revision: https://phab.mercurial-scm.org/D10642
--- a/mercurial/revlog.py Tue May 04 00:02:48 2021 +0200
+++ b/mercurial/revlog.py Mon May 03 23:45:05 2021 +0200
@@ -3240,13 +3240,16 @@
# Apply (potential) flags to add and to remove after running
# the sidedata helpers
new_offset_flags = entry[0] | flags[0] & ~flags[1]
- entry = (new_offset_flags,) + entry[1:8]
- entry += (current_offset, len(serialized_sidedata))
+ entry_update = (
+ current_offset,
+ len(serialized_sidedata),
+ new_offset_flags,
+ )
# the sidedata computation might have move the file cursors around
dfh.seek(current_offset, os.SEEK_SET)
dfh.write(serialized_sidedata)
- new_entries.append(entry)
+ new_entries.append(entry_update)
current_offset += len(serialized_sidedata)
if self._docket is not None:
self._docket.data_end = dfh.tell()
@@ -3255,7 +3258,7 @@
ifh.seek(startrev * self.index.entry_size)
for i, e in enumerate(new_entries):
rev = startrev + i
- self.index.replace_sidedata_info(rev, e[8], e[9], e[0])
+ self.index.replace_sidedata_info(rev, *e)
packed = self.index.entry_binary(rev)
if rev == 0 and self._docket is None:
header = self._format_flags | self._format_version