Patchwork [2,of,4,reviewed,by,Augie] bundle2: use chunkbuffer for exchange.getbundle

login
register
mail settings
Submitter Pierre-Yves David
Date April 12, 2014, 9:27 p.m.
Message ID <0f7e01e0c06f19b9b26c.1397338040@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4300/
State Accepted
Headers show

Comments

Pierre-Yves David - April 12, 2014, 9:27 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1397278395 14400
#      Sat Apr 12 00:53:15 2014 -0400
# Node ID 0f7e01e0c06f19b9b26c1b571a4b6de6b15d7cbd
# Parent  dda41da069a49b7dc68b7fe8d01c3b58ba315ff6
bundle2: use chunkbuffer for exchange.getbundle

We can use `util.chunkbuffer` instead.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -5,11 +5,10 @@ 
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
 from i18n import _
 from node import hex, nullid
-import cStringIO
 import errno
 import util, scmutil, changegroup, base85
 import discovery, phases, obsolete, bookmarks, bundle2
 
 
@@ -605,15 +604,11 @@  def getbundle(repo, source, heads=None, 
         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():
-        temp.write(c)
-    temp.seek(0)
-    return bundle2.unbundle20(repo.ui, temp)
+    return bundle2.unbundle20(repo.ui, util.chunkbuffer(bundler.getchunks()))
 
 class PushRaced(RuntimeError):
     """An exception raised during unbunding that indicate a push race"""
 
 def check_heads(repo, their_heads, context):