From patchwork Fri May 29 21:22:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7,of,8] bundle2: add generic debug output regarding generated parts From: Pierre-Yves David X-Patchwork-Id: 9394 Message-Id: <21a25fb81d2cce049c78.1432934520@waste.org> To: mercurial-devel@selenic.com Date: Fri, 29 May 2015 16:22:00 -0500 # HG changeset patch # User Pierre-Yves David # Date 1432711156 25200 # Wed May 27 00:19:16 2015 -0700 # Node ID 21a25fb81d2cce049c78a7d1d93ab9c9408de44d # Parent 1f7c0403f8be6b4b0a3c315853559580cc5e612d bundle2: add generic debug output regarding generated parts If we are about to hide the detailed debug output, we need some generic debug message to replace it in a concise way. diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -736,6 +736,29 @@ if self._generated is not None: raise RuntimeError('part can only be consumed once') self._generated = False + + if ui.debugflag: + msg = ['bundle2-output-part: "%s"' % self.type] + if not self.mandatory: + msg.append(' (advisory)') + nbmp = len(self.mandatoryparams) + nbap = len(self.advisoryparams) + if nbmp or nbap: + msg.append(' (params:') + if nbmp: + msg.append(' %i mandatory' % nbmp) + if nbap: + msg.append(' %i advisory' % nbmp) + msg.append(')') + if not self.data: + msg.append(' empty payload') + elif util.safehasattr(self.data, 'next'): + msg.append(' streamed payload') + else: + msg.append(' %i bytes payload' % len(self.data)) + msg.append('\n') + ui.debug(''.join(msg)) + #### header if self.mandatory: parttype = self.type.upper() 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 @@ -390,32 +390,39 @@ bundle2-output: bundle parameter: bundle2-output: start of parts bundle2-output: bundle part: "test:empty" + bundle2-output-part: "test:empty" (advisory) empty payload 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: "test:empty" (advisory) empty payload 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: "test:song" (advisory) 178 bytes payload 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: "test:debugreply" (advisory) empty payload 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: "test:math" (advisory) (params: 2 mandatory 2 advisory) 2 bytes payload 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: "test:song" (advisory) (params: 1 mandatory) empty payload 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: "test:ping" (advisory) empty payload bundle2-output: part 6: "test:ping" bundle2-output: header chunk size: 16 bundle2-output: closing payload chunk @@ -741,6 +748,7 @@ bundle2-output: bundle parameter: bundle2-output: start of parts bundle2-output: bundle part: "changegroup" + bundle2-output-part: "changegroup" (advisory) streamed payload bundle2-output: part 0: "changegroup" bundle2-output: header chunk size: 18 bundling: 1/4 changesets (25.00%)