changeset 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 c93bb6a08fa1
children 0f7e01e0c06f
files mercurial/exchange.py
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Fri Apr 11 08:04:16 2014 -0700
+++ b/mercurial/exchange.py	Sat Apr 12 14:56:55 2014 -0400
@@ -601,9 +601,11 @@
     # very crude first implementation,
     # the bundle API will change and the generation will be done lazily.
     bundler = bundle2.bundle20(repo.ui)
-    tempname = changegroup.writebundle(cg, None, 'HG10UN')
-    data = open(tempname).read()
-    part = bundle2.part('changegroup', data=data)
+    def cgchunks(cg=cg):
+        yield 'HG10UN'
+        for c in cg.getchunks():
+            yield c
+    part = bundle2.part('changegroup', data=cgchunks())
     bundler.addpart(part)
     temp = cStringIO.StringIO()
     for c in bundler.getchunks():