comparison tests/test-bundle2-exchange.t @ 22660:978cce51cc5f

bundle2: split test in two We split the test between the one dedicated to the binary format and the one dedicated to checking the exchange of data using pull and push.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 01 Oct 2014 23:55:22 -0500
parents tests/test-bundle2.t@798185707833
children 4f2222f86612
comparison
equal deleted inserted replaced
22659:798185707833 22660:978cce51cc5f
1 Test exchange of common information using bundle2
2
3
4 $ getmainid() {
5 > hg -R main log --template '{node}\n' --rev "$1"
6 > }
7
8 enable obsolescence
9
10 $ cat > obs.py << EOF
11 > import mercurial.obsolete
12 > mercurial.obsolete._enabled = True
13 > EOF
14
15 $ cat >> $HGRCPATH << EOF
16 > [extensions]
17 > obsolete=$TESTTMP/obs.py
18 > [experimental]
19 > bundle2-exp=True
20 > [ui]
21 > ssh=python "$TESTDIR/dummyssh"
22 > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
23 > [web]
24 > push_ssl = false
25 > allow_push = *
26 > [phases]
27 > publish=False
28 > EOF
29
30 The extension requires a repo (currently unused)
31
32 $ hg init main
33 $ cd main
34 $ touch a
35 $ hg add a
36 $ hg commit -m 'a'
37
38 $ hg unbundle $TESTDIR/bundles/rebase.hg
39 adding changesets
40 adding manifests
41 adding file changes
42 added 8 changesets with 7 changes to 7 files (+3 heads)
43 (run 'hg heads' to see heads, 'hg merge' to merge)
44
45 $ cd ..
46
47 Real world exchange
48 =====================
49
50 Add more obsolescence information
51
52 $ hg -R main debugobsolete -d '0 0' 1111111111111111111111111111111111111111 `getmainid 9520eea781bc`
53 $ hg -R main debugobsolete -d '0 0' 2222222222222222222222222222222222222222 `getmainid 24b6387c8c8c`
54
55 clone --pull
56
57 $ hg -R main phase --public cd010b8cd998
58 $ hg clone main other --pull --rev 9520eea781bc
59 adding changesets
60 adding manifests
61 adding file changes
62 added 2 changesets with 2 changes to 2 files
63 1 new obsolescence markers
64 updating to branch default
65 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
66 $ hg -R other log -G
67 @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
68 |
69 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
70
71 $ hg -R other debugobsolete
72 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
73
74 pull
75
76 $ hg -R main phase --public 9520eea781bc
77 $ hg -R other pull -r 24b6387c8c8c
78 pulling from $TESTTMP/main (glob)
79 searching for changes
80 adding changesets
81 adding manifests
82 adding file changes
83 added 1 changesets with 1 changes to 1 files (+1 heads)
84 1 new obsolescence markers
85 (run 'hg heads' to see heads, 'hg merge' to merge)
86 $ hg -R other log -G
87 o 2:24b6387c8c8c draft Nicolas Dumazet <nicdumz.commits@gmail.com> F
88 |
89 | @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
90 |/
91 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
92
93 $ hg -R other debugobsolete
94 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
95 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
96
97 pull empty (with phase movement)
98
99 $ hg -R main phase --public 24b6387c8c8c
100 $ hg -R other pull -r 24b6387c8c8c
101 pulling from $TESTTMP/main (glob)
102 no changes found
103 $ hg -R other log -G
104 o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
105 |
106 | @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
107 |/
108 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
109
110 $ hg -R other debugobsolete
111 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
112 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
113
114 pull empty
115
116 $ hg -R other pull -r 24b6387c8c8c
117 pulling from $TESTTMP/main (glob)
118 no changes found
119 $ hg -R other log -G
120 o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
121 |
122 | @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
123 |/
124 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
125
126 $ hg -R other debugobsolete
127 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
128 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
129
130 add extra data to test their exchange during push
131
132 $ hg -R main bookmark --rev eea13746799a book_eea1
133 $ hg -R main debugobsolete -d '0 0' 3333333333333333333333333333333333333333 `getmainid eea13746799a`
134 $ hg -R main bookmark --rev 02de42196ebe book_02de
135 $ hg -R main debugobsolete -d '0 0' 4444444444444444444444444444444444444444 `getmainid 02de42196ebe`
136 $ hg -R main bookmark --rev 42ccdea3bb16 book_42cc
137 $ hg -R main debugobsolete -d '0 0' 5555555555555555555555555555555555555555 `getmainid 42ccdea3bb16`
138 $ hg -R main bookmark --rev 5fddd98957c8 book_5fdd
139 $ hg -R main debugobsolete -d '0 0' 6666666666666666666666666666666666666666 `getmainid 5fddd98957c8`
140 $ hg -R main bookmark --rev 32af7686d403 book_32af
141 $ hg -R main debugobsolete -d '0 0' 7777777777777777777777777777777777777777 `getmainid 32af7686d403`
142
143 $ hg -R other bookmark --rev cd010b8cd998 book_eea1
144 $ hg -R other bookmark --rev cd010b8cd998 book_02de
145 $ hg -R other bookmark --rev cd010b8cd998 book_42cc
146 $ hg -R other bookmark --rev cd010b8cd998 book_5fdd
147 $ hg -R other bookmark --rev cd010b8cd998 book_32af
148
149 $ hg -R main phase --public eea13746799a
150
151 push
152 $ hg -R main push other --rev eea13746799a --bookmark book_eea1
153 pushing to other
154 searching for changes
155 remote: adding changesets
156 remote: adding manifests
157 remote: adding file changes
158 remote: added 1 changesets with 0 changes to 0 files (-1 heads)
159 remote: 1 new obsolescence markers
160 updating bookmark book_eea1
161 $ hg -R other log -G
162 o 3:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> book_eea1 G
163 |\
164 | o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
165 | |
166 @ | 1:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
167 |/
168 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_02de book_32af book_42cc book_5fdd A
169
170 $ hg -R other debugobsolete
171 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
172 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
173 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
174
175 pull over ssh
176
177 $ hg -R other pull ssh://user@dummy/main -r 02de42196ebe --bookmark book_02de
178 pulling from ssh://user@dummy/main
179 searching for changes
180 adding changesets
181 adding manifests
182 adding file changes
183 added 1 changesets with 1 changes to 1 files (+1 heads)
184 1 new obsolescence markers
185 updating bookmark book_02de
186 (run 'hg heads' to see heads, 'hg merge' to merge)
187 $ hg -R other debugobsolete
188 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
189 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
190 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
191 4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
192
193 pull over http
194
195 $ hg -R main serve -p $HGPORT -d --pid-file=main.pid -E main-error.log
196 $ cat main.pid >> $DAEMON_PIDS
197
198 $ hg -R other pull http://localhost:$HGPORT/ -r 42ccdea3bb16 --bookmark book_42cc
199 pulling from http://localhost:$HGPORT/
200 searching for changes
201 adding changesets
202 adding manifests
203 adding file changes
204 added 1 changesets with 1 changes to 1 files (+1 heads)
205 1 new obsolescence markers
206 updating bookmark book_42cc
207 (run 'hg heads .' to see heads, 'hg merge' to merge)
208 $ cat main-error.log
209 $ hg -R other debugobsolete
210 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
211 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
212 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
213 4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
214 5555555555555555555555555555555555555555 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
215
216 push over ssh
217
218 $ hg -R main push ssh://user@dummy/other -r 5fddd98957c8 --bookmark book_5fdd
219 pushing to ssh://user@dummy/other
220 searching for changes
221 remote: adding changesets
222 remote: adding manifests
223 remote: adding file changes
224 remote: added 1 changesets with 1 changes to 1 files
225 remote: 1 new obsolescence markers
226 updating bookmark book_5fdd
227 $ hg -R other log -G
228 o 6:5fddd98957c8 draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_5fdd C
229 |
230 o 5:42ccdea3bb16 draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_42cc B
231 |
232 | o 4:02de42196ebe draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_02de H
233 | |
234 | | o 3:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> book_eea1 G
235 | |/|
236 | o | 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
237 |/ /
238 | @ 1:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
239 |/
240 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_32af A
241
242 $ hg -R other debugobsolete
243 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
244 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
245 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
246 4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
247 5555555555555555555555555555555555555555 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
248 6666666666666666666666666666666666666666 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
249
250 push over http
251
252 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
253 $ cat other.pid >> $DAEMON_PIDS
254
255 $ hg -R main phase --public 32af7686d403
256 $ hg -R main push http://localhost:$HGPORT2/ -r 32af7686d403 --bookmark book_32af
257 pushing to http://localhost:$HGPORT2/
258 searching for changes
259 remote: adding changesets
260 remote: adding manifests
261 remote: adding file changes
262 remote: added 1 changesets with 1 changes to 1 files
263 remote: 1 new obsolescence markers
264 updating bookmark book_32af
265 $ cat other-error.log
266
267 Check final content.
268
269 $ hg -R other log -G
270 o 7:32af7686d403 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_32af D
271 |
272 o 6:5fddd98957c8 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_5fdd C
273 |
274 o 5:42ccdea3bb16 public Nicolas Dumazet <nicdumz.commits@gmail.com> book_42cc B
275 |
276 | o 4:02de42196ebe draft Nicolas Dumazet <nicdumz.commits@gmail.com> book_02de H
277 | |
278 | | o 3:eea13746799a public Nicolas Dumazet <nicdumz.commits@gmail.com> book_eea1 G
279 | |/|
280 | o | 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com> F
281 |/ /
282 | @ 1:9520eea781bc public Nicolas Dumazet <nicdumz.commits@gmail.com> E
283 |/
284 o 0:cd010b8cd998 public Nicolas Dumazet <nicdumz.commits@gmail.com> A
285
286 $ hg -R other debugobsolete
287 1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
288 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
289 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
290 4444444444444444444444444444444444444444 02de42196ebee42ef284b6780a87cdc96e8eaab6 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
291 5555555555555555555555555555555555555555 42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
292 6666666666666666666666666666666666666666 5fddd98957c8a54a4d436dfe1da9d87f21a1b97b 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
293 7777777777777777777777777777777777777777 32af7686d403cf45b5d95f2d70cebea587ac806a 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
294
295 Error Handling
296 ==============
297
298 Check that errors are properly returned to the client during push.
299
300 Setting up
301
302 $ cat > failpush.py << EOF
303 > """A small extension that makes push fails when using bundle2
304 >
305 > used to test error handling in bundle2
306 > """
307 >
308 > from mercurial import util
309 > from mercurial import bundle2
310 > from mercurial import exchange
311 > from mercurial import extensions
312 >
313 > def _pushbundle2failpart(pushop, bundler):
314 > reason = pushop.ui.config('failpush', 'reason', None)
315 > part = None
316 > if reason == 'abort':
317 > bundler.newpart('test:abort')
318 > if reason == 'unknown':
319 > bundler.newpart('TEST:UNKNOWN')
320 > if reason == 'race':
321 > # 20 Bytes of crap
322 > bundler.newpart('b2x:check:heads', data='01234567890123456789')
323 >
324 > @bundle2.parthandler("test:abort")
325 > def handleabort(op, part):
326 > raise util.Abort('Abandon ship!', hint="don't panic")
327 >
328 > def uisetup(ui):
329 > exchange.b2partsgenmapping['failpart'] = _pushbundle2failpart
330 > exchange.b2partsgenorder.insert(0, 'failpart')
331 >
332 > EOF
333
334 $ cd main
335 $ hg up tip
336 3 files updated, 0 files merged, 1 files removed, 0 files unresolved
337 $ echo 'I' > I
338 $ hg add I
339 $ hg ci -m 'I'
340 $ hg id
341 e7ec4e813ba6 tip
342 $ cd ..
343
344 $ cat << EOF >> $HGRCPATH
345 > [extensions]
346 > failpush=$TESTTMP/failpush.py
347 > EOF
348
349 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
350 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
351 $ cat other.pid >> $DAEMON_PIDS
352
353 Doing the actual push: Abort error
354
355 $ cat << EOF >> $HGRCPATH
356 > [failpush]
357 > reason = abort
358 > EOF
359
360 $ hg -R main push other -r e7ec4e813ba6
361 pushing to other
362 searching for changes
363 abort: Abandon ship!
364 (don't panic)
365 [255]
366
367 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
368 pushing to ssh://user@dummy/other
369 searching for changes
370 abort: Abandon ship!
371 (don't panic)
372 [255]
373
374 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
375 pushing to http://localhost:$HGPORT2/
376 searching for changes
377 abort: Abandon ship!
378 (don't panic)
379 [255]
380
381
382 Doing the actual push: unknown mandatory parts
383
384 $ cat << EOF >> $HGRCPATH
385 > [failpush]
386 > reason = unknown
387 > EOF
388
389 $ hg -R main push other -r e7ec4e813ba6
390 pushing to other
391 searching for changes
392 abort: missing support for test:unknown
393 [255]
394
395 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
396 pushing to ssh://user@dummy/other
397 searching for changes
398 abort: missing support for test:unknown
399 [255]
400
401 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
402 pushing to http://localhost:$HGPORT2/
403 searching for changes
404 abort: missing support for test:unknown
405 [255]
406
407 Doing the actual push: race
408
409 $ cat << EOF >> $HGRCPATH
410 > [failpush]
411 > reason = race
412 > EOF
413
414 $ hg -R main push other -r e7ec4e813ba6
415 pushing to other
416 searching for changes
417 abort: push failed:
418 'repository changed while pushing - please try again'
419 [255]
420
421 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
422 pushing to ssh://user@dummy/other
423 searching for changes
424 abort: push failed:
425 'repository changed while pushing - please try again'
426 [255]
427
428 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
429 pushing to http://localhost:$HGPORT2/
430 searching for changes
431 abort: push failed:
432 'repository changed while pushing - please try again'
433 [255]
434
435 Doing the actual push: hook abort
436
437 $ cat << EOF >> $HGRCPATH
438 > [failpush]
439 > reason =
440 > [hooks]
441 > b2x-pretransactionclose.failpush = false
442 > EOF
443
444 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
445 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
446 $ cat other.pid >> $DAEMON_PIDS
447
448 $ hg -R main push other -r e7ec4e813ba6
449 pushing to other
450 searching for changes
451 transaction abort!
452 rollback completed
453 abort: b2x-pretransactionclose.failpush hook exited with status 1
454 [255]
455
456 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
457 pushing to ssh://user@dummy/other
458 searching for changes
459 abort: b2x-pretransactionclose.failpush hook exited with status 1
460 remote: transaction abort!
461 remote: rollback completed
462 [255]
463
464 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
465 pushing to http://localhost:$HGPORT2/
466 searching for changes
467 abort: b2x-pretransactionclose.failpush hook exited with status 1
468 [255]
469
470