Submitter | Pierre-Yves David |
---|---|
Date | April 12, 2014, 10:08 p.m. |
Message ID | <279e77ed97be1e2b7ed7.1397340524@marginatus.alto.octopoid.net> |
Download | mbox | patch |
Permalink | /patch/4307/ |
State | Accepted |
Headers | show |
Comments
On Sun, Apr 13, 2014 at 12:08 AM, <pierre-yves.david@ens-lyon.org> wrote: > # HG changeset patch > # User Pierre-Yves David <pierre-yves.david@fb.com> > # 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 > for count, p in enumerate(unbundler): > > 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 > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel >
On 04/12/2014 06:21 PM, Olle wrote: > > > > On Sun, Apr 13, 2014 at 12:08 AM, <pierre-yves.david@ens-lyon.org > <mailto:pierre-yves.david@ens-lyon.org>> wrote: > > # HG changeset patch > # User Pierre-Yves David <pierre-yves.david@fb.com > <mailto:pierre-yves.david@fb.com>> > # 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 > > for count, p in enumerate(unbundler): That would need to be count = 0 for count, p in enumerate(unbundler, 1): I'm do not sure it worth it.
Patch
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