Mercurial > hg-stable
changeset 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 |
files | mercurial/bundle2.py tests/test-bundle2-format.t |
diffstat | 2 files changed, 35 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Tue May 26 23:01:39 2015 -0700 +++ b/mercurial/bundle2.py Wed May 27 00:52:01 2015 -0700 @@ -483,7 +483,7 @@ outdebug(self.ui, 'start of parts') for part in self._parts: outdebug(self.ui, 'bundle part: "%s"' % part.type) - for chunk in part.getchunks(): + for chunk in part.getchunks(ui=self.ui): yield chunk outdebug(self.ui, 'end of bundle') yield _pack(_fpartheadersize, 0) @@ -726,7 +726,7 @@ params.append((name, value)) # methods used to generates the bundle2 stream - def getchunks(self): + def getchunks(self, ui): if self._generated is not None: raise RuntimeError('part can only be consumed once') self._generated = False @@ -735,6 +735,7 @@ parttype = self.type.upper() else: parttype = self.type.lower() + outdebug(ui, 'part %s: "%s"' % (self.id, parttype)) ## parttype header = [_pack(_fparttypesize, len(parttype)), parttype, _pack(_fpartid, self.id), @@ -763,11 +764,13 @@ header.append(value) ## finalize header headerchunk = ''.join(header) + outdebug(ui, 'header chunk size: %i' % len(headerchunk)) yield _pack(_fpartheadersize, len(headerchunk)) yield headerchunk ## payload try: for chunk in self._payloadchunks(): + outdebug(ui, 'payload chunk size: %i' % len(chunk)) yield _pack(_fpayloadsize, len(chunk)) yield chunk except BaseException, exc: @@ -778,12 +781,14 @@ mandatory=False) interpart.id = 0 yield _pack(_fpayloadsize, -1) - for chunk in interpart.getchunks(): + for chunk in interpart.getchunks(ui=ui): yield chunk + outdebug(ui, 'closing payload chunk') # abort current part payload yield _pack(_fpayloadsize, 0) raise exc_info[0], exc_info[1], exc_info[2] # end of payload + outdebug(ui, 'closing payload chunk') yield _pack(_fpayloadsize, 0) self._generated = True
--- a/tests/test-bundle2-format.t Tue May 26 23:01:39 2015 -0700 +++ b/tests/test-bundle2-format.t Wed May 27 00:52:01 2015 -0700 @@ -388,12 +388,35 @@ bundle2-output: bundle parameter: bundle2-output: start of parts bundle2-output: bundle part: "test:empty" + bundle2-output: part 0: "test:empty" + bundle2-output: header chunk size: 17 + bundle2-output: closing payload chunk bundle2-output: bundle part: "test:empty" + bundle2-output: part 1: "test:empty" + bundle2-output: header chunk size: 17 + bundle2-output: closing payload chunk bundle2-output: bundle part: "test:song" + bundle2-output: part 2: "test:song" + bundle2-output: header chunk size: 16 + bundle2-output: payload chunk size: 178 + bundle2-output: closing payload chunk bundle2-output: bundle part: "test:debugreply" + bundle2-output: part 3: "test:debugreply" + bundle2-output: header chunk size: 22 + bundle2-output: closing payload chunk bundle2-output: bundle part: "test:math" + bundle2-output: part 4: "test:math" + bundle2-output: header chunk size: 43 + bundle2-output: payload chunk size: 2 + bundle2-output: closing payload chunk bundle2-output: bundle part: "test:song" + bundle2-output: part 5: "test:song" + bundle2-output: header chunk size: 29 + bundle2-output: closing payload chunk bundle2-output: bundle part: "test:ping" + bundle2-output: part 6: "test:ping" + bundle2-output: header chunk size: 16 + bundle2-output: closing payload chunk bundle2-output: end of bundle $ cat ../parts.hg2 @@ -715,6 +738,8 @@ bundle2-output: bundle parameter: bundle2-output: start of parts bundle2-output: bundle part: "changegroup" + bundle2-output: part 0: "changegroup" + bundle2-output: header chunk size: 18 bundling: 1/4 changesets (25.00%) bundling: 2/4 changesets (50.00%) bundling: 3/4 changesets (75.00%) @@ -726,6 +751,8 @@ bundling: D 1/3 files (33.33%) bundling: E 2/3 files (66.67%) bundling: H 3/3 files (100.00%) + bundle2-output: payload chunk size: 1555 + bundle2-output: closing payload chunk bundle2-output: end of bundle $ cat ../rev.hg2