# HG changeset patch # User Pierre-Yves David # Date 1568057909 -7200 # Node ID ba4072c0a91102ef6f2f25277832ce662bd0f5c1 # Parent 7902001aaf41e6022131b46781866a72719ae325 sidedata: test we can successfully write sidedata For now we just write them and rejoice on the lack of crashes. Differential Revision: https://phab.mercurial-scm.org/D6896 diff -r 7902001aaf41 -r ba4072c0a911 mercurial/revlogutils/sidedata.py --- a/mercurial/revlogutils/sidedata.py Fri Sep 27 16:40:07 2019 +0200 +++ b/mercurial/revlogutils/sidedata.py Mon Sep 09 21:38:29 2019 +0200 @@ -38,6 +38,17 @@ from .. import error +## sidedata type constant +# reserve a block for testing purposes. +SD_TEST1 = 1 +SD_TEST2 = 2 +SD_TEST3 = 3 +SD_TEST4 = 4 +SD_TEST5 = 5 +SD_TEST6 = 6 +SD_TEST7 = 7 + +# internal format constant SIDEDATA_HEADER = struct.Struct('>H') SIDEDATA_ENTRY = struct.Struct('>HL20s') diff -r 7902001aaf41 -r ba4072c0a911 tests/test-sidedata.t --- a/tests/test-sidedata.t Fri Sep 27 16:40:07 2019 +0200 +++ b/tests/test-sidedata.t Mon Sep 09 21:38:29 2019 +0200 @@ -2,6 +2,24 @@ Test file dedicated to checking side-data related behavior ========================================================== +Check data can be written/read from sidedata +============================================ + + $ cat << EOF >> $HGRCPATH + > [extensions] + > testsidedata=$TESTDIR/testlib/ext-sidedata.py + > EOF + + $ hg init test-sidedata --config format.use-side-data=yes + $ cd test-sidedata + $ echo aaa > a + $ hg add a + $ hg commit -m a --traceback + $ echo aaa > b + $ hg add b + $ hg commit -m b + $ echo xxx >> a + $ hg commit -m aa Check upgrade behavior ====================== diff -r 7902001aaf41 -r ba4072c0a911 tests/testlib/ext-sidedata.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/testlib/ext-sidedata.py Mon Sep 09 21:38:29 2019 +0200 @@ -0,0 +1,36 @@ +# ext-sidedata.py - small extension to test the sidedata logic +# +# Copyright 2019 Pierre-Yves David I', len(text)) + # and sha2 hashes + sha256 = hashlib.sha256(text).digest() + sd[sidedata.SD_TEST2] = struct.pack('>32s', sha256) + return orig(self, text, transaction, link, p1, p2, *args, **kwargs) + +def extsetup(ui): + extensions.wrapfunction(revlog.revlog, 'addrevision', wrapaddrevision)