##// END OF EJS Templates
bundle2: transmit exception during part generation...
Pierre-Yves David -
r23067:420a0516 stable
parent child Browse files
Show More
@@ -145,6 +145,7 future, dropping the stream may become a
145 145 preserve.
146 146 """
147 147
148 import sys
148 149 import util
149 150 import struct
150 151 import urllib
@@ -673,9 +674,22 class bundlepart(object):
673 674 yield _pack(_fpartheadersize, len(headerchunk))
674 675 yield headerchunk
675 676 ## payload
677 try:
676 678 for chunk in self._payloadchunks():
677 679 yield _pack(_fpayloadsize, len(chunk))
678 680 yield chunk
681 except Exception, exc:
682 # backup exception data for later
683 exc_info = sys.exc_info()
684 msg = 'unexpected error: %s' % exc
685 interpart = bundlepart('b2x:error:abort', [('message', msg)])
686 interpart.id = 0
687 yield _pack(_fpayloadsize, -1)
688 for chunk in interpart.getchunks():
689 yield chunk
690 # abort current part payload
691 yield _pack(_fpayloadsize, 0)
692 raise exc_info[0], exc_info[1], exc_info[2]
679 693 # end of payload
680 694 yield _pack(_fpayloadsize, 0)
681 695 self._generated = True
@@ -777,25 +777,22 with reply
777 777
778 778 Check handling of exception during generation.
779 779 ----------------------------------------------
780 (is currently not right)
781 780
782 781 $ hg bundle2 --genraise > ../genfailed.hg2
783 782 abort: Someone set up us the bomb!
784 783 [255]
785 784
786 785 Should still be a valid bundle
787 (is currently not right)
788 786
789 787 $ cat ../genfailed.hg2
790 788 HG2Y\x00\x00\x00\x00\x00\x00\x00\x11 (esc)
791 b2x:output\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
789 b2x:output\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00L\x0fb2x:error:abort\x00\x00\x00\x00\x01\x00\x07-messageunexpected error: Someone set up us the bomb!\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
792 790
793 791 And its handling on the other size raise a clean exception
794 (is currently not right)
795 792
796 793 $ cat ../genfailed.hg2 | hg unbundle2
797 794 0 unread bytes
798 abort: stream ended unexpectedly (got 0 bytes, expected 4)
795 abort: unexpected error: Someone set up us the bomb!
799 796 [255]
800 797
801 798
General Comments 0
You need to be logged in to leave comments. Login now