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

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Fri Sep 27 12:17:06 EDT 2019


marmoute created this revision.
marmoute added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6891

AFFECTED FILES
  mercurial/revlogutils/sidedata.py

CHANGE DETAILS

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



To: marmoute, durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list