Debian Codegraph @

tests/test-repo-compengines.t

raw
1 Check control over zstd import
2
3 #if zstd
4 $ hg debuginstall | grep "checking available compression engines" | grep zstd | f --line-count
5 line-count=2
6
7 $ HGZSTDPOLICY=none hg debuginstall | grep "checking available compression engines" | grep zstd | f --line-count
8 line-count=0
9 #else
10 $ hg debuginstall | grep "checking available compression engines" | grep zstd | f --line-count
11 line-count=0
12 $ HGZSTDPOLICY=vendored hg debuginstall >/dev/null
13 abort: cannot import name 'zstd' from 'mercurial' (*/mercurial/__init__.py) (glob)
14 [255]
15 #endif
16
17
18 A new repository uses zlib storage, which doesn't need a requirement
19
20 $ cat << EOF >> $HGRCPATH
21 > [format]
22 > # stabilize test accross variant
23 > revlog-compression=zlib
24 > EOF
25
26
27 $ hg init default
28 $ cd default
29 $ hg debugrequires | grep compression
30 [1]
31
32 $ touch foo
33 $ hg -q commit -A -m 'initial commit with a lot of repeated repeated repeated text to trigger compression'
34 $ hg debugrevlog -c | grep 0x78
35 0x78 (x) : 1 (100.00%)
36 0x78 (x) : 110 (100.00%)
37
38 $ cd ..
39
40 Unknown compression engine to format.compression aborts
41
42 $ hg --config format.revlog-compression=unknown init unknown
43 abort: compression engines "unknown" defined by format.revlog-compression not available
44 (run "hg debuginstall" to list available compression engines)
45 [255]
46
47 unknown compression engine in a list with known one works fine
48
49 $ hg --config format.revlog-compression=zlib,unknown init zlib-before-unknow
50 $ hg --config format.revlog-compression=unknown,zlib init unknown-before-zlib
51
52 A requirement specifying an unknown compression engine results in bail
53
54 $ hg init unknownrequirement
55 $ cd unknownrequirement
56 $ echo exp-compression-unknown >> .hg/requires
57 $ hg log
58 abort: repository requires features unknown to this Mercurial: exp-compression-unknown
59 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
60 [255]
61
62 $ cd ..
63
64 Specifying a new format.compression on an existing repo won't introduce data
65 with that engine or a requirement
66
67 $ cd default
68 $ touch bar
69 $ hg --config format.revlog-compression=none -q commit -A -m 'add bar with a lot of repeated repeated repeated text'
70
71 $ hg debugrequires | grep compression
72 [1]
73
74 $ hg debugrevlog -c | grep 0x78
75 0x78 (x) : 2 (100.00%)
76 0x78 (x) : 199 (100.00%)
77 $ cd ..
78
79 #if zstd
80
81 $ hg --config format.revlog-compression=zstd init zstd
82 $ cd zstd
83 $ hg debugrequires | grep compression
84 revlog-compression-zstd
85
86 $ touch foo
87 $ hg -q commit -A -m 'initial commit with a lot of repeated repeated repeated text'
88
89 $ hg debugrevlog -c | grep 0x28
90 0x28 : 1 (100.00%)
91 0x28 : 98 (100.00%)
92
93 $ cd ..
94
95
96 #endif
97
98 checking zlib options
99 =====================
100
101 $ hg init zlib-level-default
102 $ hg init zlib-level-1
103 $ cat << EOF >> zlib-level-1/.hg/hgrc
104 > [storage]
105 > revlog.zlib.level=1
106 > EOF
107 $ hg init zlib-level-9
108 $ cat << EOF >> zlib-level-9/.hg/hgrc
109 > [storage]
110 > revlog.zlib.level=9
111 > EOF
112
113
114 $ commitone() {
115 > repo=$1
116 > cp $RUNTESTDIR/bundles/issue4438-r1.hg $repo/a
117 > hg -R $repo add $repo/a
118 > hg -R $repo commit -m some-commit
119 > }
120
121 $ for repo in zlib-level-default zlib-level-1 zlib-level-9; do
122 > commitone $repo
123 > done
124
125 $ $RUNTESTDIR/f -s */.hg/store/data/*
126 default/.hg/store/data/bar.i: size=64
127 default/.hg/store/data/foo.i: size=64
128 zlib-level-1/.hg/store/data/a.i: size=4146
129 zlib-level-9/.hg/store/data/a.i: size=4138
130 zlib-level-default/.hg/store/data/a.i: size=4138
131 zstd/.hg/store/data/foo.i: size=64 (zstd !)
132
133 Test error cases
134
135 $ hg init zlib-level-invalid
136 $ cat << EOF >> zlib-level-invalid/.hg/hgrc
137 > [storage]
138 > revlog.zlib.level=foobar
139 > EOF
140 $ commitone zlib-level-invalid
141 config error: storage.revlog.zlib.level is not a valid integer ('foobar')
142 config error: storage.revlog.zlib.level is not a valid integer ('foobar')
143 [30]
144
145 $ hg init zlib-level-out-of-range
146 $ cat << EOF >> zlib-level-out-of-range/.hg/hgrc
147 > [storage]
148 > revlog.zlib.level=42
149 > EOF
150
151 $ commitone zlib-level-out-of-range
152 abort: invalid value for `storage.revlog.zlib.level` config: 42
153 abort: invalid value for `storage.revlog.zlib.level` config: 42
154 [255]
155
156 checking details of none compression
157 ====================================
158
159 $ hg init none-compression --config format.revlog-compression=none
160
161 $ commitone() {
162 > repo=$1
163 > cp $RUNTESTDIR/bundles/issue4438-r1.hg $repo/a
164 > hg -R $repo add $repo/a
165 > hg -R $repo commit -m some-commit
166 > }
167
168 $ commitone none-compression
169
170 $ hg log -R none-compression
171 changeset: 0:68b53da39cd8
172 tag: tip
173 user: test
174 date: Thu Jan 01 00:00:00 1970 +0000
175 summary: some-commit
176
177
178 $ hg debugrequires -R none-compression/ | grep compression
179 exp-compression-none
180
181 $ $RUNTESTDIR/f -s none-compression/.hg/store/data/*
182 none-compression/.hg/store/data/a.i: size=4216
183
184 #if zstd
185
186 checking zstd options
187 =====================
188
189 $ hg init zstd-level-default --config format.revlog-compression=zstd
190 $ hg init zstd-level-1 --config format.revlog-compression=zstd
191 $ cat << EOF >> zstd-level-1/.hg/hgrc
192 > [storage]
193 > revlog.zstd.level=1
194 > EOF
195 $ hg init zstd-level-22 --config format.revlog-compression=zstd
196 $ cat << EOF >> zstd-level-22/.hg/hgrc
197 > [storage]
198 > revlog.zstd.level=22
199 > EOF
200
201
202 $ commitone() {
203 > repo=$1
204 > cp $RUNTESTDIR/bundles/issue4438-r1.hg $repo/a
205 > hg -R $repo add $repo/a
206 > hg -R $repo commit -m some-commit
207 > }
208
209 $ for repo in zstd-level-default zstd-level-1 zstd-level-22; do
210 > commitone $repo
211 > done
212
213 $ $RUNTESTDIR/f -s zstd-*/.hg/store/data/*
214 zstd-level-1/.hg/store/data/a.i: size=4112
215 zstd-level-22/.hg/store/data/a.i: size=4091
216 zstd-level-default/.hg/store/data/a.i: size=4097
217
218 Test error cases
219
220 $ hg init zstd-level-invalid --config format.revlog-compression=zstd
221 $ cat << EOF >> zstd-level-invalid/.hg/hgrc
222 > [storage]
223 > revlog.zstd.level=foobar
224 > EOF
225 $ commitone zstd-level-invalid
226 config error: storage.revlog.zstd.level is not a valid integer ('foobar')
227 config error: storage.revlog.zstd.level is not a valid integer ('foobar')
228 [30]
229
230 $ hg init zstd-level-out-of-range --config format.revlog-compression=zstd
231 $ cat << EOF >> zstd-level-out-of-range/.hg/hgrc
232 > [storage]
233 > revlog.zstd.level=42
234 > EOF
235
236 $ commitone zstd-level-out-of-range
237 abort: invalid value for `storage.revlog.zstd.level` config: 42
238 abort: invalid value for `storage.revlog.zstd.level` config: 42
239 [255]
240
241 #endif