test-bundle2.t
134 lines
| 3.0 KiB
| text/troff
|
Tads3Lexer
/ tests / test-bundle2.t
|
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. | ||||
> """ | ||||
> | ||||
|
r20802 | > import sys | ||
|
r20801 | > from mercurial import cmdutil | ||
> from mercurial import bundle2 | ||||
> cmdtable = {} | ||||
> command = cmdutil.command(cmdtable) | ||||
> | ||||
|
r20804 | > @command('bundle2', | ||
> [('', 'param', [], 'stream level parameter'),], | ||||
> '') | ||||
> def cmdbundle2(ui, repo, **opts): | ||||
|
r20801 | > """write a bundle2 container on standard ouput""" | ||
|
r20804 | > bundler = bundle2.bundle20() | ||
> for p in opts['param']: | ||||
|
r20809 | > p = p.split('=', 1) | ||
> bundler.addparam(*p) | ||||
> | ||||
|
r20804 | > for chunk in bundler.getchunks(): | ||
|
r20801 | > ui.write(chunk) | ||
|
r20802 | > | ||
> @command('unbundle2', [], '') | ||||
> def cmdunbundle2(ui, repo): | ||||
> """read a bundle2 container from standard input""" | ||||
> unbundler = bundle2.unbundle20(sys.stdin) | ||||
> ui.write('options count: %i\n' % len(unbundler.params)) | ||||
|
r20805 | > for key in sorted(unbundler.params): | ||
> ui.write('- %s\n' % key) | ||||
|
r20810 | > value = unbundler.params[key] | ||
> if value is not None: | ||||
> ui.write(' %s\n' % value) | ||||
|
r20802 | > parts = list(unbundler) | ||
> ui.write('parts count: %i\n' % len(parts)) | ||||
|
r20801 | > EOF | ||
$ cat >> $HGRCPATH << EOF | ||||
> [extensions] | ||||
> bundle2=$TESTTMP/bundle2.py | ||||
> EOF | ||||
The extension requires a repo (currently unused) | ||||
$ hg init main | ||||
$ cd main | ||||
|
r20803 | $ touch a | ||
$ hg add a | ||||
$ hg commit -m 'a' | ||||
|
r20801 | |||
|
r20804 | |||
Empty bundle | ||||
================= | ||||
- no option | ||||
- no parts | ||||
Test bundling | ||||
|
r20801 | |||
$ hg bundle2 | ||||
HG20\x00\x00\x00\x00 (no-eol) (esc) | ||||
|
r20802 | |||
|
r20804 | Test unbundling | ||
|
r20802 | |||
$ hg bundle2 | hg unbundle2 | ||||
options count: 0 | ||||
parts count: 0 | ||||
|
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] | ||||
|
r20804 | |||
Test parameters | ||||
================= | ||||
- some options | ||||
- no parts | ||||
advisory parameters, no value | ||||
------------------------------- | ||||
Simplest possible parameters form | ||||
|
r20805 | Test generation simple option | ||
|
r20804 | |||
$ hg bundle2 --param 'caution' | ||||
HG20\x00\x07caution\x00\x00 (no-eol) (esc) | ||||
|
r20805 | Test unbundling | ||
$ hg bundle2 --param 'caution' | hg unbundle2 | ||||
options count: 1 | ||||
- caution | ||||
parts count: 0 | ||||
|
r20804 | Test generation multiple option | ||
$ hg bundle2 --param 'caution' --param 'meal' | ||||
HG20\x00\x0ccaution meal\x00\x00 (no-eol) (esc) | ||||
|
r20805 | |||
Test unbundling | ||||
$ hg bundle2 --param 'caution' --param 'meal' | hg unbundle2 | ||||
options count: 2 | ||||
- caution | ||||
- meal | ||||
parts count: 0 | ||||
|
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) | ||||
|
r20810 | Test unbundling | ||
$ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants' | hg unbundle2 | ||||
options count: 3 | ||||
- caution | ||||
- elephants | ||||
- meal | ||||
vegan | ||||
parts count: 0 | ||||