comparison mercurial/exchange.py @ 21002:dda41da069a4

bundle2: lazily generate the changegroup part in exchange.getbundle Now that we have lazy generation of parts, let's use it.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sat, 12 Apr 2014 14:56:55 -0400
parents ef377f2e0ab9
children 0f7e01e0c06f
comparison
equal deleted inserted replaced
21001:c93bb6a08fa1 21002:dda41da069a4
599 if bundlecaps is None or 'HG20' not in bundlecaps: 599 if bundlecaps is None or 'HG20' not in bundlecaps:
600 return cg 600 return cg
601 # very crude first implementation, 601 # very crude first implementation,
602 # the bundle API will change and the generation will be done lazily. 602 # the bundle API will change and the generation will be done lazily.
603 bundler = bundle2.bundle20(repo.ui) 603 bundler = bundle2.bundle20(repo.ui)
604 tempname = changegroup.writebundle(cg, None, 'HG10UN') 604 def cgchunks(cg=cg):
605 data = open(tempname).read() 605 yield 'HG10UN'
606 part = bundle2.part('changegroup', data=data) 606 for c in cg.getchunks():
607 yield c
608 part = bundle2.part('changegroup', data=cgchunks())
607 bundler.addpart(part) 609 bundler.addpart(part)
608 temp = cStringIO.StringIO() 610 temp = cStringIO.StringIO()
609 for c in bundler.getchunks(): 611 for c in bundler.getchunks():
610 temp.write(c) 612 temp.write(c)
611 temp.seek(0) 613 temp.seek(0)