##// END OF EJS Templates
bundle2: support chunk iterator as part data...
Pierre-Yves David -
r21001:c93bb6a0 default
parent child Browse files
Show More
@@ -161,6 +161,8 b' from i18n import _'
161 _fpayloadsize = '>I'
161 _fpayloadsize = '>I'
162 _fpartparamcount = '>BB'
162 _fpartparamcount = '>BB'
163
163
164 preferedchunksize = 4096
165
164 def _makefpartparamsizes(nbparams):
166 def _makefpartparamsizes(nbparams):
165 """return a struct format to read part parameter sizes
167 """return a struct format to read part parameter sizes
166
168
@@ -561,7 +563,13 b' class part(object):'
561 Exists to handle the different methods to provide data to a part."""
563 Exists to handle the different methods to provide data to a part."""
562 # we only support fixed size data now.
564 # we only support fixed size data now.
563 # This will be improved in the future.
565 # This will be improved in the future.
564 if len(self.data):
566 if util.safehasattr(self.data, 'next'):
567 buff = util.chunkbuffer(self.data)
568 chunk = buff.read(preferedchunksize)
569 while chunk:
570 yield chunk
571 chunk = buff.read(preferedchunksize)
572 elif len(self.data):
565 yield self.data
573 yield self.data
566
574
567 @parthandler('changegroup')
575 @parthandler('changegroup')
@@ -66,11 +66,11 b' Create an extension to test bundle2 API'
66 > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)]
66 > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)]
67 > outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing)
67 > outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing)
68 > cg = changegroup.getlocalbundle(repo, 'test:bundle2', outgoing, None)
68 > cg = changegroup.getlocalbundle(repo, 'test:bundle2', outgoing, None)
69 > assert cg is not None
69 > def cgchunks(cg=cg):
70 > # make me lazy later
70 > yield 'HG10UN'
71 > tempname = changegroup.writebundle(cg, None, 'HG10UN')
71 > for c in cg.getchunks():
72 > data = open(tempname).read()
72 > yield c
73 > part = bundle2.part('changegroup', data=data)
73 > part = bundle2.part('changegroup', data=cgchunks())
74 > bundler.addpart(part)
74 > bundler.addpart(part)
75 >
75 >
76 > if opts['parts']:
76 > if opts['parts']:
@@ -585,6 +585,10 b' Support for changegroup'
585 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
585 9520eea781bcca16c1e15acc0ba14335a0e8e5ba
586 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
586 eea13746799a9e0bfd88f29d3c2e9dc9389f524f
587 02de42196ebee42ef284b6780a87cdc96e8eaab6
587 02de42196ebee42ef284b6780a87cdc96e8eaab6
588 start emission of HG20 stream
589 bundle parameter:
590 start of parts
591 bundle part: "changegroup"
588 bundling: 1/4 changesets (25.00%)
592 bundling: 1/4 changesets (25.00%)
589 bundling: 2/4 changesets (50.00%)
593 bundling: 2/4 changesets (50.00%)
590 bundling: 3/4 changesets (75.00%)
594 bundling: 3/4 changesets (75.00%)
@@ -596,10 +600,6 b' Support for changegroup'
596 bundling: D 1/3 files (33.33%)
600 bundling: D 1/3 files (33.33%)
597 bundling: E 2/3 files (66.67%)
601 bundling: E 2/3 files (66.67%)
598 bundling: H 3/3 files (100.00%)
602 bundling: H 3/3 files (100.00%)
599 start emission of HG20 stream
600 bundle parameter:
601 start of parts
602 bundle part: "changegroup"
603 end of bundle
603 end of bundle
604
604
605 $ cat ../rev.hg2
605 $ cat ../rev.hg2
General Comments 0
You need to be logged in to leave comments. Login now