diff mercurial/pure/parsers.py @ 47078:223b47235d1c

sidedata: enable sidedata computers to optionally rewrite flags Sidedata computers may want to influence the flags of the revision they touch. For example, the computer for changelog-based copytracing can add a flag to signify that this revision might affect copytracing, inversely removing said flag if the information is no longer applicable. See inline documentation in `storageutil` for more details. Differential Revision: https://phab.mercurial-scm.org/D10344
author Raphaël Gomès <rgomes@octobus.net>
date Thu, 08 Apr 2021 16:55:17 +0200
parents d57386e5c80e
children 4292bed8da7c
line wrap: on
line diff
--- a/mercurial/pure/parsers.py	Sat Apr 10 11:27:40 2021 +0200
+++ b/mercurial/pure/parsers.py	Thu Apr 08 16:55:17 2021 +0200
@@ -268,7 +268,9 @@
     index_format = revlog_constants.INDEX_ENTRY_V2
     null_item = (0, 0, 0, -1, -1, -1, -1, sha1nodeconstants.nullid, 0, 0)
 
-    def replace_sidedata_info(self, i, sidedata_offset, sidedata_length):
+    def replace_sidedata_info(
+        self, i, sidedata_offset, sidedata_length, offset_flags
+    ):
         """
         Replace an existing index entry's sidedata offset and length with new
         ones.
@@ -283,7 +285,8 @@
         if i >= self._lgt:
             packed = _pack(sidedata_format, sidedata_offset, sidedata_length)
             old = self._extra[i - self._lgt]
-            new = old[:64] + packed + old[64 + packed_size :]
+            offset_flags = struct.pack(b">Q", offset_flags)
+            new = offset_flags + old[8:64] + packed + old[64 + packed_size :]
             self._extra[i - self._lgt] = new
         else:
             msg = b"cannot rewrite entries outside of this transaction"