--- a/mercurial/bundle2.py Fri May 23 15:59:19 2014 -0700
+++ b/mercurial/bundle2.py Thu May 22 11:14:02 2014 -0700
@@ -552,8 +552,17 @@
self.data = data
self.mandatoryparams = mandatoryparams
self.advisoryparams = advisoryparams
+ # status of the part's generation:
+ # - None: not started,
+ # - False: currently generated,
+ # - True: generation done.
+ self._generated = None
+ # methods used to generates the bundle2 stream
def getchunks(self):
+ if self._generated is not None:
+ raise RuntimeError('part can only be consumed once')
+ self._generated = False
#### header
## parttype
header = [_pack(_fparttypesize, len(self.type)),
@@ -591,6 +600,7 @@
yield chunk
# end of payload
yield _pack(_fpayloadsize, 0)
+ self._generated = True
def _payloadchunks(self):
"""yield chunks of a the part payload