diff --git a/mercurial/revlogutils/sidedata.py b/mercurial/revlogutils/sidedata.py --- a/mercurial/revlogutils/sidedata.py +++ b/mercurial/revlogutils/sidedata.py @@ -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 --git a/tests/test-sidedata.t b/tests/test-sidedata.t --- a/tests/test-sidedata.t +++ b/tests/test-sidedata.t @@ -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 --git a/tests/testlib/ext-sidedata.py b/tests/testlib/ext-sidedata.py new file mode 100644 --- /dev/null +++ b/tests/testlib/ext-sidedata.py @@ -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)