# HG changeset patch # User Pierre-Yves David <pierre-yves.david@octobus.net> # Date 1567552854 -7200 # Wed Sep 04 01:20:54 2019 +0200 # Node ID ea83abf9563008196e960141d2ed47ba87eefb1a # Parent 294afb982a8834db6d97cd2cefea5d643024285b sidedata: add a function to write sidedata into a raw text Differential Revision: https://phab.mercurial-scm.org/D6891 diff --git a/mercurial/revlogutils/sidedata.py b/mercurial/revlogutils/sidedata.py --- a/mercurial/revlogutils/sidedata.py +++ b/mercurial/revlogutils/sidedata.py @@ -41,6 +41,18 @@ SIDEDATA_HEADER = struct.Struct('>H') SIDEDATA_ENTRY = struct.Struct('>HL20s') +def sidedatawriteprocessor(rl, text, sidedata): + sidedata = list(sidedata.items()) + sidedata.sort() + rawtext = [SIDEDATA_HEADER.pack(len(sidedata))] + for key, value in sidedata: + digest = hashlib.sha1(value).digest() + rawtext.append(SIDEDATA_ENTRY.pack(key, len(value), digest)) + for key, value in sidedata: + rawtext.append(value) + rawtext.append(bytes(text)) + return ''.join(rawtext), False + def sidedatareadprocessor(rl, text): sidedata = {} offset = 0