Submitter | Pierre-Yves David |
---|---|
Date | Sept. 25, 2015, 10:08 p.m. |
Message ID | <7057ea11718a250084a6.1443218909@marginatus.alto.octopoid.net> |
Download | mbox | patch |
Permalink | /patch/10649/ |
State | Accepted |
Headers | show |
Comments
On Fri, Sep 25, 2015 at 03:08:29PM -0700, Pierre-Yves David wrote: > # HG changeset patch > # User Pierre-Yves David <pierre-yves.david@fb.com> > # Date 1443038165 25200 > # Wed Sep 23 12:56:05 2015 -0700 > # Node ID 7057ea11718a250084a62714a311ad3af9ea5806 > # Parent aade7f779b43470319969ee00dc072e8e4fcbcc0 > bundle20: extract core payload generation in its own function Nice, queued 1-5. > > 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. > > diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py > --- a/mercurial/bundle2.py > +++ b/mercurial/bundle2.py > @@ -528,18 +528,12 @@ class bundle20(object): > param = self._paramchunk() > outdebug(self.ui, 'bundle parameter: %s' % param) > 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""" > blocks = [] > for par, value in self._params: > @@ -548,10 +542,23 @@ class bundle20(object): > value = urllib.quote(value) > par = '%s=%s' % (par, value) > 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 > > This is meant to be used during error handling to make sure we preserve > server output""" > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > https://selenic.com/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -528,18 +528,12 @@ class bundle20(object): param = self._paramchunk() outdebug(self.ui, 'bundle parameter: %s' % param) 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""" blocks = [] for par, value in self._params: @@ -548,10 +542,23 @@ class bundle20(object): value = urllib.quote(value) par = '%s=%s' % (par, value) 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 This is meant to be used during error handling to make sure we preserve server output"""