Patchwork [4,of,6,main-line-of-works,(22,more,patches,to,go)] ] bundle2: add generic debug output regarding processed part payload

login
register
mail settings
Submitter Pierre-Yves David
Date May 28, 2015, 7:54 p.m.
Message ID <4112345562d77185304a.1432842861@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9337/
State Accepted
Headers show

Comments

Pierre-Yves David - May 28, 2015, 7:54 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1432709918 25200
#      Tue May 26 23:58:38 2015 -0700
# Node ID 4112345562d77185304a0fbb4b9131a851851522
# Parent  89b06c85a41c31cf00a68f784d03dadc2308d655
bundle2: add generic debug output regarding processed part payload

If we are about to hide the detailed debug output, we need some generic debug
message to replace it in a concise way.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1058,13 +1058,16 @@  class unbundlepart(unpackermixin):
             self._readheader()
         if size is None:
             data = self._payloadstream.read()
         else:
             data = self._payloadstream.read(size)
+        self._pos += len(data)
         if size is None or len(data) < size:
+            if not self.consumed and self._pos:
+                self.ui.debug('bundle2-input-part: total payload size %i\n'
+                              % self._pos)
             self.consumed = True
-        self._pos += len(data)
         return data
 
     def tell(self):
         return self._pos
 
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
@@ -498,10 +498,11 @@  Test part
     :test:song:
       mandatory: 0
       advisory: 0
   bundle2-input: payload chunk size: 178
   bundle2-input: payload chunk size: 0
+  bundle2-input-part: total payload size 178
       payload: 178 bytes
   bundle2-input: part header size: 22
   bundle2-input: part type: "test:debugreply"
   bundle2-input: part id: "3"
   bundle2-input: part parameters: 0
@@ -517,10 +518,11 @@  Test part
     :test:math:
       mandatory: 2
       advisory: 1
   bundle2-input: payload chunk size: 2
   bundle2-input: payload chunk size: 0
+  bundle2-input-part: total payload size 2
       payload: 2 bytes
   bundle2-input: part header size: 29
   bundle2-input: part type: "test:song"
   bundle2-input: part id: "5"
   bundle2-input: part parameters: 1
@@ -573,10 +575,11 @@  Process the bundle
   bundle2-input: found a handler for part 'test:song'
   bundle2-input-part: "test:song" (advisory) supported
   The choir starts singing:
   bundle2-input: payload chunk size: 178
   bundle2-input: payload chunk size: 0
+  bundle2-input-part: total payload size 178
       Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
       Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
       Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
   bundle2-input: part header size: 22
   bundle2-input: part type: "test:debugreply"
@@ -592,10 +595,11 @@  Process the bundle
   bundle2-input: part parameters: 3
   bundle2-input: ignoring unsupported advisory part test:math
   bundle2-input-part: "test:math" (advisory) (params: 2 mandatory 2 advisory) unsupported-type
   bundle2-input: payload chunk size: 2
   bundle2-input: payload chunk size: 0
+  bundle2-input-part: total payload size 2
   bundle2-input: part header size: 29
   bundle2-input: part type: "test:song"
   bundle2-input: part id: "5"
   bundle2-input: part parameters: 1
   bundle2-input: found a handler for part 'test:song'