Mercurial > hg
comparison mercurial/bundle2.py @ 24793:2ec894582ea2
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 16 Apr 2015 03:15:28 -0400 |
parents | a2ef1dc3b59b |
children | 21f2e8f48ae1 |
comparison
equal
deleted
inserted
replaced
24792:7d0421de8de3 | 24793:2ec894582ea2 |
---|---|
652 # - None: not started, | 652 # - None: not started, |
653 # - False: currently generated, | 653 # - False: currently generated, |
654 # - True: generation done. | 654 # - True: generation done. |
655 self._generated = None | 655 self._generated = None |
656 self.mandatory = mandatory | 656 self.mandatory = mandatory |
657 | |
658 def copy(self): | |
659 """return a copy of the part | |
660 | |
661 The new part have the very same content but no partid assigned yet. | |
662 Parts with generated data cannot be copied.""" | |
663 assert not util.safehasattr(self.data, 'next') | |
664 return self.__class__(self.type, self._mandatoryparams, | |
665 self._advisoryparams, self._data, self.mandatory) | |
657 | 666 |
658 # methods used to defines the part content | 667 # methods used to defines the part content |
659 def __setdata(self, data): | 668 def __setdata(self, data): |
660 if self._generated is not None: | 669 if self._generated is not None: |
661 raise error.ReadOnlyPartError('part is being generated') | 670 raise error.ReadOnlyPartError('part is being generated') |