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