comparison 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
comparison
equal deleted inserted replaced
47077:119790e1c67c 47078:223b47235d1c
266 266
267 class Index2Mixin(object): 267 class Index2Mixin(object):
268 index_format = revlog_constants.INDEX_ENTRY_V2 268 index_format = revlog_constants.INDEX_ENTRY_V2
269 null_item = (0, 0, 0, -1, -1, -1, -1, sha1nodeconstants.nullid, 0, 0) 269 null_item = (0, 0, 0, -1, -1, -1, -1, sha1nodeconstants.nullid, 0, 0)
270 270
271 def replace_sidedata_info(self, i, sidedata_offset, sidedata_length): 271 def replace_sidedata_info(
272 self, i, sidedata_offset, sidedata_length, offset_flags
273 ):
272 """ 274 """
273 Replace an existing index entry's sidedata offset and length with new 275 Replace an existing index entry's sidedata offset and length with new
274 ones. 276 ones.
275 This cannot be used outside of the context of sidedata rewriting, 277 This cannot be used outside of the context of sidedata rewriting,
276 inside the transaction that creates the revision `i`. 278 inside the transaction that creates the revision `i`.
281 sidedata_format = b">Qi" 283 sidedata_format = b">Qi"
282 packed_size = struct.calcsize(sidedata_format) 284 packed_size = struct.calcsize(sidedata_format)
283 if i >= self._lgt: 285 if i >= self._lgt:
284 packed = _pack(sidedata_format, sidedata_offset, sidedata_length) 286 packed = _pack(sidedata_format, sidedata_offset, sidedata_length)
285 old = self._extra[i - self._lgt] 287 old = self._extra[i - self._lgt]
286 new = old[:64] + packed + old[64 + packed_size :] 288 offset_flags = struct.pack(b">Q", offset_flags)
289 new = offset_flags + old[8:64] + packed + old[64 + packed_size :]
287 self._extra[i - self._lgt] = new 290 self._extra[i - self._lgt] = new
288 else: 291 else:
289 msg = b"cannot rewrite entries outside of this transaction" 292 msg = b"cannot rewrite entries outside of this transaction"
290 raise KeyError(msg) 293 raise KeyError(msg)
291 294