# HG changeset patch # User Joerg Sonnenberger # Date 2020-12-12 23:19:03 # Node ID 84130fd74a223039a1af6876823b820270881eee # Parent c000eff2c6353e1418007632b23f147caf47b8b8 revlog: support none compression revlog files had uncompressed revlog entries support since forever, but it wasn't selectable or exposed explicitly. It is occassionally useful for performance testing as it avoids the latency of zlib or zstd. It also has the nice side effect of providing a non-default compression engine out-of-the-box. Differential Revision: https://phab.mercurial-scm.org/D9572 diff --git a/mercurial/utils/compression.py b/mercurial/utils/compression.py --- a/mercurial/utils/compression.py +++ b/mercurial/utils/compression.py @@ -617,8 +617,10 @@ class _noopengine(compressionengine): def wireprotosupport(self): return compewireprotosupport(b'none', 0, 10) - # We don't implement revlogheader because it is handled specially - # in the revlog class. + # revlog special cases the uncompressed case, but implementing + # revlogheader allows forcing uncompressed storage. + def revlogheader(self): + return b'\0' def compressstream(self, it, opts=None): return it diff --git a/tests/test-repo-compengines.t b/tests/test-repo-compengines.t --- a/tests/test-repo-compengines.t +++ b/tests/test-repo-compengines.t @@ -43,6 +43,27 @@ A requirement specifying an unknown comp $ cd .. +Specifying a new format.compression on an existing repo won't introduce data +with that engine or a requirement + + $ cd default + $ touch bar + $ hg --config format.revlog-compression=none -q commit -A -m 'add bar with a lot of repeated repeated repeated text' + + $ cat .hg/requires + dotencode + fncache + generaldelta + revlogv1 + sparserevlog + store + testonly-simplestore (reposimplestore !) + + $ hg debugrevlog -c | grep 0x78 + 0x78 (x) : 2 (100.00%) + 0x78 (x) : 199 (100.00%) + $ cd .. + #if zstd $ hg --config format.revlog-compression=zstd init zstd @@ -66,25 +87,6 @@ A requirement specifying an unknown comp $ cd .. -Specifying a new format.compression on an existing repo won't introduce data -with that engine or a requirement - - $ cd default - $ touch bar - $ hg --config format.revlog-compression=zstd -q commit -A -m 'add bar with a lot of repeated repeated repeated text' - - $ cat .hg/requires - dotencode - fncache - generaldelta - revlogv1 - sparserevlog - store - testonly-simplestore (reposimplestore !) - - $ hg debugrevlog -c | grep 0x78 - 0x78 (x) : 2 (100.00%) - 0x78 (x) : 199 (100.00%) #endif @@ -116,10 +118,12 @@ checking zlib options > done $ $RUNTESTDIR/f -s */.hg/store/data/* - default/.hg/store/data/foo.i: size=64 (pure !) + default/.hg/store/data/bar.i: size=64 + default/.hg/store/data/foo.i: size=64 zlib-level-1/.hg/store/data/a.i: size=4146 zlib-level-9/.hg/store/data/a.i: size=4138 zlib-level-default/.hg/store/data/a.i: size=4138 + zstd/.hg/store/data/foo.i: size=64 (zstd !) Test error cases @@ -144,6 +148,41 @@ Test error cases abort: invalid value for `storage.revlog.zlib.level` config: 42 [255] +checking details of none compression +==================================== + + $ hg init none-compression --config format.revlog-compression=none + + $ commitone() { + > repo=$1 + > cp $RUNTESTDIR/bundles/issue4438-r1.hg $repo/a + > hg -R $repo add $repo/a + > hg -R $repo commit -m some-commit + > } + + $ commitone none-compression + + $ hg log -R none-compression + changeset: 0:68b53da39cd8 + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: some-commit + + + $ cat none-compression/.hg/requires + dotencode + exp-compression-none + fncache + generaldelta + revlogv1 + sparserevlog + store + testonly-simplestore (reposimplestore !) + + $ $RUNTESTDIR/f -s none-compression/.hg/store/data/* + none-compression/.hg/store/data/a.i: size=4216 + #if zstd checking zstd options