Mercurial > hg
comparison tests/test-sidedata-exchange.t @ 46718:ba8e508a8e69
sidedata-exchange: rewrite sidedata on-the-fly whenever possible
When a A exchanges with B, the difference of their supported sidedata categories
is made, and the responsibility is always with the client to generated it:
- If A pushes to B and B requires category `foo` that A does not have, A
will need to generate it when sending it to B.
- If A pulls from B and A needs category `foo`, it will generate `foo`
before the end of the transaction.
- Any category that is not required is removed. If peers are not compatible,
abort.
It is forbidden to rewrite sidedata for a rev that already has sidedata, since
that would introduce unreachable (garbage) data in the data file, something
we're not prepared for yet.
Differential Revision: https://phab.mercurial-scm.org/D10032
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Fri, 19 Feb 2021 11:24:50 +0100 |
parents | |
children | 0dedd3d063b0 |
comparison
equal
deleted
inserted
replaced
46717:502e795b55ac | 46718:ba8e508a8e69 |
---|---|
1 =========================== | |
2 Tests for sidedata exchange | |
3 =========================== | |
4 | |
5 Check simple exchange behavior | |
6 ============================== | |
7 | |
8 Pusher and pushed have sidedata enabled | |
9 --------------------------------------- | |
10 | |
11 $ hg init sidedata-source --config format.exp-use-side-data=yes | |
12 $ cat << EOF >> sidedata-source/.hg/hgrc | |
13 > [extensions] | |
14 > testsidedata=$TESTDIR/testlib/ext-sidedata-5.py | |
15 > EOF | |
16 $ hg init sidedata-target --config format.exp-use-side-data=yes | |
17 $ cat << EOF >> sidedata-target/.hg/hgrc | |
18 > [extensions] | |
19 > testsidedata=$TESTDIR/testlib/ext-sidedata-5.py | |
20 > EOF | |
21 $ cd sidedata-source | |
22 $ echo a > a | |
23 $ echo b > b | |
24 $ echo c > c | |
25 $ hg commit -Am "initial" | |
26 adding a | |
27 adding b | |
28 adding c | |
29 $ echo aa > a | |
30 $ hg commit -m "other" | |
31 $ hg push -r . ../sidedata-target | |
32 pushing to ../sidedata-target | |
33 searching for changes | |
34 adding changesets | |
35 adding manifests | |
36 adding file changes | |
37 added 2 changesets with 4 changes to 3 files | |
38 $ hg -R ../sidedata-target debugsidedata -c 0 | |
39 2 sidedata entries | |
40 entry-0001 size 4 | |
41 entry-0002 size 32 | |
42 $ hg -R ../sidedata-target debugsidedata -c 1 -v | |
43 2 sidedata entries | |
44 entry-0001 size 4 | |
45 '\x00\x00\x00:' | |
46 entry-0002 size 32 | |
47 '\xa3\xee4v\x99\x85$\x9f\x1f\x8dKe\x0f\xc3\x9d-\xc9\xb5%[\x15=h\xe9\xf2O\xb5\xd9\x1f*\xff\xe5' | |
48 $ hg -R ../sidedata-target debugsidedata -m 0 | |
49 2 sidedata entries | |
50 entry-0001 size 4 | |
51 entry-0002 size 32 | |
52 $ hg -R ../sidedata-target debugsidedata -m 1 -v | |
53 2 sidedata entries | |
54 entry-0001 size 4 | |
55 '\x00\x00\x00\x81' | |
56 entry-0002 size 32 | |
57 '-bL\xc5\xa4uu"#\xac\x1b`,\xc0\xbc\x9d\xf5\xac\xf0\x1d\x89)2\xf8N\xb1\x14m\xce\xd7\xbc\xae' | |
58 $ hg -R ../sidedata-target debugsidedata a 0 | |
59 2 sidedata entries | |
60 entry-0001 size 4 | |
61 entry-0002 size 32 | |
62 $ hg -R ../sidedata-target debugsidedata a 1 -v | |
63 2 sidedata entries | |
64 entry-0001 size 4 | |
65 '\x00\x00\x00\x03' | |
66 entry-0002 size 32 | |
67 '\xd9\xcd\x81UvL5C\xf1\x0f\xad\x8aH\rt17Fo\x8dU!<\x8e\xae\xfc\xd1/\x06\xd4:\x80' | |
68 $ cd .. | |
69 | |
70 Puller and pulled have sidedata enabled | |
71 --------------------------------------- | |
72 | |
73 $ rm -rf sidedata-source sidedata-target | |
74 $ hg init sidedata-source --config format.exp-use-side-data=yes | |
75 $ cat << EOF >> sidedata-source/.hg/hgrc | |
76 > [extensions] | |
77 > testsidedata=$TESTDIR/testlib/ext-sidedata-5.py | |
78 > EOF | |
79 $ hg init sidedata-target --config format.exp-use-side-data=yes | |
80 $ cat << EOF >> sidedata-target/.hg/hgrc | |
81 > [extensions] | |
82 > testsidedata=$TESTDIR/testlib/ext-sidedata-5.py | |
83 > EOF | |
84 $ cd sidedata-source | |
85 $ echo a > a | |
86 $ echo b > b | |
87 $ echo c > c | |
88 $ hg commit -Am "initial" | |
89 adding a | |
90 adding b | |
91 adding c | |
92 $ echo aa > a | |
93 $ hg commit -m "other" | |
94 $ hg pull -R ../sidedata-target ../sidedata-source | |
95 pulling from ../sidedata-source | |
96 requesting all changes | |
97 adding changesets | |
98 adding manifests | |
99 adding file changes | |
100 added 2 changesets with 4 changes to 3 files | |
101 new changesets 05da661850d7:7ec8b4049447 | |
102 (run 'hg update' to get a working copy) | |
103 $ hg -R ../sidedata-target debugsidedata -c 0 | |
104 2 sidedata entries | |
105 entry-0001 size 4 | |
106 entry-0002 size 32 | |
107 $ hg -R ../sidedata-target debugsidedata -c 1 -v | |
108 2 sidedata entries | |
109 entry-0001 size 4 | |
110 '\x00\x00\x00:' | |
111 entry-0002 size 32 | |
112 '\xa3\xee4v\x99\x85$\x9f\x1f\x8dKe\x0f\xc3\x9d-\xc9\xb5%[\x15=h\xe9\xf2O\xb5\xd9\x1f*\xff\xe5' | |
113 $ hg -R ../sidedata-target debugsidedata -m 0 | |
114 2 sidedata entries | |
115 entry-0001 size 4 | |
116 entry-0002 size 32 | |
117 $ hg -R ../sidedata-target debugsidedata -m 1 -v | |
118 2 sidedata entries | |
119 entry-0001 size 4 | |
120 '\x00\x00\x00\x81' | |
121 entry-0002 size 32 | |
122 '-bL\xc5\xa4uu"#\xac\x1b`,\xc0\xbc\x9d\xf5\xac\xf0\x1d\x89)2\xf8N\xb1\x14m\xce\xd7\xbc\xae' | |
123 $ hg -R ../sidedata-target debugsidedata a 0 | |
124 2 sidedata entries | |
125 entry-0001 size 4 | |
126 entry-0002 size 32 | |
127 $ hg -R ../sidedata-target debugsidedata a 1 -v | |
128 2 sidedata entries | |
129 entry-0001 size 4 | |
130 '\x00\x00\x00\x03' | |
131 entry-0002 size 32 | |
132 '\xd9\xcd\x81UvL5C\xf1\x0f\xad\x8aH\rt17Fo\x8dU!<\x8e\xae\xfc\xd1/\x06\xd4:\x80' | |
133 $ cd .. | |
134 | |
135 Now on to asymmetric configs. | |
136 | |
137 Pusher has sidedata enabled, pushed does not | |
138 -------------------------------------------- | |
139 | |
140 $ rm -rf sidedata-source sidedata-target | |
141 $ hg init sidedata-source --config format.exp-use-side-data=yes | |
142 $ cat << EOF >> sidedata-source/.hg/hgrc | |
143 > [extensions] | |
144 > testsidedata=$TESTDIR/testlib/ext-sidedata-5.py | |
145 > EOF | |
146 $ hg init sidedata-target --config format.exp-use-side-data=no | |
147 $ cd sidedata-source | |
148 $ echo a > a | |
149 $ echo b > b | |
150 $ echo c > c | |
151 $ hg commit -Am "initial" | |
152 adding a | |
153 adding b | |
154 adding c | |
155 $ echo aa > a | |
156 $ hg commit -m "other" | |
157 $ hg push -r . ../sidedata-target --traceback | |
158 pushing to ../sidedata-target | |
159 searching for changes | |
160 adding changesets | |
161 adding manifests | |
162 adding file changes | |
163 added 2 changesets with 4 changes to 3 files | |
164 $ hg -R ../sidedata-target log -G | |
165 o changeset: 1:7ec8b4049447 | |
166 | tag: tip | |
167 | user: test | |
168 | date: Thu Jan 01 00:00:00 1970 +0000 | |
169 | summary: other | |
170 | | |
171 o changeset: 0:05da661850d7 | |
172 user: test | |
173 date: Thu Jan 01 00:00:00 1970 +0000 | |
174 summary: initial | |
175 | |
176 | |
177 $ hg -R ../sidedata-target debugsidedata -c 0 | |
178 $ hg -R ../sidedata-target debugsidedata -c 1 -v | |
179 $ hg -R ../sidedata-target debugsidedata -m 0 | |
180 $ hg -R ../sidedata-target debugsidedata -m 1 -v | |
181 $ hg -R ../sidedata-target debugsidedata a 0 | |
182 $ hg -R ../sidedata-target debugsidedata a 1 -v | |
183 $ cd .. | |
184 | |
185 Pulled has sidedata enabled, puller does not | |
186 -------------------------------------------- | |
187 | |
188 $ rm -rf sidedata-source sidedata-target | |
189 $ hg init sidedata-source --config format.exp-use-side-data=yes | |
190 $ cat << EOF >> sidedata-source/.hg/hgrc | |
191 > [extensions] | |
192 > testsidedata=$TESTDIR/testlib/ext-sidedata-5.py | |
193 > EOF | |
194 $ hg init sidedata-target --config format.exp-use-side-data=no | |
195 $ cd sidedata-source | |
196 $ echo a > a | |
197 $ echo b > b | |
198 $ echo c > c | |
199 $ hg commit -Am "initial" | |
200 adding a | |
201 adding b | |
202 adding c | |
203 $ echo aa > a | |
204 $ hg commit -m "other" | |
205 $ hg pull -R ../sidedata-target ../sidedata-source | |
206 pulling from ../sidedata-source | |
207 requesting all changes | |
208 adding changesets | |
209 adding manifests | |
210 adding file changes | |
211 added 2 changesets with 4 changes to 3 files | |
212 new changesets 05da661850d7:7ec8b4049447 | |
213 (run 'hg update' to get a working copy) | |
214 $ hg -R ../sidedata-target log -G | |
215 o changeset: 1:7ec8b4049447 | |
216 | tag: tip | |
217 | user: test | |
218 | date: Thu Jan 01 00:00:00 1970 +0000 | |
219 | summary: other | |
220 | | |
221 o changeset: 0:05da661850d7 | |
222 user: test | |
223 date: Thu Jan 01 00:00:00 1970 +0000 | |
224 summary: initial | |
225 | |
226 | |
227 $ hg -R ../sidedata-target debugsidedata -c 0 | |
228 $ hg -R ../sidedata-target debugsidedata -c 1 -v | |
229 $ hg -R ../sidedata-target debugsidedata -m 0 | |
230 $ hg -R ../sidedata-target debugsidedata -m 1 -v | |
231 $ hg -R ../sidedata-target debugsidedata a 0 | |
232 $ hg -R ../sidedata-target debugsidedata a 1 -v | |
233 $ cd .. | |
234 | |
235 | |
236 Check sidedata exchange with on-the-fly generation and removal | |
237 ============================================================== | |
238 | |
239 (Push) Target has strict superset of the source | |
240 ----------------------------------------------- | |
241 | |
242 $ hg init source-repo --config format.exp-use-side-data=yes | |
243 $ hg init target-repo --config format.exp-use-side-data=yes | |
244 $ cat << EOF >> target-repo/.hg/hgrc | |
245 > [extensions] | |
246 > testsidedata=$TESTDIR/testlib/ext-sidedata.py | |
247 > EOF | |
248 $ cd source-repo | |
249 $ echo aaa > a | |
250 $ hg add a | |
251 $ hg commit -m a | |
252 $ echo aaa > b | |
253 $ hg add b | |
254 $ hg commit -m b | |
255 $ echo xxx >> a | |
256 $ hg commit -m aa | |
257 | |
258 No sidedata is generated in the source | |
259 $ hg debugsidedata -c 0 | |
260 | |
261 Check that sidedata capabilities are advertised | |
262 $ hg debugcapabilities ../target-repo | grep sidedata | |
263 exp-wanted-sidedata=1,2 | |
264 | |
265 We expect the client to abort the push since it's not capable of generating | |
266 what the server is asking | |
267 $ hg push -r . ../target-repo | |
268 pushing to ../target-repo | |
269 abort: cannot push: required sidedata category not supported by this client: '1' | |
270 [255] | |
271 | |
272 Add the required capabilities | |
273 $ cat << EOF >> .hg/hgrc | |
274 > [extensions] | |
275 > testsidedata2=$TESTDIR/testlib/ext-sidedata-2.py | |
276 > EOF | |
277 | |
278 We expect the target to have sidedata that was generated by the source on push | |
279 $ hg push -r . ../target-repo | |
280 pushing to ../target-repo | |
281 searching for changes | |
282 adding changesets | |
283 adding manifests | |
284 adding file changes | |
285 added 3 changesets with 3 changes to 2 files | |
286 $ cd ../target-repo | |
287 $ hg debugsidedata -c 0 | |
288 2 sidedata entries | |
289 entry-0001 size 4 | |
290 entry-0002 size 32 | |
291 $ hg debugsidedata -c 1 -v | |
292 2 sidedata entries | |
293 entry-0001 size 4 | |
294 '\x00\x00\x006' | |
295 entry-0002 size 32 | |
296 '\x98\t\xf9\xc4v\xf0\xc5P\x90\xf7wRf\xe8\xe27e\xfc\xc1\x93\xa4\x96\xd0\x1d\x97\xaaG\x1d\xd7t\xfa\xde' | |
297 $ hg debugsidedata -m 2 | |
298 2 sidedata entries | |
299 entry-0001 size 4 | |
300 entry-0002 size 32 | |
301 $ hg debugsidedata a 1 | |
302 2 sidedata entries | |
303 entry-0001 size 4 | |
304 entry-0002 size 32 | |
305 $ cd .. | |
306 | |
307 (Push) Difference is not subset/superset | |
308 ---------------------------------------- | |
309 | |
310 Source has one in common, one missing and one more sidedata category with the | |
311 target. | |
312 | |
313 $ rm -rf source-repo target-repo | |
314 $ hg init source-repo --config format.exp-use-side-data=yes | |
315 $ cat << EOF >> source-repo/.hg/hgrc | |
316 > [extensions] | |
317 > testsidedata3=$TESTDIR/testlib/ext-sidedata-3.py | |
318 > EOF | |
319 $ hg init target-repo --config format.exp-use-side-data=yes | |
320 $ cat << EOF >> target-repo/.hg/hgrc | |
321 > [extensions] | |
322 > testsidedata4=$TESTDIR/testlib/ext-sidedata-4.py | |
323 > EOF | |
324 $ cd source-repo | |
325 $ echo aaa > a | |
326 $ hg add a | |
327 $ hg commit -m a | |
328 $ echo aaa > b | |
329 $ hg add b | |
330 $ hg commit -m b | |
331 $ echo xxx >> a | |
332 $ hg commit -m aa | |
333 | |
334 Check that sidedata capabilities are advertised | |
335 $ hg debugcapabilities . | grep sidedata | |
336 exp-wanted-sidedata=1,2 | |
337 $ hg debugcapabilities ../target-repo | grep sidedata | |
338 exp-wanted-sidedata=2,3 | |
339 | |
340 Sidedata is generated in the source, but only the right categories (entry-0001 and entry-0002) | |
341 $ hg debugsidedata -c 0 | |
342 2 sidedata entries | |
343 entry-0001 size 4 | |
344 entry-0002 size 32 | |
345 $ hg debugsidedata -c 1 -v | |
346 2 sidedata entries | |
347 entry-0001 size 4 | |
348 '\x00\x00\x006' | |
349 entry-0002 size 32 | |
350 '\x98\t\xf9\xc4v\xf0\xc5P\x90\xf7wRf\xe8\xe27e\xfc\xc1\x93\xa4\x96\xd0\x1d\x97\xaaG\x1d\xd7t\xfa\xde' | |
351 $ hg debugsidedata -m 2 | |
352 2 sidedata entries | |
353 entry-0001 size 4 | |
354 entry-0002 size 32 | |
355 $ hg debugsidedata a 1 | |
356 2 sidedata entries | |
357 entry-0001 size 4 | |
358 entry-0002 size 32 | |
359 | |
360 | |
361 We expect the target to have sidedata that was generated by the source on push, | |
362 and also removed the sidedata categories that are not supported by the target. | |
363 Namely, we expect entry-0002 (only exchanged) and entry-0003 (generated), | |
364 but not entry-0001. | |
365 | |
366 $ hg push -r . ../target-repo --traceback | |
367 pushing to ../target-repo | |
368 searching for changes | |
369 adding changesets | |
370 adding manifests | |
371 adding file changes | |
372 added 3 changesets with 3 changes to 2 files | |
373 $ cd ../target-repo | |
374 $ hg log -G | |
375 o changeset: 2:40f977031323 | |
376 | tag: tip | |
377 | user: test | |
378 | date: Thu Jan 01 00:00:00 1970 +0000 | |
379 | summary: aa | |
380 | | |
381 o changeset: 1:2707720c6597 | |
382 | user: test | |
383 | date: Thu Jan 01 00:00:00 1970 +0000 | |
384 | summary: b | |
385 | | |
386 o changeset: 0:7049e48789d7 | |
387 user: test | |
388 date: Thu Jan 01 00:00:00 1970 +0000 | |
389 summary: a | |
390 | |
391 $ hg debugsidedata -c 0 | |
392 2 sidedata entries | |
393 entry-0002 size 32 | |
394 entry-0003 size 48 | |
395 $ hg debugsidedata -c 1 -v | |
396 2 sidedata entries | |
397 entry-0002 size 32 | |
398 '\x98\t\xf9\xc4v\xf0\xc5P\x90\xf7wRf\xe8\xe27e\xfc\xc1\x93\xa4\x96\xd0\x1d\x97\xaaG\x1d\xd7t\xfa\xde' | |
399 entry-0003 size 48 | |
400 '\x87\xcf\xdfI/\xb5\xed\xeaC\xc1\xf0S\xf3X\x1c\xcc\x00m\xee\xe6#\xc1\xe3\xcaB8Fk\x82e\xfc\xc01\xf6\xb7\xb9\xb3([\xf6D\xa6\xcf\x9b\xea\x11{\x08' | |
401 $ hg debugsidedata -m 2 | |
402 2 sidedata entries | |
403 entry-0002 size 32 | |
404 entry-0003 size 48 | |
405 $ hg debugsidedata a 1 | |
406 2 sidedata entries | |
407 entry-0002 size 32 | |
408 entry-0003 size 48 | |
409 $ cd .. | |
410 | |
411 (Pull) Target has strict superset of the source | |
412 ----------------------------------------------- | |
413 | |
414 $ rm -rf source-repo target-repo | |
415 $ hg init source-repo --config format.exp-use-side-data=yes | |
416 $ hg init target-repo --config format.exp-use-side-data=yes | |
417 $ cat << EOF >> target-repo/.hg/hgrc | |
418 > [extensions] | |
419 > testsidedata=$TESTDIR/testlib/ext-sidedata.py | |
420 > EOF | |
421 $ cd source-repo | |
422 $ echo aaa > a | |
423 $ hg add a | |
424 $ hg commit -m a | |
425 $ echo aaa > b | |
426 $ hg add b | |
427 $ hg commit -m b | |
428 $ echo xxx >> a | |
429 $ hg commit -m aa | |
430 | |
431 No sidedata is generated in the source | |
432 $ hg debugsidedata -c 0 | |
433 | |
434 Check that sidedata capabilities are advertised | |
435 $ hg debugcapabilities ../target-repo | grep sidedata | |
436 exp-wanted-sidedata=1,2 | |
437 | |
438 $ cd ../target-repo | |
439 | |
440 Add the required capabilities | |
441 $ cat << EOF >> .hg/hgrc | |
442 > [extensions] | |
443 > testsidedata2=$TESTDIR/testlib/ext-sidedata-2.py | |
444 > EOF | |
445 | |
446 We expect the target to have sidedata that it generated on-the-fly during pull | |
447 $ hg pull -r . ../source-repo --traceback | |
448 pulling from ../source-repo | |
449 adding changesets | |
450 adding manifests | |
451 adding file changes | |
452 added 3 changesets with 3 changes to 2 files | |
453 new changesets 7049e48789d7:40f977031323 | |
454 (run 'hg update' to get a working copy) | |
455 $ hg debugsidedata -c 0 --traceback | |
456 2 sidedata entries | |
457 entry-0001 size 4 | |
458 entry-0002 size 32 | |
459 $ hg debugsidedata -c 1 -v --traceback | |
460 2 sidedata entries | |
461 entry-0001 size 4 | |
462 '\x00\x00\x006' | |
463 entry-0002 size 32 | |
464 '\x98\t\xf9\xc4v\xf0\xc5P\x90\xf7wRf\xe8\xe27e\xfc\xc1\x93\xa4\x96\xd0\x1d\x97\xaaG\x1d\xd7t\xfa\xde' | |
465 $ hg debugsidedata -m 2 | |
466 2 sidedata entries | |
467 entry-0001 size 4 | |
468 entry-0002 size 32 | |
469 $ hg debugsidedata a 1 | |
470 2 sidedata entries | |
471 entry-0001 size 4 | |
472 entry-0002 size 32 | |
473 $ cd .. |