##// END OF EJS Templates
bundle2: add a test for exceptions raised during the generation process...
Pierre-Yves David -
r23007:03f3af8f default
parent child Browse files
Show More
@@ -1,769 +1,802 b''
1 1 This test is decicated to test the bundle2 container format
2 2
3 3 It test multiple existing parts to test different feature of the container. You
4 4 probably do not need to touch this test unless you change the binary encoding
5 5 of the bundle2 format itself.
6 6
7 7 Create an extension to test bundle2 API
8 8
9 9 $ cat > bundle2.py << EOF
10 10 > """A small extension to test bundle2 implementation
11 11 >
12 12 > Current bundle2 implementation is far too limited to be used in any core
13 13 > code. We still need to be able to test it while it grow up.
14 14 > """
15 15 >
16 16 > import sys, os
17 17 > from mercurial import cmdutil
18 18 > from mercurial import util
19 19 > from mercurial import bundle2
20 20 > from mercurial import scmutil
21 21 > from mercurial import discovery
22 22 > from mercurial import changegroup
23 23 > from mercurial import error
24 24 > from mercurial import obsolete
25 25 >
26 26 >
27 27 > try:
28 28 > import msvcrt
29 29 > msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
30 30 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
31 31 > msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
32 32 > except ImportError:
33 33 > pass
34 34 >
35 35 > cmdtable = {}
36 36 > command = cmdutil.command(cmdtable)
37 37 >
38 38 > ELEPHANTSSONG = """Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
39 39 > Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
40 40 > Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko."""
41 41 > assert len(ELEPHANTSSONG) == 178 # future test say 178 bytes, trust it.
42 42 >
43 43 > @bundle2.parthandler('test:song')
44 44 > def songhandler(op, part):
45 45 > """handle a "test:song" bundle2 part, printing the lyrics on stdin"""
46 46 > op.ui.write('The choir starts singing:\n')
47 47 > verses = 0
48 48 > for line in part.read().split('\n'):
49 49 > op.ui.write(' %s\n' % line)
50 50 > verses += 1
51 51 > op.records.add('song', {'verses': verses})
52 52 >
53 53 > @bundle2.parthandler('test:ping')
54 54 > def pinghandler(op, part):
55 55 > op.ui.write('received ping request (id %i)\n' % part.id)
56 56 > if op.reply is not None and 'ping-pong' in op.reply.capabilities:
57 57 > op.ui.write_err('replying to ping request (id %i)\n' % part.id)
58 58 > op.reply.newpart('test:pong', [('in-reply-to', str(part.id))])
59 59 >
60 60 > @bundle2.parthandler('test:debugreply')
61 61 > def debugreply(op, part):
62 62 > """print data about the capacity of the bundle reply"""
63 63 > if op.reply is None:
64 64 > op.ui.write('debugreply: no reply\n')
65 65 > else:
66 66 > op.ui.write('debugreply: capabilities:\n')
67 67 > for cap in sorted(op.reply.capabilities):
68 68 > op.ui.write('debugreply: %r\n' % cap)
69 69 > for val in op.reply.capabilities[cap]:
70 70 > op.ui.write('debugreply: %r\n' % val)
71 71 >
72 72 > @command('bundle2',
73 73 > [('', 'param', [], 'stream level parameter'),
74 74 > ('', 'unknown', False, 'include an unknown mandatory part in the bundle'),
75 75 > ('', 'unknownparams', False, 'include an unknown part parameters in the bundle'),
76 76 > ('', 'parts', False, 'include some arbitrary parts to the bundle'),
77 77 > ('', 'reply', False, 'produce a reply bundle'),
78 78 > ('', 'pushrace', False, 'includes a check:head part with unknown nodes'),
79 > ('', 'genraise', False, 'includes a part that raise an exception during generation'),
79 80 > ('r', 'rev', [], 'includes those changeset in the bundle'),],
80 81 > '[OUTPUTFILE]')
81 82 > def cmdbundle2(ui, repo, path=None, **opts):
82 83 > """write a bundle2 container on standard ouput"""
83 84 > bundler = bundle2.bundle20(ui)
84 85 > for p in opts['param']:
85 86 > p = p.split('=', 1)
86 87 > try:
87 88 > bundler.addparam(*p)
88 89 > except ValueError, exc:
89 90 > raise util.Abort('%s' % exc)
90 91 >
91 92 > if opts['reply']:
92 93 > capsstring = 'ping-pong\nelephants=babar,celeste\ncity%3D%21=celeste%2Cville'
93 94 > bundler.newpart('b2x:replycaps', data=capsstring)
94 95 >
95 96 > if opts['pushrace']:
96 97 > # also serve to test the assignement of data outside of init
97 98 > part = bundler.newpart('b2x:check:heads')
98 99 > part.data = '01234567890123456789'
99 100 >
100 101 > revs = opts['rev']
101 102 > if 'rev' in opts:
102 103 > revs = scmutil.revrange(repo, opts['rev'])
103 104 > if revs:
104 105 > # very crude version of a changegroup part creation
105 106 > bundled = repo.revs('%ld::%ld', revs, revs)
106 107 > headmissing = [c.node() for c in repo.set('heads(%ld)', revs)]
107 108 > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)]
108 109 > outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing)
109 110 > cg = changegroup.getlocalchangegroup(repo, 'test:bundle2', outgoing, None)
110 111 > bundler.newpart('b2x:changegroup', data=cg.getchunks())
111 112 >
112 113 > if opts['parts']:
113 114 > bundler.newpart('test:empty')
114 115 > # add a second one to make sure we handle multiple parts
115 116 > bundler.newpart('test:empty')
116 117 > bundler.newpart('test:song', data=ELEPHANTSSONG)
117 118 > bundler.newpart('test:debugreply')
118 119 > mathpart = bundler.newpart('test:math')
119 120 > mathpart.addparam('pi', '3.14')
120 121 > mathpart.addparam('e', '2.72')
121 122 > mathpart.addparam('cooking', 'raw', mandatory=False)
122 123 > mathpart.data = '42'
123 124 > # advisory known part with unknown mandatory param
124 125 > bundler.newpart('test:song', [('randomparam','')])
125 126 > if opts['unknown']:
126 127 > bundler.newpart('test:UNKNOWN', data='some random content')
127 128 > if opts['unknownparams']:
128 129 > bundler.newpart('test:SONG', [('randomparams', '')])
129 130 > if opts['parts']:
130 131 > bundler.newpart('test:ping')
132 > if opts['genraise']:
133 > def genraise():
134 > yield 'first line\n'
135 > raise RuntimeError('Someone set up us the bomb!')
136 > bundler.newpart('b2x:output', data=genraise())
131 137 >
132 138 > if path is None:
133 139 > file = sys.stdout
134 140 > else:
135 141 > file = open(path, 'wb')
136 142 >
137 > for chunk in bundler.getchunks():
138 > file.write(chunk)
143 > try:
144 > for chunk in bundler.getchunks():
145 > file.write(chunk)
146 > except RuntimeError, exc:
147 > raise util.Abort(exc)
139 148 >
140 149 > @command('unbundle2', [], '')
141 150 > def cmdunbundle2(ui, repo, replypath=None):
142 151 > """process a bundle2 stream from stdin on the current repo"""
143 152 > try:
144 153 > tr = None
145 154 > lock = repo.lock()
146 155 > tr = repo.transaction('processbundle')
147 156 > try:
148 157 > unbundler = bundle2.unbundle20(ui, sys.stdin)
149 158 > op = bundle2.processbundle(repo, unbundler, lambda: tr)
150 159 > tr.close()
151 160 > except error.BundleValueError, exc:
152 161 > raise util.Abort('missing support for %s' % exc)
153 162 > except error.PushRaced, exc:
154 163 > raise util.Abort('push race: %s' % exc)
155 164 > finally:
156 165 > if tr is not None:
157 166 > tr.release()
158 167 > lock.release()
159 168 > remains = sys.stdin.read()
160 169 > ui.write('%i unread bytes\n' % len(remains))
161 170 > if op.records['song']:
162 171 > totalverses = sum(r['verses'] for r in op.records['song'])
163 172 > ui.write('%i total verses sung\n' % totalverses)
164 173 > for rec in op.records['changegroup']:
165 174 > ui.write('addchangegroup return: %i\n' % rec['return'])
166 175 > if op.reply is not None and replypath is not None:
167 176 > file = open(replypath, 'wb')
168 177 > for chunk in op.reply.getchunks():
169 178 > file.write(chunk)
170 179 >
171 180 > @command('statbundle2', [], '')
172 181 > def cmdstatbundle2(ui, repo):
173 182 > """print statistic on the bundle2 container read from stdin"""
174 183 > unbundler = bundle2.unbundle20(ui, sys.stdin)
175 184 > try:
176 185 > params = unbundler.params
177 186 > except error.BundleValueError, exc:
178 187 > raise util.Abort('unknown parameters: %s' % exc)
179 188 > ui.write('options count: %i\n' % len(params))
180 189 > for key in sorted(params):
181 190 > ui.write('- %s\n' % key)
182 191 > value = params[key]
183 192 > if value is not None:
184 193 > ui.write(' %s\n' % value)
185 194 > count = 0
186 195 > for p in unbundler.iterparts():
187 196 > count += 1
188 197 > ui.write(' :%s:\n' % p.type)
189 198 > ui.write(' mandatory: %i\n' % len(p.mandatoryparams))
190 199 > ui.write(' advisory: %i\n' % len(p.advisoryparams))
191 200 > ui.write(' payload: %i bytes\n' % len(p.read()))
192 201 > ui.write('parts count: %i\n' % count)
193 202 > EOF
194 203 $ cat >> $HGRCPATH << EOF
195 204 > [extensions]
196 205 > bundle2=$TESTTMP/bundle2.py
197 206 > [experimental]
198 207 > bundle2-exp=True
199 208 > evolution=createmarkers
200 209 > [ui]
201 210 > ssh=python "$TESTDIR/dummyssh"
202 211 > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
203 212 > [web]
204 213 > push_ssl = false
205 214 > allow_push = *
206 215 > [phases]
207 216 > publish=False
208 217 > EOF
209 218
210 219 The extension requires a repo (currently unused)
211 220
212 221 $ hg init main
213 222 $ cd main
214 223 $ touch a
215 224 $ hg add a
216 225 $ hg commit -m 'a'
217 226
218 227
219 228 Empty bundle
220 229 =================
221 230
222 231 - no option
223 232 - no parts
224 233
225 234 Test bundling
226 235
227 236 $ hg bundle2
228 237 HG2X\x00\x00\x00\x00 (no-eol) (esc)
229 238
230 239 Test unbundling
231 240
232 241 $ hg bundle2 | hg statbundle2
233 242 options count: 0
234 243 parts count: 0
235 244
236 245 Test old style bundle are detected and refused
237 246
238 247 $ hg bundle --all ../bundle.hg
239 248 1 changesets found
240 249 $ hg statbundle2 < ../bundle.hg
241 250 abort: unknown bundle version 10
242 251 [255]
243 252
244 253 Test parameters
245 254 =================
246 255
247 256 - some options
248 257 - no parts
249 258
250 259 advisory parameters, no value
251 260 -------------------------------
252 261
253 262 Simplest possible parameters form
254 263
255 264 Test generation simple option
256 265
257 266 $ hg bundle2 --param 'caution'
258 267 HG2X\x00\x07caution\x00\x00 (no-eol) (esc)
259 268
260 269 Test unbundling
261 270
262 271 $ hg bundle2 --param 'caution' | hg statbundle2
263 272 options count: 1
264 273 - caution
265 274 parts count: 0
266 275
267 276 Test generation multiple option
268 277
269 278 $ hg bundle2 --param 'caution' --param 'meal'
270 279 HG2X\x00\x0ccaution meal\x00\x00 (no-eol) (esc)
271 280
272 281 Test unbundling
273 282
274 283 $ hg bundle2 --param 'caution' --param 'meal' | hg statbundle2
275 284 options count: 2
276 285 - caution
277 286 - meal
278 287 parts count: 0
279 288
280 289 advisory parameters, with value
281 290 -------------------------------
282 291
283 292 Test generation
284 293
285 294 $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants'
286 295 HG2X\x00\x1ccaution meal=vegan elephants\x00\x00 (no-eol) (esc)
287 296
288 297 Test unbundling
289 298
290 299 $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants' | hg statbundle2
291 300 options count: 3
292 301 - caution
293 302 - elephants
294 303 - meal
295 304 vegan
296 305 parts count: 0
297 306
298 307 parameter with special char in value
299 308 ---------------------------------------------------
300 309
301 310 Test generation
302 311
303 312 $ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple
304 313 HG2X\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
305 314
306 315 Test unbundling
307 316
308 317 $ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple | hg statbundle2
309 318 options count: 2
310 319 - e|! 7/
311 320 babar%#==tutu
312 321 - simple
313 322 parts count: 0
314 323
315 324 Test unknown mandatory option
316 325 ---------------------------------------------------
317 326
318 327 $ hg bundle2 --param 'Gravity' | hg statbundle2
319 328 abort: unknown parameters: Stream Parameter - Gravity
320 329 [255]
321 330
322 331 Test debug output
323 332 ---------------------------------------------------
324 333
325 334 bundling debug
326 335
327 336 $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2
328 337 start emission of HG2X stream
329 338 bundle parameter: e%7C%21%207/=babar%25%23%3D%3Dtutu simple
330 339 start of parts
331 340 end of bundle
332 341
333 342 file content is ok
334 343
335 344 $ cat ../out.hg2
336 345 HG2X\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
337 346
338 347 unbundling debug
339 348
340 349 $ hg statbundle2 --debug < ../out.hg2
341 350 start processing of HG2X stream
342 351 reading bundle2 stream parameters
343 352 ignoring unknown parameter 'e|! 7/'
344 353 ignoring unknown parameter 'simple'
345 354 options count: 2
346 355 - e|! 7/
347 356 babar%#==tutu
348 357 - simple
349 358 start extraction of bundle2 parts
350 359 part header size: 0
351 360 end of bundle2 stream
352 361 parts count: 0
353 362
354 363
355 364 Test buggy input
356 365 ---------------------------------------------------
357 366
358 367 empty parameter name
359 368
360 369 $ hg bundle2 --param '' --quiet
361 370 abort: empty parameter name
362 371 [255]
363 372
364 373 bad parameter name
365 374
366 375 $ hg bundle2 --param 42babar
367 376 abort: non letter first character: '42babar'
368 377 [255]
369 378
370 379
371 380 Test part
372 381 =================
373 382
374 383 $ hg bundle2 --parts ../parts.hg2 --debug
375 384 start emission of HG2X stream
376 385 bundle parameter:
377 386 start of parts
378 387 bundle part: "test:empty"
379 388 bundle part: "test:empty"
380 389 bundle part: "test:song"
381 390 bundle part: "test:debugreply"
382 391 bundle part: "test:math"
383 392 bundle part: "test:song"
384 393 bundle part: "test:ping"
385 394 end of bundle
386 395
387 396 $ cat ../parts.hg2
388 397 HG2X\x00\x00\x00\x11 (esc)
389 398 test:empty\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11 (esc)
390 399 test:empty\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x10 test:song\x00\x00\x00\x02\x00\x00\x00\x00\x00\xb2Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko (esc)
391 400 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
392 401 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.\x00\x00\x00\x00\x00\x16\x0ftest:debugreply\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00+ test:math\x00\x00\x00\x04\x02\x01\x02\x04\x01\x04\x07\x03pi3.14e2.72cookingraw\x00\x00\x00\x0242\x00\x00\x00\x00\x00\x1d test:song\x00\x00\x00\x05\x01\x00\x0b\x00randomparam\x00\x00\x00\x00\x00\x10 test:ping\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
393 402
394 403
395 404 $ hg statbundle2 < ../parts.hg2
396 405 options count: 0
397 406 :test:empty:
398 407 mandatory: 0
399 408 advisory: 0
400 409 payload: 0 bytes
401 410 :test:empty:
402 411 mandatory: 0
403 412 advisory: 0
404 413 payload: 0 bytes
405 414 :test:song:
406 415 mandatory: 0
407 416 advisory: 0
408 417 payload: 178 bytes
409 418 :test:debugreply:
410 419 mandatory: 0
411 420 advisory: 0
412 421 payload: 0 bytes
413 422 :test:math:
414 423 mandatory: 2
415 424 advisory: 1
416 425 payload: 2 bytes
417 426 :test:song:
418 427 mandatory: 1
419 428 advisory: 0
420 429 payload: 0 bytes
421 430 :test:ping:
422 431 mandatory: 0
423 432 advisory: 0
424 433 payload: 0 bytes
425 434 parts count: 7
426 435
427 436 $ hg statbundle2 --debug < ../parts.hg2
428 437 start processing of HG2X stream
429 438 reading bundle2 stream parameters
430 439 options count: 0
431 440 start extraction of bundle2 parts
432 441 part header size: 17
433 442 part type: "test:empty"
434 443 part id: "0"
435 444 part parameters: 0
436 445 :test:empty:
437 446 mandatory: 0
438 447 advisory: 0
439 448 payload chunk size: 0
440 449 payload: 0 bytes
441 450 part header size: 17
442 451 part type: "test:empty"
443 452 part id: "1"
444 453 part parameters: 0
445 454 :test:empty:
446 455 mandatory: 0
447 456 advisory: 0
448 457 payload chunk size: 0
449 458 payload: 0 bytes
450 459 part header size: 16
451 460 part type: "test:song"
452 461 part id: "2"
453 462 part parameters: 0
454 463 :test:song:
455 464 mandatory: 0
456 465 advisory: 0
457 466 payload chunk size: 178
458 467 payload chunk size: 0
459 468 payload: 178 bytes
460 469 part header size: 22
461 470 part type: "test:debugreply"
462 471 part id: "3"
463 472 part parameters: 0
464 473 :test:debugreply:
465 474 mandatory: 0
466 475 advisory: 0
467 476 payload chunk size: 0
468 477 payload: 0 bytes
469 478 part header size: 43
470 479 part type: "test:math"
471 480 part id: "4"
472 481 part parameters: 3
473 482 :test:math:
474 483 mandatory: 2
475 484 advisory: 1
476 485 payload chunk size: 2
477 486 payload chunk size: 0
478 487 payload: 2 bytes
479 488 part header size: 29
480 489 part type: "test:song"
481 490 part id: "5"
482 491 part parameters: 1
483 492 :test:song:
484 493 mandatory: 1
485 494 advisory: 0
486 495 payload chunk size: 0
487 496 payload: 0 bytes
488 497 part header size: 16
489 498 part type: "test:ping"
490 499 part id: "6"
491 500 part parameters: 0
492 501 :test:ping:
493 502 mandatory: 0
494 503 advisory: 0
495 504 payload chunk size: 0
496 505 payload: 0 bytes
497 506 part header size: 0
498 507 end of bundle2 stream
499 508 parts count: 7
500 509
501 510 Test actual unbundling of test part
502 511 =======================================
503 512
504 513 Process the bundle
505 514
506 515 $ hg unbundle2 --debug < ../parts.hg2
507 516 start processing of HG2X stream
508 517 reading bundle2 stream parameters
509 518 start extraction of bundle2 parts
510 519 part header size: 17
511 520 part type: "test:empty"
512 521 part id: "0"
513 522 part parameters: 0
514 523 ignoring unsupported advisory part test:empty
515 524 payload chunk size: 0
516 525 part header size: 17
517 526 part type: "test:empty"
518 527 part id: "1"
519 528 part parameters: 0
520 529 ignoring unsupported advisory part test:empty
521 530 payload chunk size: 0
522 531 part header size: 16
523 532 part type: "test:song"
524 533 part id: "2"
525 534 part parameters: 0
526 535 found a handler for part 'test:song'
527 536 The choir starts singing:
528 537 payload chunk size: 178
529 538 payload chunk size: 0
530 539 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
531 540 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
532 541 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
533 542 part header size: 22
534 543 part type: "test:debugreply"
535 544 part id: "3"
536 545 part parameters: 0
537 546 found a handler for part 'test:debugreply'
538 547 debugreply: no reply
539 548 payload chunk size: 0
540 549 part header size: 43
541 550 part type: "test:math"
542 551 part id: "4"
543 552 part parameters: 3
544 553 ignoring unsupported advisory part test:math
545 554 payload chunk size: 2
546 555 payload chunk size: 0
547 556 part header size: 29
548 557 part type: "test:song"
549 558 part id: "5"
550 559 part parameters: 1
551 560 found a handler for part 'test:song'
552 561 ignoring unsupported advisory part test:song - randomparam
553 562 payload chunk size: 0
554 563 part header size: 16
555 564 part type: "test:ping"
556 565 part id: "6"
557 566 part parameters: 0
558 567 found a handler for part 'test:ping'
559 568 received ping request (id 6)
560 569 payload chunk size: 0
561 570 part header size: 0
562 571 end of bundle2 stream
563 572 0 unread bytes
564 573 3 total verses sung
565 574
566 575 Unbundle with an unknown mandatory part
567 576 (should abort)
568 577
569 578 $ hg bundle2 --parts --unknown ../unknown.hg2
570 579
571 580 $ hg unbundle2 < ../unknown.hg2
572 581 The choir starts singing:
573 582 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
574 583 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
575 584 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
576 585 debugreply: no reply
577 586 0 unread bytes
578 587 abort: missing support for test:unknown
579 588 [255]
580 589
581 590 Unbundle with an unknown mandatory part parameters
582 591 (should abort)
583 592
584 593 $ hg bundle2 --unknownparams ../unknown.hg2
585 594
586 595 $ hg unbundle2 < ../unknown.hg2
587 596 0 unread bytes
588 597 abort: missing support for test:song - randomparams
589 598 [255]
590 599
591 600 unbundle with a reply
592 601
593 602 $ hg bundle2 --parts --reply ../parts-reply.hg2
594 603 $ hg unbundle2 ../reply.hg2 < ../parts-reply.hg2
595 604 0 unread bytes
596 605 3 total verses sung
597 606
598 607 The reply is a bundle
599 608
600 609 $ cat ../reply.hg2
601 610 HG2X\x00\x00\x00\x1f (esc)
602 611 b2x:output\x00\x00\x00\x00\x00\x01\x0b\x01in-reply-to3\x00\x00\x00\xd9The choir starts singing: (esc)
603 612 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
604 613 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
605 614 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
606 615 \x00\x00\x00\x00\x00\x1f (esc)
607 616 b2x:output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to4\x00\x00\x00\xc9debugreply: capabilities: (esc)
608 617 debugreply: 'city=!'
609 618 debugreply: 'celeste,ville'
610 619 debugreply: 'elephants'
611 620 debugreply: 'babar'
612 621 debugreply: 'celeste'
613 622 debugreply: 'ping-pong'
614 623 \x00\x00\x00\x00\x00\x1e test:pong\x00\x00\x00\x02\x01\x00\x0b\x01in-reply-to7\x00\x00\x00\x00\x00\x1f (esc)
615 624 b2x:output\x00\x00\x00\x03\x00\x01\x0b\x01in-reply-to7\x00\x00\x00=received ping request (id 7) (esc)
616 625 replying to ping request (id 7)
617 626 \x00\x00\x00\x00\x00\x00 (no-eol) (esc)
618 627
619 628 The reply is valid
620 629
621 630 $ hg statbundle2 < ../reply.hg2
622 631 options count: 0
623 632 :b2x:output:
624 633 mandatory: 0
625 634 advisory: 1
626 635 payload: 217 bytes
627 636 :b2x:output:
628 637 mandatory: 0
629 638 advisory: 1
630 639 payload: 201 bytes
631 640 :test:pong:
632 641 mandatory: 1
633 642 advisory: 0
634 643 payload: 0 bytes
635 644 :b2x:output:
636 645 mandatory: 0
637 646 advisory: 1
638 647 payload: 61 bytes
639 648 parts count: 4
640 649
641 650 Unbundle the reply to get the output:
642 651
643 652 $ hg unbundle2 < ../reply.hg2
644 653 remote: The choir starts singing:
645 654 remote: Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
646 655 remote: Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
647 656 remote: Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
648 657 remote: debugreply: capabilities:
649 658 remote: debugreply: 'city=!'
650 659 remote: debugreply: 'celeste,ville'
651 660 remote: debugreply: 'elephants'
652 661 remote: debugreply: 'babar'
653 662 remote: debugreply: 'celeste'
654 663 remote: debugreply: 'ping-pong'
655 664 remote: received ping request (id 7)
656 665 remote: replying to ping request (id 7)
657 666 0 unread bytes
658 667
659 668 Test push race detection
660 669
661 670 $ hg bundle2 --pushrace ../part-race.hg2
662 671
663 672 $ hg unbundle2 < ../part-race.hg2
664 673 0 unread bytes
665 674 abort: push race: repository changed while pushing - please try again
666 675 [255]
667 676
668 677 Support for changegroup
669 678 ===================================
670 679
671 680 $ hg unbundle $TESTDIR/bundles/rebase.hg
672 681 adding changesets
673 682 adding manifests
674 683 adding file changes
675 684 added 8 changesets with 7 changes to 7 files (+3 heads)
676 685 (run 'hg heads' to see heads, 'hg merge' to merge)
677 686
678 687 $ hg log -G
679 688 o 8:02de42196ebe draft Nicolas Dumazet <nicdumz.commits@gmail.com> H
680 689 |
681 690 | o 7:eea13746799a draft Nicolas Dumazet <nicdumz.commits@gmail.com> G
682 691 |/|
683 692 o | 6:24b6387c8c8c draft Nicolas Dumazet <nicdumz.commits@gmail.com> F
684 693 | |
685 694 | o 5:9520eea781bc draft Nicolas Dumazet <nicdumz.commits@gmail.com> E
686 695 |/
687 696 | o 4:32af7686d403 draft Nicolas Dumazet <nicdumz.commits@gmail.com> D
688 697 | |
689 698 | o 3:5fddd98957c8 draft Nicolas Dumazet <nicdumz.commits@gmail.com> C
690 699 | |
691 700 | o 2:42ccdea3bb16 draft Nicolas Dumazet <nicdumz.commits@gmail.com> B
692 701 |/
693 702 o 1:cd010b8cd998 draft Nicolas Dumazet <nicdumz.commits@gmail.com> A
694 703
695 704 @ 0:3903775176ed draft test a
696 705
697 706
698 707 $ hg bundle2 --debug --rev '8+7+5+4' ../rev.hg2
699 708 4 changesets found
700 709 list of changesets:
701 710 32af7686d403cf45b5d95f2d70cebea587ac806a
702 711 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
703 712 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
704 713 02de42196ebee42ef284b6780a87cdc96e8eaab6
705 714 start emission of HG2X stream
706 715 bundle parameter:
707 716 start of parts
708 717 bundle part: "b2x:changegroup"
709 718 bundling: 1/4 changesets (25.00%)
710 719 bundling: 2/4 changesets (50.00%)
711 720 bundling: 3/4 changesets (75.00%)
712 721 bundling: 4/4 changesets (100.00%)
713 722 bundling: 1/4 manifests (25.00%)
714 723 bundling: 2/4 manifests (50.00%)
715 724 bundling: 3/4 manifests (75.00%)
716 725 bundling: 4/4 manifests (100.00%)
717 726 bundling: D 1/3 files (33.33%)
718 727 bundling: E 2/3 files (66.67%)
719 728 bundling: H 3/3 files (100.00%)
720 729 end of bundle
721 730
722 731 $ cat ../rev.hg2
723 732 HG2X\x00\x00\x00\x16\x0fb2x:changegroup\x00\x00\x00\x00\x00\x00\x00\x00\x06\x13\x00\x00\x00\xa42\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j_\xdd\xd9\x89W\xc8\xa5JMCm\xfe\x1d\xa9\xd8\x7f!\xa1\xb9{\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x002\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)6e1f4c47ecb533ffd0c8e52cdc88afb6cd39e20c (esc)
724 733 \x00\x00\x00f\x00\x00\x00h\x00\x00\x00\x02D (esc)
725 734 \x00\x00\x00i\x00\x00\x00j\x00\x00\x00\x01D\x00\x00\x00\xa4\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\xcd\x01\x0b\x8c\xd9\x98\xf3\x98\x1aZ\x81\x15\xf9O\x8d\xa4\xabP`\x89\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)4dece9c826f69490507b98c6383a3009b295837d (esc)
726 735 \x00\x00\x00f\x00\x00\x00h\x00\x00\x00\x02E (esc)
727 736 \x00\x00\x00i\x00\x00\x00j\x00\x00\x00\x01E\x00\x00\x00\xa2\xee\xa17Fy\x9a\x9e\x0b\xfd\x88\xf2\x9d<.\x9d\xc98\x9fRO$\xb68|\x8c\x8c\xae7\x17\x88\x80\xf3\xfa\x95\xde\xd3\xcb\x1c\xf7\x85\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\xee\xa17Fy\x9a\x9e\x0b\xfd\x88\xf2\x9d<.\x9d\xc98\x9fRO\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)365b93d57fdf4814e2b5911d6bacff2b12014441 (esc)
728 737 \x00\x00\x00f\x00\x00\x00h\x00\x00\x00\x00\x00\x00\x00i\x00\x00\x00j\x00\x00\x00\x01G\x00\x00\x00\xa4\x02\xdeB\x19n\xbe\xe4.\xf2\x84\xb6x (esc)
729 738 \x87\xcd\xc9n\x8e\xaa\xb6$\xb68|\x8c\x8c\xae7\x17\x88\x80\xf3\xfa\x95\xde\xd3\xcb\x1c\xf7\x85\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xdeB\x19n\xbe\xe4.\xf2\x84\xb6x (esc)
730 739 \x87\xcd\xc9n\x8e\xaa\xb6\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)8bee48edc7318541fc0013ee41b089276a8c24bf (esc)
731 740 \x00\x00\x00f\x00\x00\x00f\x00\x00\x00\x02H (esc)
732 741 \x00\x00\x00g\x00\x00\x00h\x00\x00\x00\x01H\x00\x00\x00\x00\x00\x00\x00\x8bn\x1fLG\xec\xb53\xff\xd0\xc8\xe5,\xdc\x88\xaf\xb6\xcd9\xe2\x0cf\xa5\xa0\x18\x17\xfd\xf5#\x9c'8\x02\xb5\xb7a\x8d\x05\x1c\x89\xe4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x002\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j\x00\x00\x00\x81\x00\x00\x00\x81\x00\x00\x00+D\x00c3f1ca2924c16a19b0656a84900e504e5b0aec2d (esc)
733 742 \x00\x00\x00\x8bM\xec\xe9\xc8&\xf6\x94\x90P{\x98\xc68:0 \xb2\x95\x83}\x00}\x8c\x9d\x88\x84\x13%\xf5\xc6\xb0cq\xb3[N\x8a+\x1a\x83\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\x00\x00\x00+\x00\x00\x00\xac\x00\x00\x00+E\x009c6fd0350a6c0d0c49d4a9c5017cf07043f54e58 (esc)
734 743 \x00\x00\x00\x8b6[\x93\xd5\x7f\xdfH\x14\xe2\xb5\x91\x1dk\xac\xff+\x12\x01DA(\xa5\x84\xc6^\xf1!\xf8\x9e\xb6j\xb7\xd0\xbc\x15=\x80\x99\xe7\xceM\xec\xe9\xc8&\xf6\x94\x90P{\x98\xc68:0 \xb2\x95\x83}\xee\xa17Fy\x9a\x9e\x0b\xfd\x88\xf2\x9d<.\x9d\xc98\x9fRO\x00\x00\x00V\x00\x00\x00V\x00\x00\x00+F\x0022bfcfd62a21a3287edbd4d656218d0f525ed76a (esc)
735 744 \x00\x00\x00\x97\x8b\xeeH\xed\xc71\x85A\xfc\x00\x13\xeeA\xb0\x89'j\x8c$\xbf(\xa5\x84\xc6^\xf1!\xf8\x9e\xb6j\xb7\xd0\xbc\x15=\x80\x99\xe7\xce\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xdeB\x19n\xbe\xe4.\xf2\x84\xb6x (esc)
736 745 \x87\xcd\xc9n\x8e\xaa\xb6\x00\x00\x00+\x00\x00\x00V\x00\x00\x00\x00\x00\x00\x00\x81\x00\x00\x00\x81\x00\x00\x00+H\x008500189e74a9e0475e822093bc7db0d631aeb0b4 (esc)
737 746 \x00\x00\x00\x00\x00\x00\x00\x05D\x00\x00\x00b\xc3\xf1\xca)$\xc1j\x19\xb0ej\x84\x90\x0ePN[ (esc)
738 747 \xec-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x002\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02D (esc)
739 748 \x00\x00\x00\x00\x00\x00\x00\x05E\x00\x00\x00b\x9co\xd05 (esc)
740 749 l\r (no-eol) (esc)
741 750 \x0cI\xd4\xa9\xc5\x01|\xf0pC\xf5NX\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02E (esc)
742 751 \x00\x00\x00\x00\x00\x00\x00\x05H\x00\x00\x00b\x85\x00\x18\x9et\xa9\xe0G^\x82 \x93\xbc}\xb0\xd61\xae\xb0\xb4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xdeB\x19n\xbe\xe4.\xf2\x84\xb6x (esc)
743 752 \x87\xcd\xc9n\x8e\xaa\xb6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02H (esc)
744 753 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
745 754
746 755 $ hg unbundle2 < ../rev.hg2
747 756 adding changesets
748 757 adding manifests
749 758 adding file changes
750 759 added 0 changesets with 0 changes to 3 files
751 760 0 unread bytes
752 761 addchangegroup return: 1
753 762
754 763 with reply
755 764
756 765 $ hg bundle2 --rev '8+7+5+4' --reply ../rev-rr.hg2
757 766 $ hg unbundle2 ../rev-reply.hg2 < ../rev-rr.hg2
758 767 0 unread bytes
759 768 addchangegroup return: 1
760 769
761 770 $ cat ../rev-reply.hg2
762 771 HG2X\x00\x00\x003\x15b2x:reply:changegroup\x00\x00\x00\x00\x00\x02\x0b\x01\x06\x01in-reply-to1return1\x00\x00\x00\x00\x00\x1f (esc)
763 772 b2x:output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to1\x00\x00\x00dadding changesets (esc)
764 773 adding manifests
765 774 adding file changes
766 775 added 0 changesets with 0 changes to 3 files
767 776 \x00\x00\x00\x00\x00\x00 (no-eol) (esc)
768 777
778 Check handling of exception during generation.
779 ----------------------------------------------
780 (is currently not right)
781
782 $ hg bundle2 --genraise > ../genfailed.hg2
783 abort: Someone set up us the bomb!
784 [255]
785
786 Should still be a valid bundle
787 (is currently not right)
788
789 $ cat ../genfailed.hg2
790 HG2X\x00\x00\x00\x11 (esc)
791 b2x:output\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
792
793 And its handling on the other size raise a clean exception
794 (is currently not right)
795
796 $ cat ../genfailed.hg2 | hg unbundle2
797 0 unread bytes
798 abort: stream ended unexpectedly (got 0 bytes, expected 2)
799 [255]
800
801
769 802 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now