##// END OF EJS Templates
tests: make sha256line.py available for all tests...
av6 -
r52254:fa4c4fa2 stable
parent child Browse files
Show More
@@ -0,0 +1,14 b''
1 #!/usr/bin/env python3
2 #
3 # A tool to help producing large and poorly compressible files
4 #
5 # Usage:
6 # $TESTDIR/seq.py 1000 | $TESTDIR/sha256line.py > my-file.txt
7
8
9 import hashlib
10 import sys
11
12
13 for line in sys.stdin:
14 print(hashlib.sha256(line.encode('utf8')).hexdigest())
@@ -1,362 +1,355 b''
1 1 ==========================================================
2 2 Test various things around delta computation within revlog
3 3 ==========================================================
4 4
5 5
6 6 basic setup
7 7 -----------
8 8
9 9 $ cat << EOF >> $HGRCPATH
10 10 > [debug]
11 11 > revlog.debug-delta=yes
12 12 > EOF
13 $ cat << EOF >> sha256line.py
14 > # a way to quickly produce file of significant size and poorly compressable content.
15 > import hashlib
16 > import sys
17 > for line in sys.stdin:
18 > print(hashlib.sha256(line.encode('utf8')).hexdigest())
19 > EOF
20 13
21 14 $ hg init base-repo
22 15 $ cd base-repo
23 16
24 17 create a "large" file
25 18
26 $ $TESTDIR/seq.py 1000 | $PYTHON $TESTTMP/sha256line.py > my-file.txt
19 $ $TESTDIR/seq.py 1000 | $TESTDIR/sha256line.py > my-file.txt
27 20 $ hg add my-file.txt
28 21 $ hg commit -m initial-commit
29 22 DBG-DELTAS: FILELOG:my-file.txt: rev=0: delta-base=0 * (glob)
30 23 DBG-DELTAS: MANIFESTLOG: * (glob)
31 24 DBG-DELTAS: CHANGELOG: * (glob)
32 25
33 26 Add more change at the end of the file
34 27
35 $ $TESTDIR/seq.py 1001 1200 | $PYTHON $TESTTMP/sha256line.py >> my-file.txt
28 $ $TESTDIR/seq.py 1001 1200 | $TESTDIR/sha256line.py >> my-file.txt
36 29 $ hg commit -m "large-change"
37 30 DBG-DELTAS: FILELOG:my-file.txt: rev=1: delta-base=0 * (glob)
38 31 DBG-DELTAS: MANIFESTLOG: * (glob)
39 32 DBG-DELTAS: CHANGELOG: * (glob)
40 33
41 34 Add small change at the start
42 35
43 36 $ hg up 'desc("initial-commit")' --quiet
44 37 $ mv my-file.txt foo
45 38 $ echo "small change at the start" > my-file.txt
46 39 $ cat foo >> my-file.txt
47 40 $ rm foo
48 41 $ hg commit -m "small-change"
49 42 DBG-DELTAS: FILELOG:my-file.txt: rev=2: delta-base=0 * (glob)
50 43 DBG-DELTAS: MANIFESTLOG: * (glob)
51 44 DBG-DELTAS: CHANGELOG: * (glob)
52 45 created new head
53 46
54 47
55 48 $ hg log -r 'head()' -T '{node}\n' >> ../base-heads.nodes
56 49 $ hg log -r 'desc("initial-commit")' -T '{node}\n' >> ../initial.node
57 50 $ hg log -r 'desc("small-change")' -T '{node}\n' >> ../small.node
58 51 $ hg log -r 'desc("large-change")' -T '{node}\n' >> ../large.node
59 52 $ cd ..
60 53
61 54 Check delta find policy and result for merge on commit
62 55 ======================================================
63 56
64 57 Check that delta of merge pick best of the two parents
65 58 ------------------------------------------------------
66 59
67 60 As we check against both parents, the one with the largest change should
68 61 produce the smallest delta and be picked.
69 62
70 63 $ hg clone base-repo test-parents --quiet
71 64 $ hg -R test-parents update 'nodefromfile("small.node")' --quiet
72 65 $ hg -R test-parents merge 'nodefromfile("large.node")' --quiet
73 66
74 67 The delta base is the "large" revision as it produce a smaller delta.
75 68
76 69 $ hg -R test-parents commit -m "merge from small change"
77 70 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=1 * (glob)
78 71 DBG-DELTAS: MANIFESTLOG: * (glob)
79 72 DBG-DELTAS: CHANGELOG: * (glob)
80 73
81 74 Check that the behavior tested above can we disabled
82 75 ----------------------------------------------------
83 76
84 77 We disable the checking of both parent at the same time. The `small` change,
85 78 that produce a less optimal delta, should be picked first as it is "closer" to
86 79 the new commit.
87 80
88 81 $ hg clone base-repo test-no-parents --quiet
89 82 $ hg -R test-no-parents update 'nodefromfile("small.node")' --quiet
90 83 $ hg -R test-no-parents merge 'nodefromfile("large.node")' --quiet
91 84
92 85 The delta base is the "large" revision as it produce a smaller delta.
93 86
94 87 $ hg -R test-no-parents commit -m "merge from small change" \
95 88 > --config storage.revlog.optimize-delta-parent-choice=no
96 89 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
97 90 DBG-DELTAS: MANIFESTLOG: * (glob)
98 91 DBG-DELTAS: CHANGELOG: * (glob)
99 92
100 93
101 94 Check delta-find policy and result when unbundling
102 95 ==================================================
103 96
104 97 Build a bundle with all delta built against p1
105 98
106 99 $ hg bundle -R test-parents --all --config devel.bundle.delta=p1 all-p1.hg
107 100 4 changesets found
108 101
109 102 Default policy of trusting delta from the bundle
110 103 ------------------------------------------------
111 104
112 105 Keeping the `p1` delta used in the bundle is sub-optimal for storage, but
113 106 strusting in-bundle delta is faster to apply.
114 107
115 108 $ hg init bundle-default
116 109 $ hg -R bundle-default unbundle all-p1.hg --quiet
117 110 DBG-DELTAS: CHANGELOG: * (glob)
118 111 DBG-DELTAS: CHANGELOG: * (glob)
119 112 DBG-DELTAS: CHANGELOG: * (glob)
120 113 DBG-DELTAS: CHANGELOG: * (glob)
121 114 DBG-DELTAS: MANIFESTLOG: * (glob)
122 115 DBG-DELTAS: MANIFESTLOG: * (glob)
123 116 DBG-DELTAS: MANIFESTLOG: * (glob)
124 117 DBG-DELTAS: MANIFESTLOG: * (glob)
125 118 DBG-DELTAS: FILELOG:my-file.txt: rev=0: delta-base=0 * (glob)
126 119 DBG-DELTAS: FILELOG:my-file.txt: rev=1: delta-base=0 * (glob)
127 120 DBG-DELTAS: FILELOG:my-file.txt: rev=2: delta-base=0 * (glob)
128 121 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
129 122
130 123 (confirm the file revision are in the same order, 2 should be smaller than 1)
131 124
132 125 $ hg -R bundle-default debugdata my-file.txt 2 | wc -l
133 126 \s*1001 (re)
134 127 $ hg -R bundle-default debugdata my-file.txt 1 | wc -l
135 128 \s*1200 (re)
136 129
137 130 explicitly enabled
138 131 ------------------
139 132
140 133 Keeping the `p1` delta used in the bundle is sub-optimal for storage, but
141 134 strusting in-bundle delta is faster to apply.
142 135
143 136 $ hg init bundle-reuse-enabled
144 137 $ hg -R bundle-reuse-enabled unbundle all-p1.hg --quiet \
145 138 > --config storage.revlog.reuse-external-delta-parent=yes
146 139 DBG-DELTAS: CHANGELOG: * (glob)
147 140 DBG-DELTAS: CHANGELOG: * (glob)
148 141 DBG-DELTAS: CHANGELOG: * (glob)
149 142 DBG-DELTAS: CHANGELOG: * (glob)
150 143 DBG-DELTAS: MANIFESTLOG: * (glob)
151 144 DBG-DELTAS: MANIFESTLOG: * (glob)
152 145 DBG-DELTAS: MANIFESTLOG: * (glob)
153 146 DBG-DELTAS: MANIFESTLOG: * (glob)
154 147 DBG-DELTAS: FILELOG:my-file.txt: rev=0: delta-base=0 * (glob)
155 148 DBG-DELTAS: FILELOG:my-file.txt: rev=1: delta-base=0 * (glob)
156 149 DBG-DELTAS: FILELOG:my-file.txt: rev=2: delta-base=0 * (glob)
157 150 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
158 151
159 152 (confirm the file revision are in the same order, 2 should be smaller than 1)
160 153
161 154 $ hg -R bundle-reuse-enabled debugdata my-file.txt 2 | wc -l
162 155 \s*1001 (re)
163 156 $ hg -R bundle-reuse-enabled debugdata my-file.txt 1 | wc -l
164 157 \s*1200 (re)
165 158
166 159 explicitly disabled
167 160 -------------------
168 161
169 162 Not reusing the delta-base from the parent means we the delta will be made
170 163 against the "best" parent. (so not the same as the previous two)
171 164
172 165 $ hg init bundle-reuse-disabled
173 166 $ hg -R bundle-reuse-disabled unbundle all-p1.hg --quiet \
174 167 > --config storage.revlog.reuse-external-delta-parent=no
175 168 DBG-DELTAS: CHANGELOG: * (glob)
176 169 DBG-DELTAS: CHANGELOG: * (glob)
177 170 DBG-DELTAS: CHANGELOG: * (glob)
178 171 DBG-DELTAS: CHANGELOG: * (glob)
179 172 DBG-DELTAS: MANIFESTLOG: * (glob)
180 173 DBG-DELTAS: MANIFESTLOG: * (glob)
181 174 DBG-DELTAS: MANIFESTLOG: * (glob)
182 175 DBG-DELTAS: MANIFESTLOG: * (glob)
183 176 DBG-DELTAS: FILELOG:my-file.txt: rev=0: delta-base=0 * (glob)
184 177 DBG-DELTAS: FILELOG:my-file.txt: rev=1: delta-base=0 * (glob)
185 178 DBG-DELTAS: FILELOG:my-file.txt: rev=2: delta-base=0 * (glob)
186 179 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=1 * (glob)
187 180
188 181 (confirm the file revision are in the same order, 2 should be smaller than 1)
189 182
190 183 $ hg -R bundle-reuse-disabled debugdata my-file.txt 2 | wc -l
191 184 \s*1001 (re)
192 185 $ hg -R bundle-reuse-disabled debugdata my-file.txt 1 | wc -l
193 186 \s*1200 (re)
194 187
195 188
196 189 Check the path.*:pulled-delta-reuse-policy option
197 190 ==========================================
198 191
199 192 Get a repository with the bad parent picked and a clone ready to pull the merge
200 193
201 194 $ cp -aR bundle-reuse-enabled peer-bad-delta
202 195 $ hg clone peer-bad-delta local-pre-pull --rev `cat large.node` --rev `cat small.node` --quiet
203 196 DBG-DELTAS: CHANGELOG: * (glob)
204 197 DBG-DELTAS: CHANGELOG: * (glob)
205 198 DBG-DELTAS: CHANGELOG: * (glob)
206 199 DBG-DELTAS: MANIFESTLOG: * (glob)
207 200 DBG-DELTAS: MANIFESTLOG: * (glob)
208 201 DBG-DELTAS: MANIFESTLOG: * (glob)
209 202 DBG-DELTAS: FILELOG:my-file.txt: rev=0: delta-base=0 * (glob)
210 203 DBG-DELTAS: FILELOG:my-file.txt: rev=1: delta-base=0 * (glob)
211 204 DBG-DELTAS: FILELOG:my-file.txt: rev=2: delta-base=0 * (glob)
212 205
213 206 Check the parent order for the file
214 207
215 208 $ hg -R local-pre-pull debugdata my-file.txt 2 | wc -l
216 209 \s*1001 (re)
217 210 $ hg -R local-pre-pull debugdata my-file.txt 1 | wc -l
218 211 \s*1200 (re)
219 212
220 213 Pull with no value (so the default)
221 214 -----------------------------------
222 215
223 216 default is to reuse the (bad) delta
224 217
225 218 $ cp -aR local-pre-pull local-no-value
226 219 $ hg -R local-no-value pull --quiet
227 220 DBG-DELTAS: CHANGELOG: * (glob)
228 221 DBG-DELTAS: MANIFESTLOG: * (glob)
229 222 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
230 223
231 224 Pull with explicitly the default
232 225 --------------------------------
233 226
234 227 default is to reuse the (bad) delta
235 228
236 229 $ cp -aR local-pre-pull local-default
237 230 $ hg -R local-default pull --quiet --config 'paths.default:pulled-delta-reuse-policy=default'
238 231 DBG-DELTAS: CHANGELOG: * (glob)
239 232 DBG-DELTAS: MANIFESTLOG: * (glob)
240 233 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
241 234
242 235 Pull with no-reuse
243 236 ------------------
244 237
245 238 We don't reuse the base, so we get a better delta
246 239
247 240 $ cp -aR local-pre-pull local-no-reuse
248 241 $ hg -R local-no-reuse pull --quiet --config 'paths.default:pulled-delta-reuse-policy=no-reuse'
249 242 DBG-DELTAS: CHANGELOG: * (glob)
250 243 DBG-DELTAS: MANIFESTLOG: * (glob)
251 244 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=1 * (glob)
252 245
253 246 Pull with try-base
254 247 ------------------
255 248
256 249 We requested to use the (bad) delta
257 250
258 251 $ cp -aR local-pre-pull local-try-base
259 252 $ hg -R local-try-base pull --quiet --config 'paths.default:pulled-delta-reuse-policy=try-base'
260 253 DBG-DELTAS: CHANGELOG: * (glob)
261 254 DBG-DELTAS: MANIFESTLOG: * (glob)
262 255 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
263 256
264 257 Case where we force a "bad" delta to be applied
265 258 ===============================================
266 259
267 260 We build a very different file content to force a full snapshot
268 261
269 262 $ cp -aR peer-bad-delta peer-bad-delta-with-full
270 263 $ cp -aR local-pre-pull local-pre-pull-full
271 264 $ echo '[paths]' >> local-pre-pull-full/.hg/hgrc
272 265 $ echo 'default=../peer-bad-delta-with-full' >> local-pre-pull-full/.hg/hgrc
273 266
274 267 $ hg -R peer-bad-delta-with-full update 'desc("merge")' --quiet
275 268 $ ($TESTDIR/seq.py 2000 2100; $TESTDIR/seq.py 500 510; $TESTDIR/seq.py 3000 3050) \
276 > | $PYTHON $TESTTMP/sha256line.py > peer-bad-delta-with-full/my-file.txt
269 > | $TESTDIR/sha256line.py > peer-bad-delta-with-full/my-file.txt
277 270 $ hg -R peer-bad-delta-with-full commit -m 'trigger-full'
278 271 DBG-DELTAS: FILELOG:my-file.txt: rev=4: delta-base=4 * (glob)
279 272 DBG-DELTAS: MANIFESTLOG: * (glob)
280 273 DBG-DELTAS: CHANGELOG: * (glob)
281 274
282 275 Check that "try-base" behavior challenge the delta
283 276 --------------------------------------------------
284 277
285 278 The bundling process creates a delta against the previous revision, however this
286 279 is an invalid chain for the client, so it is not considered and we do a full
287 280 snapshot again.
288 281
289 282 $ cp -aR local-pre-pull-full local-try-base-full
290 283 $ hg -R local-try-base-full pull --quiet \
291 284 > --config 'paths.default:pulled-delta-reuse-policy=try-base'
292 285 DBG-DELTAS: CHANGELOG: * (glob)
293 286 DBG-DELTAS: CHANGELOG: * (glob)
294 287 DBG-DELTAS: MANIFESTLOG: * (glob)
295 288 DBG-DELTAS: MANIFESTLOG: * (glob)
296 289 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
297 290 DBG-DELTAS: FILELOG:my-file.txt: rev=4: delta-base=4 * (glob)
298 291
299 292 Check that "forced" behavior do not challenge the delta, even if it is full.
300 293 ---------------------------------------------------------------------------
301 294
302 295 A full bundle should be accepted as full bundle without recomputation
303 296
304 297 $ cp -aR local-pre-pull-full local-forced-full
305 298 $ hg -R local-forced-full pull --quiet \
306 299 > --config 'paths.default:pulled-delta-reuse-policy=forced'
307 300 DBG-DELTAS: CHANGELOG: * (glob)
308 301 DBG-DELTAS: CHANGELOG: * (glob)
309 302 DBG-DELTAS: MANIFESTLOG: * (glob)
310 303 DBG-DELTAS: MANIFESTLOG: * (glob)
311 304 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
312 305 DBG-DELTAS: FILELOG:my-file.txt: rev=4: delta-base=4 is-cached=1 - search-rounds=0 try-count=0 - delta-type=full snap-depth=0 - * (glob)
313 306
314 307 Check that "forced" behavior do not challenge the delta, even if it is bad.
315 308 ---------------------------------------------------------------------------
316 309
317 310 The client does not challenge anything and applies the bizarre delta directly.
318 311
319 312 Note: If the bundling process becomes smarter, this test might no longer work
320 313 (as the server won't be sending "bad" deltas anymore) and might need something
321 314 more subtle to test this behavior.
322 315
323 316 $ hg bundle -R peer-bad-delta-with-full --all --config devel.bundle.delta=p1 all-p1.hg
324 317 5 changesets found
325 318 $ cp -aR local-pre-pull-full local-forced-full-p1
326 319 $ hg -R local-forced-full-p1 pull --quiet \
327 320 > --config 'paths.*:pulled-delta-reuse-policy=forced' all-p1.hg
328 321 DBG-DELTAS: CHANGELOG: * (glob)
329 322 DBG-DELTAS: CHANGELOG: * (glob)
330 323 DBG-DELTAS: MANIFESTLOG: * (glob)
331 324 DBG-DELTAS: MANIFESTLOG: * (glob)
332 325 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 is-cached=1 *search-rounds=0 try-count=0* (glob)
333 326 DBG-DELTAS: FILELOG:my-file.txt: rev=4: delta-base=3 is-cached=1 *search-rounds=0 try-count=0* (glob)
334 327
335 328 Check that running "forced" on a non-general delta repository does not corrupt it
336 329 ---------------------------------------------------------------------------------
337 330
338 331 Even if requested to be used, some of the delta in the revlog cannot be stored on a non-general delta repository. We check that the bundle application was correct.
339 332
340 333 $ hg init \
341 334 > --config format.usegeneraldelta=no \
342 335 > --config format.sparse-revlog=no \
343 336 > local-forced-full-p1-no-gd
344 337 $ hg debugformat -R local-forced-full-p1-no-gd | grep generaldelta
345 338 generaldelta: no
346 339 $ hg -R local-forced-full-p1-no-gd pull --quiet local-pre-pull-full \
347 340 > --config debug.revlog.debug-delta=no
348 341 $ hg -R local-forced-full-p1-no-gd pull --quiet \
349 342 > --config 'paths.*:pulled-delta-reuse-policy=forced' all-p1.hg
350 343 DBG-DELTAS: CHANGELOG: * (glob)
351 344 DBG-DELTAS: CHANGELOG: * (glob)
352 345 DBG-DELTAS: MANIFESTLOG: * (glob)
353 346 DBG-DELTAS: MANIFESTLOG: * (glob)
354 347 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=0 * - search-rounds=1 try-count=1 * (glob)
355 348 DBG-DELTAS: FILELOG:my-file.txt: rev=4: delta-base=4 * - search-rounds=1 try-count=1 * (glob)
356 349 $ hg -R local-forced-full-p1-no-gd verify
357 350 checking changesets
358 351 checking manifests
359 352 crosschecking files in changesets and manifests
360 353 checking files
361 354 checking dirstate
362 355 checked 5 changesets with 5 changes to 1 files
General Comments 0
You need to be logged in to leave comments. Login now