Patchwork [5,of,8] bundle2: add debug output for part generation

login
register
mail settings
Submitter Pierre-Yves David
Date May 29, 2015, 9:21 p.m.
Message ID <b44ee346211fad97f4f2.1432934518@waste.org>
Download mbox | patch
Permalink /patch/9392/
State Accepted
Headers show

Comments

Pierre-Yves David - May 29, 2015, 9:21 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1432713121 25200
#      Wed May 27 00:52:01 2015 -0700
# Node ID b44ee346211fad97f4f2497b705dc9fda6cfd092
# Parent  697d8953b04d88c5da40ccb94db289b3eeb403db
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.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -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
 
diff --git a/tests/test-bundle2-format.t b/tests/test-bundle2-format.t
--- a/tests/test-bundle2-format.t
+++ b/tests/test-bundle2-format.t
@@ -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