Patchwork [8,of,8] bundle2: directly feed part to readbundle

login
register
mail settings
Submitter Pierre-Yves David
Date April 12, 2014, 10:08 p.m.
Message ID <0d2c95ff44edc35fe1f3.1397340527@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4310/
State Accepted
Headers show

Comments

Pierre-Yves David - April 12, 2014, 10:08 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1397277495 14400
#      Sat Apr 12 00:38:15 2014 -0400
# Node ID 0d2c95ff44edc35fe1f35816c6b5165f33a57bfe
# Parent  192cace034eaafb08e536afd113f0b10ff0cf0e8
bundle2: directly feed part to readbundle

Now that part payload can be read like a stream, we can directly use it to feed
the unbundle10 process.
Pierre-Yves David - April 13, 2014, 6:55 p.m.
On 04/12/2014 06:08 PM, pierre-yves.david@ens-lyon.org wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1397277495 14400
> #      Sat Apr 12 00:38:15 2014 -0400
> # Node ID 0d2c95ff44edc35fe1f35816c6b5165f33a57bfe
> # Parent  192cace034eaafb08e536afd113f0b10ff0cf0e8
> bundle2: directly feed part to readbundle

this review have been reviewed in real life by matt.

The result have been clownoptorized in fb-crew.
Augie Fackler - April 14, 2014, 2:30 a.m.
On Apr 13, 2014, at 2:55 PM, Pierre-Yves David <pierre-yves.david@ens-lyon.org> wrote:

> The result have been clownoptorized in fb-crew.

For those not familiar with Phabricator's creative terminology, that means it's been queued. :)

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -142,11 +142,10 @@  preserve.
 
 import util
 import struct
 import urllib
 import string
-import StringIO
 
 import changegroup
 from i18n import _
 
 _pack = struct.pack
@@ -638,13 +637,11 @@  def handlechangegroup(op, inpart):
     #
     # The addchangegroup function will get a transaction object by itself, but
     # we need to make sure we trigger the creation of a transaction object used
     # for the whole processing scope.
     op.gettransaction()
-    data = StringIO.StringIO(inpart.read())
-    data.seek(0)
-    cg = changegroup.readbundle(data, 'bundle2part')
+    cg = changegroup.readbundle(inpart, 'bundle2part')
     ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')
     op.records.add('changegroup', {'return': ret})
     if op.reply is not None:
         # This is definitly not the final form of this
         # return. But one need to start somewhere.