comparison mercurial/bundle2.py @ 25321:b44ee346211f

bundle2: add debug output for part generation The part generation process was lacking a ui object and could not produce debug output. It seems valuable to have some debug output on this part too, especially now that we are planning to be able to hide it in the default --debug output.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 27 May 2015 00:52:01 -0700
parents 697d8953b04d
children 1f7c0403f8be
comparison
equal deleted inserted replaced
25320:697d8953b04d 25321:b44ee346211f
481 yield param 481 yield param
482 482
483 outdebug(self.ui, 'start of parts') 483 outdebug(self.ui, 'start of parts')
484 for part in self._parts: 484 for part in self._parts:
485 outdebug(self.ui, 'bundle part: "%s"' % part.type) 485 outdebug(self.ui, 'bundle part: "%s"' % part.type)
486 for chunk in part.getchunks(): 486 for chunk in part.getchunks(ui=self.ui):
487 yield chunk 487 yield chunk
488 outdebug(self.ui, 'end of bundle') 488 outdebug(self.ui, 'end of bundle')
489 yield _pack(_fpartheadersize, 0) 489 yield _pack(_fpartheadersize, 0)
490 490
491 def _paramchunk(self): 491 def _paramchunk(self):
724 if mandatory: 724 if mandatory:
725 params = self._mandatoryparams 725 params = self._mandatoryparams
726 params.append((name, value)) 726 params.append((name, value))
727 727
728 # methods used to generates the bundle2 stream 728 # methods used to generates the bundle2 stream
729 def getchunks(self): 729 def getchunks(self, ui):
730 if self._generated is not None: 730 if self._generated is not None:
731 raise RuntimeError('part can only be consumed once') 731 raise RuntimeError('part can only be consumed once')
732 self._generated = False 732 self._generated = False
733 #### header 733 #### header
734 if self.mandatory: 734 if self.mandatory:
735 parttype = self.type.upper() 735 parttype = self.type.upper()
736 else: 736 else:
737 parttype = self.type.lower() 737 parttype = self.type.lower()
738 outdebug(ui, 'part %s: "%s"' % (self.id, parttype))
738 ## parttype 739 ## parttype
739 header = [_pack(_fparttypesize, len(parttype)), 740 header = [_pack(_fparttypesize, len(parttype)),
740 parttype, _pack(_fpartid, self.id), 741 parttype, _pack(_fpartid, self.id),
741 ] 742 ]
742 ## parameters 743 ## parameters
761 for key, value in advpar: 762 for key, value in advpar:
762 header.append(key) 763 header.append(key)
763 header.append(value) 764 header.append(value)
764 ## finalize header 765 ## finalize header
765 headerchunk = ''.join(header) 766 headerchunk = ''.join(header)
767 outdebug(ui, 'header chunk size: %i' % len(headerchunk))
766 yield _pack(_fpartheadersize, len(headerchunk)) 768 yield _pack(_fpartheadersize, len(headerchunk))
767 yield headerchunk 769 yield headerchunk
768 ## payload 770 ## payload
769 try: 771 try:
770 for chunk in self._payloadchunks(): 772 for chunk in self._payloadchunks():
773 outdebug(ui, 'payload chunk size: %i' % len(chunk))
771 yield _pack(_fpayloadsize, len(chunk)) 774 yield _pack(_fpayloadsize, len(chunk))
772 yield chunk 775 yield chunk
773 except BaseException, exc: 776 except BaseException, exc:
774 # backup exception data for later 777 # backup exception data for later
775 exc_info = sys.exc_info() 778 exc_info = sys.exc_info()
776 msg = 'unexpected error: %s' % exc 779 msg = 'unexpected error: %s' % exc
777 interpart = bundlepart('error:abort', [('message', msg)], 780 interpart = bundlepart('error:abort', [('message', msg)],
778 mandatory=False) 781 mandatory=False)
779 interpart.id = 0 782 interpart.id = 0
780 yield _pack(_fpayloadsize, -1) 783 yield _pack(_fpayloadsize, -1)
781 for chunk in interpart.getchunks(): 784 for chunk in interpart.getchunks(ui=ui):
782 yield chunk 785 yield chunk
786 outdebug(ui, 'closing payload chunk')
783 # abort current part payload 787 # abort current part payload
784 yield _pack(_fpayloadsize, 0) 788 yield _pack(_fpayloadsize, 0)
785 raise exc_info[0], exc_info[1], exc_info[2] 789 raise exc_info[0], exc_info[1], exc_info[2]
786 # end of payload 790 # end of payload
791 outdebug(ui, 'closing payload chunk')
787 yield _pack(_fpayloadsize, 0) 792 yield _pack(_fpayloadsize, 0)
788 self._generated = True 793 self._generated = True
789 794
790 def _payloadchunks(self): 795 def _payloadchunks(self):
791 """yield chunks of a the part payload 796 """yield chunks of a the part payload