From patchwork Thu May 28 16:53:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [6, of, 7, main-line-of-works, (28, more, patches, to, go)] ] bundle2: add generic debug output regarding generated parts From: Pierre-Yves David X-Patchwork-Id: 9329 Message-Id: <4cd5a7c810b47ed664d8.1432831997@marginatus.alto.octopoid.net> To: mercurial-devel@selenic.com Cc: Pierre-Yves David Date: Thu, 28 May 2015 09:53:17 -0700 # HG changeset patch # User Pierre-Yves David # Date 1432711156 25200 # Wed May 27 00:19:16 2015 -0700 # Node ID 4cd5a7c810b47ed664d868a80bff4fdb9b3c6a60 # Parent 5c49e274aa63196c3d8e20b2f28c7b185e10f47b 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 @@ -734,10 +734,33 @@ class bundlepart(object): # methods used to generates the bundle2 stream def getchunks(self, ui): 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() else: parttype = self.type.lower() 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,36 +388,43 @@ Test part bundle2-output-bundle: "HG20", 7 parts total bundle2-output: start emission of HG20 stream 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 bundle2-output: end of bundle @@ -739,10 +746,11 @@ Support for changegroup bundle2-output-bundle: "HG20", 1 parts total bundle2-output: start emission of HG20 stream 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%) bundling: 2/4 changesets (50.00%) bundling: 3/4 changesets (75.00%)