34 > op.records.add('song', {'verses': verses}) |
34 > op.records.add('song', {'verses': verses}) |
35 > |
35 > |
36 > @bundle2.parthandler('test:ping') |
36 > @bundle2.parthandler('test:ping') |
37 > def pinghandler(op, part): |
37 > def pinghandler(op, part): |
38 > op.ui.write('received ping request (id %i)\n' % part.id) |
38 > op.ui.write('received ping request (id %i)\n' % part.id) |
39 > if op.reply is not None: |
39 > if op.reply is not None and 'ping-pong' in op.reply.capabilities: |
40 > op.ui.write_err('replying to ping request (id %i)\n' % part.id) |
40 > op.ui.write_err('replying to ping request (id %i)\n' % part.id) |
41 > rpart = bundle2.bundlepart('test:pong', |
41 > rpart = bundle2.bundlepart('test:pong', |
42 > [('in-reply-to', str(part.id))]) |
42 > [('in-reply-to', str(part.id))]) |
43 > op.reply.addpart(rpart) |
43 > op.reply.addpart(rpart) |
44 > |
44 > |
|
45 > @bundle2.parthandler('test:debugreply') |
|
46 > def debugreply(op, part): |
|
47 > """print data about the capacity of the bundle reply""" |
|
48 > if op.reply is None: |
|
49 > op.ui.write('debugreply: no reply\n') |
|
50 > else: |
|
51 > op.ui.write('debugreply: capabilities:\n') |
|
52 > for cap in sorted(op.reply.capabilities): |
|
53 > op.ui.write('debugreply: %r\n' % cap) |
45 > @command('bundle2', |
54 > @command('bundle2', |
46 > [('', 'param', [], 'stream level parameter'), |
55 > [('', 'param', [], 'stream level parameter'), |
47 > ('', 'unknown', False, 'include an unknown mandatory part in the bundle'), |
56 > ('', 'unknown', False, 'include an unknown mandatory part in the bundle'), |
48 > ('', 'parts', False, 'include some arbitrary parts to the bundle'), |
57 > ('', 'parts', False, 'include some arbitrary parts to the bundle'), |
49 > ('', 'reply', False, 'produce a reply bundle'), |
58 > ('', 'reply', False, 'produce a reply bundle'), |
58 > bundler.addparam(*p) |
67 > bundler.addparam(*p) |
59 > except ValueError, exc: |
68 > except ValueError, exc: |
60 > raise util.Abort('%s' % exc) |
69 > raise util.Abort('%s' % exc) |
61 > |
70 > |
62 > if opts['reply']: |
71 > if opts['reply']: |
63 > bundler.addpart(bundle2.bundlepart('replycaps')) |
72 > capsstring = 'ping-pong\nelephants' |
|
73 > bundler.addpart(bundle2.bundlepart('replycaps', data=capsstring)) |
64 > |
74 > |
65 > revs = opts['rev'] |
75 > revs = opts['rev'] |
66 > if 'rev' in opts: |
76 > if 'rev' in opts: |
67 > revs = scmutil.revrange(repo, opts['rev']) |
77 > revs = scmutil.revrange(repo, opts['rev']) |
68 > if revs: |
78 > if revs: |
80 > bundler.addpart(part) |
90 > bundler.addpart(part) |
81 > # add a second one to make sure we handle multiple parts |
91 > # add a second one to make sure we handle multiple parts |
82 > part = bundle2.bundlepart('test:empty') |
92 > part = bundle2.bundlepart('test:empty') |
83 > bundler.addpart(part) |
93 > bundler.addpart(part) |
84 > part = bundle2.bundlepart('test:song', data=ELEPHANTSSONG) |
94 > part = bundle2.bundlepart('test:song', data=ELEPHANTSSONG) |
|
95 > bundler.addpart(part) |
|
96 > part = bundle2.bundlepart('test:debugreply') |
85 > bundler.addpart(part) |
97 > bundler.addpart(part) |
86 > part = bundle2.bundlepart('test:math', |
98 > part = bundle2.bundlepart('test:math', |
87 > [('pi', '3.14'), ('e', '2.72')], |
99 > [('pi', '3.14'), ('e', '2.72')], |
88 > [('cooking', 'raw')], |
100 > [('cooking', 'raw')], |
89 > '42') |
101 > '42') |
337 bundle parameter: |
349 bundle parameter: |
338 start of parts |
350 start of parts |
339 bundle part: "test:empty" |
351 bundle part: "test:empty" |
340 bundle part: "test:empty" |
352 bundle part: "test:empty" |
341 bundle part: "test:song" |
353 bundle part: "test:song" |
|
354 bundle part: "test:debugreply" |
342 bundle part: "test:math" |
355 bundle part: "test:math" |
343 bundle part: "test:ping" |
356 bundle part: "test:ping" |
344 end of bundle |
357 end of bundle |
345 |
358 |
346 $ cat ../parts.hg2 |
359 $ cat ../parts.hg2 |
347 HG20\x00\x00\x00\x11 (esc) |
360 HG20\x00\x00\x00\x11 (esc) |
348 test:empty\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11 (esc) |
361 test:empty\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11 (esc) |
349 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) |
362 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) |
350 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko |
363 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko |
351 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.\x00\x00\x00\x00\x00+ test:math\x00\x00\x00\x03\x02\x01\x02\x04\x01\x04\x07\x03pi3.14e2.72cookingraw\x00\x00\x00\x0242\x00\x00\x00\x00\x00\x10 test:ping\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc) |
364 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\x10 test:ping\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc) |
352 |
365 |
353 |
366 |
354 $ hg statbundle2 < ../parts.hg2 |
367 $ hg statbundle2 < ../parts.hg2 |
355 options count: 0 |
368 options count: 0 |
356 :test:empty: |
369 :test:empty: |
406 mandatory: 0 |
423 mandatory: 0 |
407 advisory: 0 |
424 advisory: 0 |
408 payload chunk size: 178 |
425 payload chunk size: 178 |
409 payload chunk size: 0 |
426 payload chunk size: 0 |
410 payload: 178 bytes |
427 payload: 178 bytes |
|
428 part header size: 22 |
|
429 part type: "test:debugreply" |
|
430 part id: "3" |
|
431 part parameters: 0 |
|
432 :test:debugreply: |
|
433 mandatory: 0 |
|
434 advisory: 0 |
|
435 payload chunk size: 0 |
|
436 payload: 0 bytes |
411 part header size: 43 |
437 part header size: 43 |
412 part type: "test:math" |
438 part type: "test:math" |
413 part id: "3" |
439 part id: "4" |
414 part parameters: 3 |
440 part parameters: 3 |
415 :test:math: |
441 :test:math: |
416 mandatory: 2 |
442 mandatory: 2 |
417 advisory: 1 |
443 advisory: 1 |
418 payload chunk size: 2 |
444 payload chunk size: 2 |
419 payload chunk size: 0 |
445 payload chunk size: 0 |
420 payload: 2 bytes |
446 payload: 2 bytes |
421 part header size: 16 |
447 part header size: 16 |
422 part type: "test:ping" |
448 part type: "test:ping" |
423 part id: "4" |
449 part id: "5" |
424 part parameters: 0 |
450 part parameters: 0 |
425 :test:ping: |
451 :test:ping: |
426 mandatory: 0 |
452 mandatory: 0 |
427 advisory: 0 |
453 advisory: 0 |
428 payload chunk size: 0 |
454 payload chunk size: 0 |
429 payload: 0 bytes |
455 payload: 0 bytes |
430 part header size: 0 |
456 part header size: 0 |
431 end of bundle2 stream |
457 end of bundle2 stream |
432 parts count: 5 |
458 parts count: 6 |
433 |
459 |
434 Test actual unbundling of test part |
460 Test actual unbundling of test part |
435 ======================================= |
461 ======================================= |
436 |
462 |
437 Process the bundle |
463 Process the bundle |
461 payload chunk size: 178 |
487 payload chunk size: 178 |
462 payload chunk size: 0 |
488 payload chunk size: 0 |
463 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko |
489 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko |
464 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko |
490 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko |
465 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko. |
491 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko. |
|
492 part header size: 22 |
|
493 part type: "test:debugreply" |
|
494 part id: "3" |
|
495 part parameters: 0 |
|
496 found a handler for part 'test:debugreply' |
|
497 debugreply: no reply |
|
498 payload chunk size: 0 |
466 part header size: 43 |
499 part header size: 43 |
467 part type: "test:math" |
500 part type: "test:math" |
468 part id: "3" |
501 part id: "4" |
469 part parameters: 3 |
502 part parameters: 3 |
470 ignoring unknown advisory part 'test:math' |
503 ignoring unknown advisory part 'test:math' |
471 payload chunk size: 2 |
504 payload chunk size: 2 |
472 payload chunk size: 0 |
505 payload chunk size: 0 |
473 part header size: 16 |
506 part header size: 16 |
474 part type: "test:ping" |
507 part type: "test:ping" |
475 part id: "4" |
508 part id: "5" |
476 part parameters: 0 |
509 part parameters: 0 |
477 found a handler for part 'test:ping' |
510 found a handler for part 'test:ping' |
478 received ping request (id 4) |
511 received ping request (id 5) |
479 payload chunk size: 0 |
512 payload chunk size: 0 |
480 part header size: 0 |
513 part header size: 0 |
481 end of bundle2 stream |
514 end of bundle2 stream |
482 0 unread bytes |
515 0 unread bytes |
483 3 total verses sung |
516 3 total verses sung |
490 $ hg unbundle2 < ../unknown.hg2 |
523 $ hg unbundle2 < ../unknown.hg2 |
491 The choir starts singing: |
524 The choir starts singing: |
492 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko |
525 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko |
493 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko |
526 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko |
494 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko. |
527 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko. |
|
528 debugreply: no reply |
495 0 unread bytes |
529 0 unread bytes |
496 abort: missing support for 'test:unknown' |
530 abort: missing support for 'test:unknown' |
497 [255] |
531 [255] |
498 |
532 |
499 unbundle with a reply |
533 unbundle with a reply |
508 $ cat ../reply.hg2 |
542 $ cat ../reply.hg2 |
509 HG20\x00\x00\x00\x1b\x06output\x00\x00\x00\x00\x00\x01\x0b\x01in-reply-to3\x00\x00\x00\xd9The choir starts singing: (esc) |
543 HG20\x00\x00\x00\x1b\x06output\x00\x00\x00\x00\x00\x01\x0b\x01in-reply-to3\x00\x00\x00\xd9The choir starts singing: (esc) |
510 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko |
544 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko |
511 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko |
545 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko |
512 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko. |
546 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko. |
513 \x00\x00\x00\x00\x00\x1e test:pong\x00\x00\x00\x01\x01\x00\x0b\x01in-reply-to5\x00\x00\x00\x00\x00\x1b\x06output\x00\x00\x00\x02\x00\x01\x0b\x01in-reply-to5\x00\x00\x00=received ping request (id 5) (esc) |
547 \x00\x00\x00\x00\x00\x1b\x06output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to4\x00\x00\x00Rdebugreply: capabilities: (esc) |
514 replying to ping request (id 5) |
548 debugreply: 'elephants' |
|
549 debugreply: 'ping-pong' |
|
550 \x00\x00\x00\x00\x00\x1e test:pong\x00\x00\x00\x02\x01\x00\x0b\x01in-reply-to6\x00\x00\x00\x00\x00\x1b\x06output\x00\x00\x00\x03\x00\x01\x0b\x01in-reply-to6\x00\x00\x00=received ping request (id 6) (esc) |
|
551 replying to ping request (id 6) |
515 \x00\x00\x00\x00\x00\x00 (no-eol) (esc) |
552 \x00\x00\x00\x00\x00\x00 (no-eol) (esc) |
516 |
553 |
517 The reply is valid |
554 The reply is valid |
518 |
555 |
519 $ hg statbundle2 < ../reply.hg2 |
556 $ hg statbundle2 < ../reply.hg2 |
520 options count: 0 |
557 options count: 0 |
521 :output: |
558 :output: |
522 mandatory: 0 |
559 mandatory: 0 |
523 advisory: 1 |
560 advisory: 1 |
524 payload: 217 bytes |
561 payload: 217 bytes |
|
562 :output: |
|
563 mandatory: 0 |
|
564 advisory: 1 |
|
565 payload: 82 bytes |
525 :test:pong: |
566 :test:pong: |
526 mandatory: 1 |
567 mandatory: 1 |
527 advisory: 0 |
568 advisory: 0 |
528 payload: 0 bytes |
569 payload: 0 bytes |
529 :output: |
570 :output: |
530 mandatory: 0 |
571 mandatory: 0 |
531 advisory: 1 |
572 advisory: 1 |
532 payload: 61 bytes |
573 payload: 61 bytes |
533 parts count: 3 |
574 parts count: 4 |
534 |
575 |
535 Unbundle the reply to get the output: |
576 Unbundle the reply to get the output: |
536 |
577 |
537 $ hg unbundle2 < ../reply.hg2 |
578 $ hg unbundle2 < ../reply.hg2 |
538 remote: The choir starts singing: |
579 remote: The choir starts singing: |
539 remote: Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko |
580 remote: Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko |
540 remote: Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko |
581 remote: Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko |
541 remote: Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko. |
582 remote: Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko. |
542 remote: received ping request (id 5) |
583 remote: debugreply: capabilities: |
543 remote: replying to ping request (id 5) |
584 remote: debugreply: 'elephants' |
|
585 remote: debugreply: 'ping-pong' |
|
586 remote: received ping request (id 6) |
|
587 remote: replying to ping request (id 6) |
544 0 unread bytes |
588 0 unread bytes |
545 |
589 |
546 Support for changegroup |
590 Support for changegroup |
547 =================================== |
591 =================================== |
548 |
592 |