comparison mercurial/bundle2.py @ 26396:d90c30801cdf

bundle20: extract core payload generation in its own function We are about to allow compressing the core of the bundle2. So we extract the generation of this bits in its own parts to make this compression phases easier in a later changesets.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 23 Sep 2015 12:56:05 -0700
parents 4e7b0bf9f0b1
children 795f02a24b87
comparison
equal deleted inserted replaced
26395:4e7b0bf9f0b1 26396:d90c30801cdf
528 param = self._paramchunk() 528 param = self._paramchunk()
529 outdebug(self.ui, 'bundle parameter: %s' % param) 529 outdebug(self.ui, 'bundle parameter: %s' % param)
530 yield _pack(_fstreamparamsize, len(param)) 530 yield _pack(_fstreamparamsize, len(param))
531 if param: 531 if param:
532 yield param 532 yield param
533 533 for chunk in self._getcorechunk():
534 outdebug(self.ui, 'start of parts') 534 yield chunk
535 for part in self._parts:
536 outdebug(self.ui, 'bundle part: "%s"' % part.type)
537 for chunk in part.getchunks(ui=self.ui):
538 yield chunk
539 outdebug(self.ui, 'end of bundle')
540 yield _pack(_fpartheadersize, 0)
541 535
542 def _paramchunk(self): 536 def _paramchunk(self):
543 """return a encoded version of all stream parameters""" 537 """return a encoded version of all stream parameters"""
544 blocks = [] 538 blocks = []
545 for par, value in self._params: 539 for par, value in self._params:
547 if value is not None: 541 if value is not None:
548 value = urllib.quote(value) 542 value = urllib.quote(value)
549 par = '%s=%s' % (par, value) 543 par = '%s=%s' % (par, value)
550 blocks.append(par) 544 blocks.append(par)
551 return ' '.join(blocks) 545 return ' '.join(blocks)
546
547 def _getcorechunk(self):
548 """yield chunk for the core part of the bundle
549
550 (all but headers and parameters)"""
551 outdebug(self.ui, 'start of parts')
552 for part in self._parts:
553 outdebug(self.ui, 'bundle part: "%s"' % part.type)
554 for chunk in part.getchunks(ui=self.ui):
555 yield chunk
556 outdebug(self.ui, 'end of bundle')
557 yield _pack(_fpartheadersize, 0)
558
552 559
553 def salvageoutput(self): 560 def salvageoutput(self):
554 """return a list with a copy of all output parts in the bundle 561 """return a list with a copy of all output parts in the bundle
555 562
556 This is meant to be used during error handling to make sure we preserve 563 This is meant to be used during error handling to make sure we preserve