[PATCH 1 of 7] bundle2: add a 'copy' method on part

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Apr 16 14:34:12 CDT 2015



On 04/16/2015 02:15 PM, Ryan McElroy wrote:
> On 4/16/2015 2:25 AM, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david at fb.com>
>> # Date 1429168528 14400
>> #      Thu Apr 16 03:15:28 2015 -0400
>> # Node ID 878a6e0f8c834aec2cc8c50d65b9ab804644b73c
>> # Parent  d5711c886d0b1acb2d18b92bf6e8ba6d9ad0c4b3
>> bundle2: add a 'copy' method on part
>>
>> This is the first step in our quest for preserving the server output
>> on error
>> (issue4594). We want to be able to copy the output parts from the
>> aborted reply
>> into the exception bundle.
>>
>> The dunction will be used in a later patch.
>
> s/The dunction/This function/g

Sure, maybe matt can fix that inflight?

>> diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
>> --- a/mercurial/bundle2.py
>> +++ b/mercurial/bundle2.py
>> @@ -653,10 +653,19 @@ class bundlepart(object):
>>           # - False: currently generated,
>>           # - True: generation done.
>>           self._generated = None
>>           self.mandatory = mandatory
>> +    def copy(self):
>> +        """return a copy of the part
>> +
>> +        The new part have the very same content but no partid
>> assigned yet.
>> +        Parts with generated data cannot be copied."""
>> +        assert not util.safehasattr(self.data, 'next')
>
> It is nonobvious to me that 'next' refers to generated data.

'next' refer to python generator. It is used like that lower in the 
code. I can add a comment about it. I would be happy to do it after the 
freeze though.

> Also, I'd like this assert to have more debug information in it.

It is fairly clear once you known about bundle2 and python generator, 
the comment can probably cover that well. This is a developer oriented 
check (otherwise it would not be an assert)

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list