Debian Codegraph @

tests/test-revlog-delta-find.t

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