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

login
register
mail settings
Submitter phabricator
Date Oct. 1, 2019, 6:22 p.m.
Message ID <0d7cad82749095df76f0fd8fd90a895d@localhost.localdomain>
Download mbox | patch
Permalink /patch/41912/
State Not Applicable
Headers show

Comments

phabricator - Oct. 1, 2019, 6:22 p.m.
Closed by commit rHGea83abf95630: sidedata: add a function to write sidedata into a raw text (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6891?vs=16649&id=16763

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6891/new/

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

AFFECTED FILES
  mercurial/revlogutils/sidedata.py

CHANGE DETAILS




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

Patch

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