Show More
@@ -294,23 +294,24 b' def processbundle(repo, unbundler, trans' | |||
|
294 | 294 | # part key are matched lower case |
|
295 | 295 | key = parttype.lower() |
|
296 | 296 | try: |
|
297 |
handler = parthandlermapping |
|
|
297 | handler = parthandlermapping.get(key) | |
|
298 | if handler is None: | |
|
299 | raise error.BundleValueError(parttype=key) | |
|
298 | 300 | op.ui.debug('found a handler for part %r\n' % parttype) |
|
299 | except KeyError: | |
|
301 | unknownparams = part.mandatorykeys - handler.params | |
|
302 | if unknownparams: | |
|
303 | unknownparams = list(unknownparams) | |
|
304 | unknownparams.sort() | |
|
305 | raise error.BundleValueError(parttype=key, | |
|
306 | params=unknownparams) | |
|
307 | except error.BundleValueError, exc: | |
|
300 | 308 | if key != parttype: # mandatory parts |
|
301 |
|
|
|
302 | # - use a more precise exception | |
|
303 | raise error.BundleValueError(parttype=key) | |
|
304 | op.ui.debug('ignoring unknown advisory part %r\n' % key) | |
|
309 | raise | |
|
310 | op.ui.debug('ignoring unsupported advisory part %s\n' % exc) | |
|
305 | 311 | # consuming the part |
|
306 | 312 | part.read() |
|
307 | 313 | continue |
|
308 | 314 | |
|
309 | unknownparams = part.mandatorykeys - handler.params | |
|
310 | if unknownparams: | |
|
311 | unknownparams = list(unknownparams) | |
|
312 | unknownparams.sort() | |
|
313 | raise error.BundleValueError(parttype=key, params=unknownparams) | |
|
314 | 315 | |
|
315 | 316 | # handler is called outside the above try block so that we don't |
|
316 | 317 | # risk catching KeyErrors from anything other than the |
@@ -112,6 +112,8 b' Create an extension to test bundle2 API' | |||
|
112 | 112 | > mathpart.addparam('e', '2.72') |
|
113 | 113 | > mathpart.addparam('cooking', 'raw', mandatory=False) |
|
114 | 114 | > mathpart.data = '42' |
|
115 | > # advisory known part with unknown mandatory param | |
|
116 | > bundler.newpart('test:song', [('randomparam','')]) | |
|
115 | 117 | > if opts['unknown']: |
|
116 | 118 | > bundler.newpart('test:UNKNOWN', data='some random content') |
|
117 | 119 | > if opts['unknownparams']: |
@@ -366,6 +368,7 b' Test part' | |||
|
366 | 368 | bundle part: "test:song" |
|
367 | 369 | bundle part: "test:debugreply" |
|
368 | 370 | bundle part: "test:math" |
|
371 | bundle part: "test:song" | |
|
369 | 372 | bundle part: "test:ping" |
|
370 | 373 | end of bundle |
|
371 | 374 | |
@@ -374,7 +377,7 b' Test part' | |||
|
374 | 377 | test:empty\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11 (esc) |
|
375 | 378 | 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) |
|
376 | 379 | Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko |
|
377 |
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\x0 |
|
|
380 | 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) | |
|
378 | 381 | |
|
379 | 382 | |
|
380 | 383 | $ hg statbundle2 < ../parts.hg2 |
@@ -399,11 +402,15 b' Test part' | |||
|
399 | 402 | mandatory: 2 |
|
400 | 403 | advisory: 1 |
|
401 | 404 | payload: 2 bytes |
|
405 | :test:song: | |
|
406 | mandatory: 1 | |
|
407 | advisory: 0 | |
|
408 | payload: 0 bytes | |
|
402 | 409 | :test:ping: |
|
403 | 410 | mandatory: 0 |
|
404 | 411 | advisory: 0 |
|
405 | 412 | payload: 0 bytes |
|
406 |
parts count: |
|
|
413 | parts count: 7 | |
|
407 | 414 | |
|
408 | 415 | $ hg statbundle2 --debug < ../parts.hg2 |
|
409 | 416 | start processing of HG2X stream |
@@ -457,9 +464,18 b' Test part' | |||
|
457 | 464 | payload chunk size: 2 |
|
458 | 465 | payload chunk size: 0 |
|
459 | 466 | payload: 2 bytes |
|
467 | part header size: 29 | |
|
468 | part type: "test:song" | |
|
469 | part id: "5" | |
|
470 | part parameters: 1 | |
|
471 | :test:song: | |
|
472 | mandatory: 1 | |
|
473 | advisory: 0 | |
|
474 | payload chunk size: 0 | |
|
475 | payload: 0 bytes | |
|
460 | 476 | part header size: 16 |
|
461 | 477 | part type: "test:ping" |
|
462 |
part id: " |
|
|
478 | part id: "6" | |
|
463 | 479 | part parameters: 0 |
|
464 | 480 | :test:ping: |
|
465 | 481 | mandatory: 0 |
@@ -468,7 +484,7 b' Test part' | |||
|
468 | 484 | payload: 0 bytes |
|
469 | 485 | part header size: 0 |
|
470 | 486 | end of bundle2 stream |
|
471 |
parts count: |
|
|
487 | parts count: 7 | |
|
472 | 488 | |
|
473 | 489 | Test actual unbundling of test part |
|
474 | 490 | ======================================= |
@@ -483,13 +499,13 b' Process the bundle' | |||
|
483 | 499 | part type: "test:empty" |
|
484 | 500 | part id: "0" |
|
485 | 501 | part parameters: 0 |
|
486 |
ignoring un |
|
|
502 | ignoring unsupported advisory part test:empty | |
|
487 | 503 | payload chunk size: 0 |
|
488 | 504 | part header size: 17 |
|
489 | 505 | part type: "test:empty" |
|
490 | 506 | part id: "1" |
|
491 | 507 | part parameters: 0 |
|
492 |
ignoring un |
|
|
508 | ignoring unsupported advisory part test:empty | |
|
493 | 509 | payload chunk size: 0 |
|
494 | 510 | part header size: 16 |
|
495 | 511 | part type: "test:song" |
@@ -513,15 +529,22 b' Process the bundle' | |||
|
513 | 529 | part type: "test:math" |
|
514 | 530 | part id: "4" |
|
515 | 531 | part parameters: 3 |
|
516 |
ignoring un |
|
|
532 | ignoring unsupported advisory part test:math | |
|
517 | 533 | payload chunk size: 2 |
|
518 | 534 | payload chunk size: 0 |
|
535 | part header size: 29 | |
|
536 | part type: "test:song" | |
|
537 | part id: "5" | |
|
538 | part parameters: 1 | |
|
539 | found a handler for part 'test:song' | |
|
540 | ignoring unsupported advisory part test:song - randomparam | |
|
541 | payload chunk size: 0 | |
|
519 | 542 | part header size: 16 |
|
520 | 543 | part type: "test:ping" |
|
521 |
part id: " |
|
|
544 | part id: "6" | |
|
522 | 545 | part parameters: 0 |
|
523 | 546 | found a handler for part 'test:ping' |
|
524 |
received ping request (id |
|
|
547 | received ping request (id 6) | |
|
525 | 548 | payload chunk size: 0 |
|
526 | 549 | part header size: 0 |
|
527 | 550 | end of bundle2 stream |
@@ -576,9 +599,9 b' The reply is a bundle' | |||
|
576 | 599 | debugreply: 'babar' |
|
577 | 600 | debugreply: 'celeste' |
|
578 | 601 | debugreply: 'ping-pong' |
|
579 |
\x00\x00\x00\x00\x00\x1e test:pong\x00\x00\x00\x02\x01\x00\x0b\x01in-reply-to |
|
|
580 |
b2x:output\x00\x00\x00\x03\x00\x01\x0b\x01in-reply-to |
|
|
581 |
replying to ping request (id |
|
|
602 | \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) | |
|
603 | b2x:output\x00\x00\x00\x03\x00\x01\x0b\x01in-reply-to7\x00\x00\x00=received ping request (id 7) (esc) | |
|
604 | replying to ping request (id 7) | |
|
582 | 605 | \x00\x00\x00\x00\x00\x00 (no-eol) (esc) |
|
583 | 606 | |
|
584 | 607 | The reply is valid |
@@ -617,8 +640,8 b' Unbundle the reply to get the output:' | |||
|
617 | 640 | remote: debugreply: 'babar' |
|
618 | 641 | remote: debugreply: 'celeste' |
|
619 | 642 | remote: debugreply: 'ping-pong' |
|
620 |
remote: received ping request (id |
|
|
621 |
remote: replying to ping request (id |
|
|
643 | remote: received ping request (id 7) | |
|
644 | remote: replying to ping request (id 7) | |
|
622 | 645 | 0 unread bytes |
|
623 | 646 | |
|
624 | 647 | Test push race detection |
General Comments 0
You need to be logged in to leave comments.
Login now