# HG changeset patch # User Pierre-Yves David # Date 2015-04-16 07:15:28 # Node ID 2ec894582ea27e240f047d689b976eed776ce17c # Parent 7d0421de8de3188d85e58cf7fe10a5b90daad179 bundle2: add a 'copy' method on parts 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 function will be used in a later patch. diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -655,6 +655,15 @@ class bundlepart(object): 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') + return self.__class__(self.type, self._mandatoryparams, + self._advisoryparams, self._data, self.mandatory) + # methods used to defines the part content def __setdata(self, data): if self._generated is not None: