Patchwork D10642: revlog: simplify entry update logic in `rewrite_sidedata`

login
register
mail settings
Submitter phabricator
Date May 4, 2021, 2:18 p.m.
Message ID <differential-rev-PHID-DREV-szbs35ibcll2elsbsxmy-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48963/
State Superseded
Headers show

Comments

phabricator - May 4, 2021, 2:18 p.m.
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We don't need to rebuild the full entry. So lets just gather the data we need
  to pass to `replace_sidedata_info`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10642

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




To: marmoute, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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