mercurial/bundle2.py
changeset 21601 7ff01befc7ec
parent 21600 5e08f3b65510
child 21602 cc33ae50bab3
equal deleted inserted replaced
21600:5e08f3b65510 21601:7ff01befc7ec
   550         self.id = None
   550         self.id = None
   551         self.type = parttype
   551         self.type = parttype
   552         self.data = data
   552         self.data = data
   553         self.mandatoryparams = mandatoryparams
   553         self.mandatoryparams = mandatoryparams
   554         self.advisoryparams = advisoryparams
   554         self.advisoryparams = advisoryparams
   555 
   555         # status of the part's generation:
       
   556         # - None: not started,
       
   557         # - False: currently generated,
       
   558         # - True: generation done.
       
   559         self._generated = None
       
   560 
       
   561     # methods used to generates the bundle2 stream
   556     def getchunks(self):
   562     def getchunks(self):
       
   563         if self._generated is not None:
       
   564             raise RuntimeError('part can only be consumed once')
       
   565         self._generated = False
   557         #### header
   566         #### header
   558         ## parttype
   567         ## parttype
   559         header = [_pack(_fparttypesize, len(self.type)),
   568         header = [_pack(_fparttypesize, len(self.type)),
   560                   self.type, _pack(_fpartid, self.id),
   569                   self.type, _pack(_fpartid, self.id),
   561                  ]
   570                  ]
   589         for chunk in self._payloadchunks():
   598         for chunk in self._payloadchunks():
   590             yield _pack(_fpayloadsize, len(chunk))
   599             yield _pack(_fpayloadsize, len(chunk))
   591             yield chunk
   600             yield chunk
   592         # end of payload
   601         # end of payload
   593         yield _pack(_fpayloadsize, 0)
   602         yield _pack(_fpayloadsize, 0)
       
   603         self._generated = True
   594 
   604 
   595     def _payloadchunks(self):
   605     def _payloadchunks(self):
   596         """yield chunks of a the part payload
   606         """yield chunks of a the part payload
   597 
   607 
   598         Exists to handle the different methods to provide data to a part."""
   608         Exists to handle the different methods to provide data to a part."""