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