From patchwork Sat Apr 12 22:08:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5,of,8] bundle2: lazily iterate over bundle part in test From: Pierre-Yves David X-Patchwork-Id: 4307 Message-Id: <279e77ed97be1e2b7ed7.1397340524@marginatus.alto.octopoid.net> To: mercurial-devel@selenic.com Cc: pierre-yves.david@ens-lyon.org Date: Sat, 12 Apr 2014 18:08:44 -0400 # HG changeset patch # User Pierre-Yves David # Date 1397242946 14400 # Fri Apr 11 15:02:26 2014 -0400 # Node ID 279e77ed97be1e2b7ed7af7ed71bfd17f43c365a # Parent 372163682f8801aaf1986c819da6a5bb03bdec76 bundle2: lazily iterate over bundle part in test We use to create a list to know the number of part in the bundle. This prevent any lazy reading as planned for real usage. The list creation is dropped. Some test output changed as debug output is interleaved with command output. diff --git a/tests/test-bundle2.t b/tests/test-bundle2.t --- a/tests/test-bundle2.t +++ b/tests/test-bundle2.t @@ -144,17 +144,18 @@ Create an extension to test bundle2 API > for key in sorted(params): > ui.write('- %s\n' % key) > value = params[key] > if value is not None: > ui.write(' %s\n' % value) - > parts = list(unbundler) - > ui.write('parts count: %i\n' % len(parts)) - > for p in parts: + > count = 0 + > for p in unbundler: + > count += 1 > ui.write(' :%s:\n' % p.type) > ui.write(' mandatory: %i\n' % len(p.mandatoryparams)) > ui.write(' advisory: %i\n' % len(p.advisoryparams)) > ui.write(' payload: %i bytes\n' % len(p.data)) + > ui.write('parts count: %i\n' % count) > EOF $ cat >> $HGRCPATH << EOF > [extensions] > bundle2=$TESTTMP/bundle2.py > [server] @@ -344,11 +345,10 @@ Test part Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.\x00\x00\x00\x00\x00+ test:math\x00\x00\x00\x03\x02\x01\x02\x04\x01\x04\x07\x03pi3.14e2.72cookingraw\x00\x00\x00\x0242\x00\x00\x00\x00\x00\x10 test:ping\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc) $ hg statbundle2 < ../parts.hg2 options count: 0 - parts count: 5 :test:empty: mandatory: 0 advisory: 0 payload: 0 bytes :test:empty: @@ -365,10 +365,11 @@ Test part payload: 2 bytes :test:ping: mandatory: 0 advisory: 0 payload: 0 bytes + parts count: 5 $ hg statbundle2 --debug < ../parts.hg2 start processing of HG20 stream reading bundle2 stream parameters options count: 0 @@ -376,55 +377,55 @@ Test part part header size: 17 part type: "test:empty" part id: "0" part parameters: 0 payload chunk size: 0 + :test:empty: + mandatory: 0 + advisory: 0 + payload: 0 bytes part header size: 17 part type: "test:empty" part id: "1" part parameters: 0 payload chunk size: 0 + :test:empty: + mandatory: 0 + advisory: 0 + payload: 0 bytes part header size: 16 part type: "test:song" part id: "2" part parameters: 0 payload chunk size: 178 payload chunk size: 0 + :test:song: + mandatory: 0 + advisory: 0 + payload: 178 bytes part header size: 43 part type: "test:math" part id: "3" part parameters: 3 payload chunk size: 2 payload chunk size: 0 + :test:math: + mandatory: 2 + advisory: 1 + payload: 2 bytes part header size: 16 part type: "test:ping" part id: "4" part parameters: 0 payload chunk size: 0 - part header size: 0 - end of bundle2 stream - parts count: 5 - :test:empty: - mandatory: 0 - advisory: 0 - payload: 0 bytes - :test:empty: - mandatory: 0 - advisory: 0 - payload: 0 bytes - :test:song: - mandatory: 0 - advisory: 0 - payload: 178 bytes - :test:math: - mandatory: 2 - advisory: 1 - payload: 2 bytes :test:ping: mandatory: 0 advisory: 0 payload: 0 bytes + part header size: 0 + end of bundle2 stream + parts count: 5 Test actual unbundling of test part ======================================= Process the bundle @@ -507,15 +508,15 @@ The reply is a bundle The reply is valid $ hg statbundle2 < ../reply.hg2 options count: 0 - parts count: 1 :test:pong: mandatory: 1 advisory: 0 payload: 0 bytes + parts count: 1 Support for changegroup =================================== $ hg unbundle $TESTDIR/bundles/rebase.hg