Patchwork [2,of,6,main-line-of-works,(22,more,patches,to,go)] ] bundle2: add generic debug output at the end of bundle processing

login
register
mail settings
Submitter Pierre-Yves David
Date May 28, 2015, 7:54 p.m.
Message ID <7e90773b13a2e68fa30d.1432842859@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9335/
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 1432710169 25200
#      Wed May 27 00:02:49 2015 -0700
# Node ID 7e90773b13a2e68fa30db6d7fcc61e86ecbb103e
# Parent  3607f75c806f20979b3daeae9040ba5bd4ca4e9c
bundle2: add generic debug output at the end of bundle processing

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
@@ -326,17 +326,18 @@  def processbundle(repo, unbundler, trans
             msg.append(' no-transaction')
         else:
             msg.append(' with-transaction')
         msg.append('\n')
         repo.ui.debug(''.join(msg))
-    iterparts = unbundler.iterparts()
+    iterparts = enumerate(unbundler.iterparts())
     part = None
+    nbpart = 0
     try:
-        for part in iterparts:
+        for nbpart, part in iterparts:
             _processpart(op, part)
     except BaseException, exc:
-        for part in iterparts:
+        for nbpart, part in iterparts:
             # consume the bundle content
             part.seek(0, 2)
         # Small hack to let caller code distinguish exceptions from bundle2
         # processing from processing the old format. This is mostly
         # needed to handle different return codes to unbundle according to the
@@ -346,10 +347,13 @@  def processbundle(repo, unbundler, trans
         salvaged = []
         if op.reply is not None:
             salvaged = op.reply.salvageoutput()
         exc._bundle2salvagedoutput = salvaged
         raise
+    finally:
+        repo.ui.debug('bundle2-input-bundle: %i parts total\n' % nbpart)
+
     return op
 
 def _processpart(op, part):
     """process a single part from a bundle
 
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
@@ -603,10 +603,11 @@  Process the bundle
   bundle2-input: found a handler for part 'test:ping'
   received ping request (id 6)
   bundle2-input: payload chunk size: 0
   bundle2-input: part header size: 0
   bundle2-input: end of bundle2 stream
+  bundle2-input-bundle: 6 parts total
   0 unread bytes
   3 total verses sung
 
 Unbundle with an unknown mandatory part
 (should abort)