# HG changeset patch # User Pierre-Yves David # Date 1400885658 25200 # Node ID 57cd844d7a5b3a5b2ae35cac3095c256c388ea42 # Parent 1b0dbb91de5b435976822a4200d28941a2e70ab6 bundle2: have ``newpart`` automatically add the part to the bundle The created part is automatically added to the bundle as this is most certainly the intent of the user code. diff -r 1b0dbb91de5b -r 57cd844d7a5b mercurial/bundle2.py --- a/mercurial/bundle2.py Fri May 23 15:45:46 2014 -0700 +++ b/mercurial/bundle2.py Fri May 23 15:54:18 2014 -0700 @@ -381,7 +381,7 @@ class bundle20(object): """represent an outgoing bundle2 container - Use the `addparam` method to add stream level parameter. and `addpart` to + Use the `addparam` method to add stream level parameter. and `newpart` to populate it. Then call `getchunks` to retrieve all the binary chunks of data that compose the bundle2 container.""" @@ -411,6 +411,7 @@ def newpart(self, typeid, *args, **kwargs): """create a new part for the containers""" part = bundlepart(typeid, *args, **kwargs) + self.addpart(part) return part # methods used to generate the bundle2 stream @@ -712,10 +713,9 @@ if op.reply is not None: # This is definitly not the final form of this # return. But one need to start somewhere. - part = op.reply.newpart('b2x:reply:changegroup', (), - [('in-reply-to', str(inpart.id)), - ('return', '%i' % ret)]) - op.reply.addpart(part) + op.reply.newpart('b2x:reply:changegroup', (), + [('in-reply-to', str(inpart.id)), + ('return', '%i' % ret)]) assert not inpart.read() @parthandler('b2x:reply:changegroup')