comparison mercurial/metadata.py @ 45571:7543b5072e84

sidedata: add a `decode_files_sidedata` function Right now the function mostly gather existing code to build a consistent object. However having this function allow us prepare all user code independently from the actual side data format change (and associated encoding/decoding changes) Strictly speaking, we could not need to passe the sidedata explicitly since we have access to it though the `changelogrevision` object. However, the short term goal is to drop that first parameter to only pass the sidedata binaries.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 23 Sep 2020 15:13:44 +0200
parents 64d18e9e8508
children 3d5b2b8e93fd
comparison
equal deleted inserted replaced
45570:9a3563b46f52 45571:7543b5072e84
340 if not sidedata: 340 if not sidedata:
341 sidedata = None 341 sidedata = None
342 return sidedata 342 return sidedata
343 343
344 344
345 def decode_files_sidedata(changelogrevision, sidedata):
346 """Return a ChangingFiles instance from a changelogrevision using sidata
347 """
348 touched = changelogrevision.files
349
350 rawindices = sidedata.get(sidedatamod.SD_FILESADDED)
351 added = decodefileindices(touched, rawindices)
352
353 rawindices = sidedata.get(sidedatamod.SD_FILESREMOVED)
354 removed = decodefileindices(touched, rawindices)
355
356 rawcopies = sidedata.get(sidedatamod.SD_P1COPIES)
357 p1_copies = decodecopies(touched, rawcopies)
358
359 rawcopies = sidedata.get(sidedatamod.SD_P2COPIES)
360 p2_copies = decodecopies(touched, rawcopies)
361
362 return ChangingFiles(
363 touched=touched,
364 added=added,
365 removed=removed,
366 p1_copies=p1_copies,
367 p2_copies=p2_copies,
368 )
369
370
345 def _getsidedata(srcrepo, rev): 371 def _getsidedata(srcrepo, rev):
346 ctx = srcrepo[rev] 372 ctx = srcrepo[rev]
347 filescopies = computechangesetcopies(ctx) 373 filescopies = computechangesetcopies(ctx)
348 filesadded = computechangesetfilesadded(ctx) 374 filesadded = computechangesetfilesadded(ctx)
349 filesremoved = computechangesetfilesremoved(ctx) 375 filesremoved = computechangesetfilesremoved(ctx)