# HG changeset patch # User Pierre-Yves David # Date 2014-05-23 22:54:18 # 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 --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -381,7 +381,7 @@ def encodecaps(caps): 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 @@ class bundle20(object): 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 @@ def handlechangegroup(op, inpart): 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')