Skip to content
Snippets Groups Projects
Commit ea83abf95630 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

sidedata: add a function to write sidedata into a raw text

Differential Revision: https://phab.mercurial-scm.org/D6891
parent 294afb982a88
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment