revlog: simplify entry update logic in `rewrite_sidedata`
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 03 May 2021 23:45:05 +0200
changeset 47256 de63be070e02
parent 47255 78230d036e5d
child 47257 02a4463565ea
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
mercurial/revlog.py
--- 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