Mercurial > hg
changeset 43035:ea83abf95630
sidedata: add a function to write sidedata into a raw text
Differential Revision: https://phab.mercurial-scm.org/D6891
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 04 Sep 2019 01:20:54 +0200 |
parents | 294afb982a88 |
children | e8bc4c3d9a0b |
files | mercurial/revlogutils/sidedata.py |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlogutils/sidedata.py Wed Sep 04 00:59:15 2019 +0200 +++ b/mercurial/revlogutils/sidedata.py Wed Sep 04 01:20:54 2019 +0200 @@ -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