[PATCH 1 of 5 modernize-streamclone] bundle2: implement unbundlepart.readline()

Gregory Szorc gregory.szorc at gmail.com
Sun Oct 4 20:29:45 CDT 2015


On Sun, Oct 4, 2015 at 2:18 PM, Pierre-Yves David <
pierre-yves.david at ens-lyon.org> wrote:

>
>
> On 10/04/2015 01:11 PM, Gregory Szorc wrote:
>
>> # HG changeset patch
>> # User Gregory Szorc <gregory.szorc at gmail.com>
>> # Date 1443823506 25200
>> #      Fri Oct 02 15:05:06 2015 -0700
>> # Node ID 28a2967528155aac6fbabf642061aa3ba1360be0
>> # Parent  22f27f7f4ef3933ee604be645ae79f84ca2f5b99
>> bundle2: implement unbundlepart.readline()
>>
>> This is used by the stream clone consuming code. readline() is also part
>> of the standard file object API, so someone else is likely going to want
>> this sooner or later.
>>
>> diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
>> --- a/mercurial/bundle2.py
>> +++ b/mercurial/bundle2.py
>> @@ -1130,8 +1130,21 @@ class unbundlepart(unpackermixin):
>>                                 % self._pos)
>>               self.consumed = True
>>           return data
>>
>> +    def readline(self):
>> +        chars = []
>> +        while True:
>> +            c = self.read(1)
>>
>
> urg, but I assume this is what python is doing internally anyway.
>
> I'm not sure how our implementation of read behave there. Can you double
> check this? I would like to avoid reallocation a 4k block one byte at a
> time until it is consumed.
>

The piece I need this for is slurping the file count and payload size
header line off the stream. In a bundle2 world, I could make these bundle2
part parameters and not require readline. I'll just drop this patch from
the resend and work in additional refactoring of the reading code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20151004/38a6402c/attachment.html>


More information about the Mercurial-devel mailing list