changeset 25333:5bfffdbdc907

bundle2: add generic debug output regarding processed part If we are about to hide the detailed debug output, we need some generic debug message to replace it.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 26 May 2015 23:36:31 -0700
parents 0cdd1c811705
children 76cba1ecf55f
files mercurial/bundle2.py tests/test-bundle2-format.t
diffstat 2 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Wed May 27 00:02:49 2015 -0700
+++ b/mercurial/bundle2.py	Tue May 26 23:36:31 2015 -0700
@@ -359,23 +359,43 @@
 
     The part is guaranteed to have been fully consumed when the function exits
     (even if an exception is raised)."""
+    status = 'unknown' # used by debug output
     try:
         try:
             handler = parthandlermapping.get(part.type)
             if handler is None:
+                status = 'unsupported-type'
                 raise error.UnsupportedPartError(parttype=part.type)
             indebug(op.ui, 'found a handler for part %r' % part.type)
             unknownparams = part.mandatorykeys - handler.params
             if unknownparams:
                 unknownparams = list(unknownparams)
                 unknownparams.sort()
+                status = 'unsupported-params (%s)' % unknownparams
                 raise error.UnsupportedPartError(parttype=part.type,
                                                params=unknownparams)
+            status = 'supported'
         except error.UnsupportedPartError, exc:
             if part.mandatory: # mandatory parts
                 raise
             indebug(op.ui, 'ignoring unsupported advisory part %s' % exc)
             return # skip to part processing
+        finally:
+            if op.ui.debugflag:
+                msg = ['bundle2-input-part: "%s"' % part.type]
+                if not part.mandatory:
+                    msg.append(' (advisory)')
+                nbmp = len(part.mandatorykeys)
+                nbap = len(part.params) - nbmp
+                if nbmp or nbap:
+                    msg.append(' (params:')
+                    if nbmp:
+                        msg.append(' %i mandatory' % nbmp)
+                    if nbap:
+                        msg.append(' %i advisory' % nbmp)
+                    msg.append(')')
+                msg.append(' %s\n' % status)
+                op.ui.debug(''.join(msg))
 
         # handler is called outside the above try block so that we don't
         # risk catching KeyErrors from anything other than the
--- a/tests/test-bundle2-format.t	Wed May 27 00:02:49 2015 -0700
+++ b/tests/test-bundle2-format.t	Tue May 26 23:36:31 2015 -0700
@@ -557,18 +557,21 @@
   bundle2-input: part id: "0"
   bundle2-input: part parameters: 0
   bundle2-input: ignoring unsupported advisory part test:empty
+  bundle2-input-part: "test:empty" (advisory) unsupported-type
   bundle2-input: payload chunk size: 0
   bundle2-input: part header size: 17
   bundle2-input: part type: "test:empty"
   bundle2-input: part id: "1"
   bundle2-input: part parameters: 0
   bundle2-input: ignoring unsupported advisory part test:empty
+  bundle2-input-part: "test:empty" (advisory) unsupported-type
   bundle2-input: payload chunk size: 0
   bundle2-input: part header size: 16
   bundle2-input: part type: "test:song"
   bundle2-input: part id: "2"
   bundle2-input: part parameters: 0
   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
@@ -580,6 +583,7 @@
   bundle2-input: part id: "3"
   bundle2-input: part parameters: 0
   bundle2-input: found a handler for part 'test:debugreply'
+  bundle2-input-part: "test:debugreply" (advisory) supported
   debugreply: no reply
   bundle2-input: payload chunk size: 0
   bundle2-input: part header size: 43
@@ -587,6 +591,7 @@
   bundle2-input: part id: "4"
   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 header size: 29
@@ -595,12 +600,14 @@
   bundle2-input: part parameters: 1
   bundle2-input: found a handler for part 'test:song'
   bundle2-input: ignoring unsupported advisory part test:song - randomparam
+  bundle2-input-part: "test:song" (advisory) (params: 1 mandatory) unsupported-params (['randomparam'])
   bundle2-input: payload chunk size: 0
   bundle2-input: part header size: 16
   bundle2-input: part type: "test:ping"
   bundle2-input: part id: "6"
   bundle2-input: part parameters: 0
   bundle2-input: found a handler for part 'test:ping'
+  bundle2-input-part: "test:ping" (advisory) supported
   received ping request (id 6)
   bundle2-input: payload chunk size: 0
   bundle2-input: part header size: 0