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.
--- a/mercurial/bundle2.py Wed Sep 23 14:00:16 2015 -0700
+++ b/mercurial/bundle2.py Wed Sep 23 12:56:05 2015 -0700
@@ -530,14 +530,8 @@
yield _pack(_fstreamparamsize, len(param))
if param:
yield param
-
- outdebug(self.ui, 'start of parts')
- for part in self._parts:
- outdebug(self.ui, 'bundle part: "%s"' % part.type)
- for chunk in part.getchunks(ui=self.ui):
- yield chunk
- outdebug(self.ui, 'end of bundle')
- yield _pack(_fpartheadersize, 0)
+ for chunk in self._getcorechunk():
+ yield chunk
def _paramchunk(self):
"""return a encoded version of all stream parameters"""
@@ -550,6 +544,19 @@
blocks.append(par)
return ' '.join(blocks)
+ def _getcorechunk(self):
+ """yield chunk for the core part of the bundle
+
+ (all but headers and parameters)"""
+ outdebug(self.ui, 'start of parts')
+ for part in self._parts:
+ outdebug(self.ui, 'bundle part: "%s"' % part.type)
+ for chunk in part.getchunks(ui=self.ui):
+ yield chunk
+ outdebug(self.ui, 'end of bundle')
+ yield _pack(_fpartheadersize, 0)
+
+
def salvageoutput(self):
"""return a list with a copy of all output parts in the bundle