##// END OF EJS Templates
bundle2: print debug information during unbundling...
bundle2: print debug information during unbundling The unbundler class is now feed with an ui object and use it to transmit data about the unbundling process.

File last commit:

r20843:0641b41b default
r20843:0641b41b default
Show More
test-bundle2.t
204 lines | 4.6 KiB | text/troff | Tads3Lexer
Pierre-Yves David
bundle2: very first version of a bundle2 bundler...
r20801
Create an extension to test bundle2 API
$ cat > bundle2.py << EOF
> """A small extension to test bundle2 implementation
>
> Current bundle2 implementation is far too limited to be used in any core
> code. We still need to be able to test it while it grow up.
> """
>
Pierre-Yves David
bundle2: a very first version of bundle2 unbundler...
r20802 > import sys
Pierre-Yves David
bundle2: very first version of a bundle2 bundler...
r20801 > from mercurial import cmdutil
Pierre-Yves David
bundle2: refuse empty parameter name...
r20813 > from mercurial import util
Pierre-Yves David
bundle2: very first version of a bundle2 bundler...
r20801 > from mercurial import bundle2
> cmdtable = {}
> command = cmdutil.command(cmdtable)
>
Pierre-Yves David
bundle2: support bundling simple parameter...
r20804 > @command('bundle2',
> [('', 'param', [], 'stream level parameter'),],
Pierre-Yves David
bundle2: add ability to write to a file to the test...
r20841 > '[OUTPUTFILE]')
> def cmdbundle2(ui, repo, path=None, **opts):
Pierre-Yves David
bundle2: very first version of a bundle2 bundler...
r20801 > """write a bundle2 container on standard ouput"""
Pierre-Yves David
bundle2: print debug information during bundling...
r20842 > bundler = bundle2.bundle20(ui)
Pierre-Yves David
bundle2: support bundling simple parameter...
r20804 > for p in opts['param']:
Pierre-Yves David
bundle2: support for bundling parameter value...
r20809 > p = p.split('=', 1)
Pierre-Yves David
bundle2: refuse empty parameter name...
r20813 > try:
> bundler.addparam(*p)
> except ValueError, exc:
> raise util.Abort('%s' % exc)
Pierre-Yves David
bundle2: support for bundling parameter value...
r20809 >
Pierre-Yves David
bundle2: add ability to write to a file to the test...
r20841 > if path is None:
> file = sys.stdout
> else:
> file = open(path, 'w')
>
Pierre-Yves David
bundle2: support bundling simple parameter...
r20804 > for chunk in bundler.getchunks():
Pierre-Yves David
bundle2: add ability to write to a file to the test...
r20841 > file.write(chunk)
Pierre-Yves David
bundle2: a very first version of bundle2 unbundler...
r20802 >
> @command('unbundle2', [], '')
> def cmdunbundle2(ui, repo):
> """read a bundle2 container from standard input"""
Pierre-Yves David
bundle2: print debug information during unbundling...
r20843 > unbundler = bundle2.unbundle20(ui, sys.stdin)
Pierre-Yves David
bundle2: a very first version of bundle2 unbundler...
r20802 > ui.write('options count: %i\n' % len(unbundler.params))
Pierre-Yves David
bundle2: support for unbundling simple parameter...
r20805 > for key in sorted(unbundler.params):
> ui.write('- %s\n' % key)
Pierre-Yves David
bundle2: support for unbundling parameter value...
r20810 > value = unbundler.params[key]
> if value is not None:
> ui.write(' %s\n' % value)
Pierre-Yves David
bundle2: a very first version of bundle2 unbundler...
r20802 > parts = list(unbundler)
> ui.write('parts count: %i\n' % len(parts))
Pierre-Yves David
bundle2: very first version of a bundle2 bundler...
r20801 > EOF
$ cat >> $HGRCPATH << EOF
> [extensions]
> bundle2=$TESTTMP/bundle2.py
> EOF
The extension requires a repo (currently unused)
$ hg init main
$ cd main
Pierre-Yves David
bundle2: make sure the unbundler refuse non bundle2 stream...
r20803 $ touch a
$ hg add a
$ hg commit -m 'a'
Pierre-Yves David
bundle2: very first version of a bundle2 bundler...
r20801
Pierre-Yves David
bundle2: support bundling simple parameter...
r20804
Empty bundle
=================
- no option
- no parts
Test bundling
Pierre-Yves David
bundle2: very first version of a bundle2 bundler...
r20801
$ hg bundle2
HG20\x00\x00\x00\x00 (no-eol) (esc)
Pierre-Yves David
bundle2: a very first version of bundle2 unbundler...
r20802
Pierre-Yves David
bundle2: support bundling simple parameter...
r20804 Test unbundling
Pierre-Yves David
bundle2: a very first version of bundle2 unbundler...
r20802
$ hg bundle2 | hg unbundle2
options count: 0
parts count: 0
Pierre-Yves David
bundle2: make sure the unbundler refuse non bundle2 stream...
r20803
Test old style bundle are detected and refused
$ hg bundle --all ../bundle.hg
1 changesets found
$ hg unbundle2 < ../bundle.hg
abort: unknown bundle version 10
[255]
Pierre-Yves David
bundle2: support bundling simple parameter...
r20804
Test parameters
=================
- some options
- no parts
advisory parameters, no value
-------------------------------
Simplest possible parameters form
Pierre-Yves David
bundle2: support for unbundling simple parameter...
r20805 Test generation simple option
Pierre-Yves David
bundle2: support bundling simple parameter...
r20804
$ hg bundle2 --param 'caution'
HG20\x00\x07caution\x00\x00 (no-eol) (esc)
Pierre-Yves David
bundle2: support for unbundling simple parameter...
r20805 Test unbundling
$ hg bundle2 --param 'caution' | hg unbundle2
options count: 1
- caution
parts count: 0
Pierre-Yves David
bundle2: support bundling simple parameter...
r20804 Test generation multiple option
$ hg bundle2 --param 'caution' --param 'meal'
HG20\x00\x0ccaution meal\x00\x00 (no-eol) (esc)
Pierre-Yves David
bundle2: support for unbundling simple parameter...
r20805
Test unbundling
$ hg bundle2 --param 'caution' --param 'meal' | hg unbundle2
options count: 2
- caution
- meal
parts count: 0
Pierre-Yves David
bundle2: support for bundling parameter value...
r20809 advisory parameters, with value
-------------------------------
Test generation
$ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants'
HG20\x00\x1ccaution meal=vegan elephants\x00\x00 (no-eol) (esc)
Pierre-Yves David
bundle2: support for unbundling parameter value...
r20810 Test unbundling
$ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants' | hg unbundle2
options count: 3
- caution
- elephants
- meal
vegan
parts count: 0
Pierre-Yves David
bundle2: urlquote stream parameter name and value...
r20811
parameter with special char in value
---------------------------------------------------
Test generation
$ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple
HG20\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
Pierre-Yves David
bundle2: urlunquote stream parameter name and value during unbundling...
r20812
Test unbundling
$ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple | hg unbundle2
options count: 2
- e|! 7/
babar%#==tutu
- simple
parts count: 0
Pierre-Yves David
bundle2: refuse empty parameter name...
r20813
Pierre-Yves David
bundle2: add ability to write to a file to the test...
r20841 Test debug output
---------------------------------------------------
Pierre-Yves David
bundle2: print debug information during unbundling...
r20843 bundling debug
Pierre-Yves David
bundle2: add ability to write to a file to the test...
r20841 $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2
Pierre-Yves David
bundle2: print debug information during bundling...
r20842 start emission of HG20 stream
bundle parameter: e%7C%21%207/=babar%25%23%3D%3Dtutu simple
end of bundle
Pierre-Yves David
bundle2: add ability to write to a file to the test...
r20841
file content is ok
$ cat ../out.hg2
HG20\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
Pierre-Yves David
bundle2: print debug information during unbundling...
r20843 unbundling debug
$ hg unbundle2 --debug < ../out.hg2
start processing of HG20 stream
reading bundle2 stream parameters
options count: 2
- e|! 7/
babar%#==tutu
- simple
start extraction of bundle2 parts
end of bundle2 stream
parts count: 0
Pierre-Yves David
bundle2: refuse empty parameter name...
r20813 Test buggy input
---------------------------------------------------
empty parameter name
$ hg bundle2 --param '' --quiet
abort: empty parameter name
[255]
Pierre-Yves David
bundle2: force the first char of parameter to be an letter....
r20814
bad parameter name
$ hg bundle2 --param 42babar
abort: non letter first character: '42babar'
[255]