##// END OF EJS Templates
bundle2: change header size and make them signed (new format)...
Pierre-Yves David -
r23009:90f86ad3 default
parent child Browse files
Show More
@@ -31,7 +31,7 b' stream level parameters'
31 31
32 32 Binary format is as follow
33 33
34 :params size: (16 bits integer)
34 :params size: int32
35 35
36 36 The total number of Bytes used by the parameters
37 37
@@ -64,7 +64,7 b' Payload part'
64 64
65 65 Binary format is as follow
66 66
67 :header size: (16 bits inter)
67 :header size: int32
68 68
69 69 The total number of Bytes used by the part headers. When the header is empty
70 70 (size = 0) this is interpreted as the end of stream marker.
@@ -119,12 +119,15 b' Binary format is as follow'
119 119
120 120 payload is a series of `<chunksize><chunkdata>`.
121 121
122 `chunksize` is a 32 bits integer, `chunkdata` are plain bytes (as much as
122 `chunksize` is an int32, `chunkdata` are plain bytes (as much as
123 123 `chunksize` says)` The payload part is concluded by a zero size chunk.
124 124
125 125 The current implementation always produces either zero or one chunk.
126 126 This is an implementation limitation that will ultimately be lifted.
127 127
128 `chunksize` can be negative to trigger special case processing. No such
129 processing is in place yet.
130
128 131 Bundle processing
129 132 ============================
130 133
@@ -155,13 +158,13 b' from i18n import _'
155 158 _pack = struct.pack
156 159 _unpack = struct.unpack
157 160
158 _magicstring = 'HG2X'
161 _magicstring = 'HG2Y'
159 162
160 _fstreamparamsize = '>H'
161 _fpartheadersize = '>H'
163 _fstreamparamsize = '>i'
164 _fpartheadersize = '>i'
162 165 _fparttypesize = '>B'
163 166 _fpartid = '>I'
164 _fpayloadsize = '>I'
167 _fpayloadsize = '>i'
165 168 _fpartparamcount = '>BB'
166 169
167 170 preferedchunksize = 4096
@@ -496,7 +499,7 b' class unbundle20(unpackermixin):'
496 499 magic, version = header[0:2], header[2:4]
497 500 if magic != 'HG':
498 501 raise util.Abort(_('not a Mercurial bundle'))
499 if version != '2X':
502 if version != '2Y':
500 503 raise util.Abort(_('unknown bundle version %s') % version)
501 504 self.ui.debug('start processing of %s stream\n' % header)
502 505
@@ -781,7 +784,7 b' class unbundlepart(unpackermixin):'
781 784 self.consumed = True
782 785 return data
783 786
784 capabilities = {'HG2X': (),
787 capabilities = {'HG2Y': (),
785 788 'b2x:listkeys': (),
786 789 'b2x:pushkey': (),
787 790 'b2x:changegroup': (),
@@ -32,7 +32,7 b' def readbundle(ui, fh, fname, vfs=None):'
32 32 if alg is None:
33 33 alg = changegroup.readexactly(fh, 2)
34 34 return changegroup.cg1unpacker(fh, alg)
35 elif version == '2X':
35 elif version == '2Y':
36 36 return bundle2.unbundle20(ui, fh, header=magic + version)
37 37 else:
38 38 raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
@@ -1099,7 +1099,7 b' def _pullobsolete(pullop):'
1099 1099
1100 1100 def caps20to10(repo):
1101 1101 """return a set with appropriate options to use bundle20 during getbundle"""
1102 caps = set(['HG2X'])
1102 caps = set(['HG2Y'])
1103 1103 capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo))
1104 1104 caps.add('bundle2=' + urllib.quote(capsblob))
1105 1105 return caps
@@ -1132,7 +1132,7 b' def getbundle(repo, source, heads=None, '
1132 1132 **kwargs):
1133 1133 """return a full bundle (with potentially multiple kind of parts)
1134 1134
1135 Could be a bundle HG10 or a bundle HG2X depending on bundlecaps
1135 Could be a bundle HG10 or a bundle HG2Y depending on bundlecaps
1136 1136 passed. For now, the bundle can contain only changegroup, but this will
1137 1137 changes when more part type will be available for bundle2.
1138 1138
@@ -1144,7 +1144,7 b' def getbundle(repo, source, heads=None, '
1144 1144 when the API of bundle is refined.
1145 1145 """
1146 1146 # bundle10 case
1147 if bundlecaps is None or 'HG2X' not in bundlecaps:
1147 if bundlecaps is None or 'HG2Y' not in bundlecaps:
1148 1148 if bundlecaps and not kwargs.get('cg', True):
1149 1149 raise ValueError(_('request for bundle10 must include changegroup'))
1150 1150
@@ -109,7 +109,7 b' class localpeer(peer.peerrepository):'
109 109 format='HG10', **kwargs):
110 110 cg = exchange.getbundle(self._repo, source, heads=heads,
111 111 common=common, bundlecaps=bundlecaps, **kwargs)
112 if bundlecaps is not None and 'HG2X' in bundlecaps:
112 if bundlecaps is not None and 'HG2Y' in bundlecaps:
113 113 # When requesting a bundle2, getbundle returns a stream to make the
114 114 # wire level function happier. We need to build a proper object
115 115 # from it in local peer.
@@ -359,7 +359,7 b' class wirepeer(peer.peerrepository):'
359 359 opts[key] = value
360 360 f = self._callcompressable("getbundle", **opts)
361 361 bundlecaps = kwargs.get('bundlecaps')
362 if bundlecaps is not None and 'HG2X' in bundlecaps:
362 if bundlecaps is not None and 'HG2Y' in bundlecaps:
363 363 return bundle2.unbundle20(self.ui, f)
364 364 else:
365 365 return changegroupmod.cg1unpacker(f, 'UN')
@@ -234,7 +234,7 b' Empty bundle'
234 234 Test bundling
235 235
236 236 $ hg bundle2
237 HG2X\x00\x00\x00\x00 (no-eol) (esc)
237 HG2Y\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
238 238
239 239 Test unbundling
240 240
@@ -264,7 +264,7 b' Simplest possible parameters form'
264 264 Test generation simple option
265 265
266 266 $ hg bundle2 --param 'caution'
267 HG2X\x00\x07caution\x00\x00 (no-eol) (esc)
267 HG2Y\x00\x00\x00\x07caution\x00\x00\x00\x00 (no-eol) (esc)
268 268
269 269 Test unbundling
270 270
@@ -276,7 +276,7 b' Test unbundling'
276 276 Test generation multiple option
277 277
278 278 $ hg bundle2 --param 'caution' --param 'meal'
279 HG2X\x00\x0ccaution meal\x00\x00 (no-eol) (esc)
279 HG2Y\x00\x00\x00\x0ccaution meal\x00\x00\x00\x00 (no-eol) (esc)
280 280
281 281 Test unbundling
282 282
@@ -292,7 +292,7 b' advisory parameters, with value'
292 292 Test generation
293 293
294 294 $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants'
295 HG2X\x00\x1ccaution meal=vegan elephants\x00\x00 (no-eol) (esc)
295 HG2Y\x00\x00\x00\x1ccaution meal=vegan elephants\x00\x00\x00\x00 (no-eol) (esc)
296 296
297 297 Test unbundling
298 298
@@ -310,7 +310,7 b' parameter with special char in value'
310 310 Test generation
311 311
312 312 $ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple
313 HG2X\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
313 HG2Y\x00\x00\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00\x00\x00 (no-eol) (esc)
314 314
315 315 Test unbundling
316 316
@@ -334,7 +334,7 b' Test debug output'
334 334 bundling debug
335 335
336 336 $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2
337 start emission of HG2X stream
337 start emission of HG2Y stream
338 338 bundle parameter: e%7C%21%207/=babar%25%23%3D%3Dtutu simple
339 339 start of parts
340 340 end of bundle
@@ -342,12 +342,12 b' bundling debug'
342 342 file content is ok
343 343
344 344 $ cat ../out.hg2
345 HG2X\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
345 HG2Y\x00\x00\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00\x00\x00 (no-eol) (esc)
346 346
347 347 unbundling debug
348 348
349 349 $ hg statbundle2 --debug < ../out.hg2
350 start processing of HG2X stream
350 start processing of HG2Y stream
351 351 reading bundle2 stream parameters
352 352 ignoring unknown parameter 'e|! 7/'
353 353 ignoring unknown parameter 'simple'
@@ -381,7 +381,7 b' Test part'
381 381 =================
382 382
383 383 $ hg bundle2 --parts ../parts.hg2 --debug
384 start emission of HG2X stream
384 start emission of HG2Y stream
385 385 bundle parameter:
386 386 start of parts
387 387 bundle part: "test:empty"
@@ -394,11 +394,11 b' Test part'
394 394 end of bundle
395 395
396 396 $ cat ../parts.hg2
397 HG2X\x00\x00\x00\x11 (esc)
398 test:empty\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11 (esc)
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)
397 HG2Y\x00\x00\x00\x00\x00\x00\x00\x11 (esc)
398 test:empty\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11 (esc)
399 test:empty\x00\x00\x00\x01\x00\x00\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)
400 400 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
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)
401 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.\x00\x00\x00\x00\x00\x00\x00\x16\x0ftest:debugreply\x00\x00\x00\x03\x00\x00\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\x00\x00\x1d test:song\x00\x00\x00\x05\x01\x00\x0b\x00randomparam\x00\x00\x00\x00\x00\x00\x00\x10 test:ping\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
402 402
403 403
404 404 $ hg statbundle2 < ../parts.hg2
@@ -434,7 +434,7 b' Test part'
434 434 parts count: 7
435 435
436 436 $ hg statbundle2 --debug < ../parts.hg2
437 start processing of HG2X stream
437 start processing of HG2Y stream
438 438 reading bundle2 stream parameters
439 439 options count: 0
440 440 start extraction of bundle2 parts
@@ -513,7 +513,7 b' Test actual unbundling of test part'
513 513 Process the bundle
514 514
515 515 $ hg unbundle2 --debug < ../parts.hg2
516 start processing of HG2X stream
516 start processing of HG2Y stream
517 517 reading bundle2 stream parameters
518 518 start extraction of bundle2 parts
519 519 part header size: 17
@@ -607,12 +607,12 b' unbundle with a reply'
607 607 The reply is a bundle
608 608
609 609 $ cat ../reply.hg2
610 HG2X\x00\x00\x00\x1f (esc)
610 HG2Y\x00\x00\x00\x00\x00\x00\x00\x1f (esc)
611 611 b2x:output\x00\x00\x00\x00\x00\x01\x0b\x01in-reply-to3\x00\x00\x00\xd9The choir starts singing: (esc)
612 612 Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
613 613 Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
614 614 Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
615 \x00\x00\x00\x00\x00\x1f (esc)
615 \x00\x00\x00\x00\x00\x00\x00\x1f (esc)
616 616 b2x:output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to4\x00\x00\x00\xc9debugreply: capabilities: (esc)
617 617 debugreply: 'city=!'
618 618 debugreply: 'celeste,ville'
@@ -620,10 +620,10 b' The reply is a bundle'
620 620 debugreply: 'babar'
621 621 debugreply: 'celeste'
622 622 debugreply: 'ping-pong'
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)
623 \x00\x00\x00\x00\x00\x00\x00\x1e test:pong\x00\x00\x00\x02\x01\x00\x0b\x01in-reply-to7\x00\x00\x00\x00\x00\x00\x00\x1f (esc)
624 624 b2x:output\x00\x00\x00\x03\x00\x01\x0b\x01in-reply-to7\x00\x00\x00=received ping request (id 7) (esc)
625 625 replying to ping request (id 7)
626 \x00\x00\x00\x00\x00\x00 (no-eol) (esc)
626 \x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
627 627
628 628 The reply is valid
629 629
@@ -711,7 +711,7 b' Support for changegroup'
711 711 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
712 712 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
713 713 02de42196ebee42ef284b6780a87cdc96e8eaab6
714 start emission of HG2X stream
714 start emission of HG2Y stream
715 715 bundle parameter:
716 716 start of parts
717 717 bundle part: "b2x:changegroup"
@@ -729,7 +729,7 b' Support for changegroup'
729 729 end of bundle
730 730
731 731 $ cat ../rev.hg2
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)
732 HG2Y\x00\x00\x00\x00\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)
733 733 \x00\x00\x00f\x00\x00\x00h\x00\x00\x00\x02D (esc)
734 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)
735 735 \x00\x00\x00f\x00\x00\x00h\x00\x00\x00\x02E (esc)
@@ -750,7 +750,7 b' Support for changegroup'
750 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)
751 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)
752 752 \x87\xcd\xc9n\x8e\xaa\xb6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02H (esc)
753 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
753 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
754 754
755 755 $ hg unbundle2 < ../rev.hg2
756 756 adding changesets
@@ -768,12 +768,12 b' with reply'
768 768 addchangegroup return: 1
769 769
770 770 $ cat ../rev-reply.hg2
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)
771 HG2Y\x00\x00\x00\x00\x00\x00\x003\x15b2x:reply:changegroup\x00\x00\x00\x00\x00\x02\x0b\x01\x06\x01in-reply-to1return1\x00\x00\x00\x00\x00\x00\x00\x1f (esc)
772 772 b2x:output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to1\x00\x00\x00dadding changesets (esc)
773 773 adding manifests
774 774 adding file changes
775 775 added 0 changesets with 0 changes to 3 files
776 \x00\x00\x00\x00\x00\x00 (no-eol) (esc)
776 \x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
777 777
778 778 Check handling of exception during generation.
779 779 ----------------------------------------------
@@ -787,7 +787,7 b' Should still be a valid bundle'
787 787 (is currently not right)
788 788
789 789 $ cat ../genfailed.hg2
790 HG2X\x00\x00\x00\x11 (esc)
790 HG2Y\x00\x00\x00\x00\x00\x00\x00\x11 (esc)
791 791 b2x:output\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
792 792
793 793 And its handling on the other size raise a clean exception
@@ -795,7 +795,7 b' And its handling on the other size raise'
795 795
796 796 $ cat ../genfailed.hg2 | hg unbundle2
797 797 0 unread bytes
798 abort: stream ended unexpectedly (got 0 bytes, expected 2)
798 abort: stream ended unexpectedly (got 0 bytes, expected 4)
799 799 [255]
800 800
801 801
General Comments 0
You need to be logged in to leave comments. Login now