comparison tests/test-bundle2.t @ 20841:cff562fe77a0

bundle2: add ability to write to a file to the test Next changesets are about improving debug output during bundling. We won't be able to simply bundle to stdin in this case. The bundle2 stream would be interleaved with debug output.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 19 Mar 2014 02:36:21 -0700
parents 8532f5e1b9df
children 938718d72624
comparison
equal deleted inserted replaced
20840:308344d80fe5 20841:cff562fe77a0
15 > cmdtable = {} 15 > cmdtable = {}
16 > command = cmdutil.command(cmdtable) 16 > command = cmdutil.command(cmdtable)
17 > 17 >
18 > @command('bundle2', 18 > @command('bundle2',
19 > [('', 'param', [], 'stream level parameter'),], 19 > [('', 'param', [], 'stream level parameter'),],
20 > '') 20 > '[OUTPUTFILE]')
21 > def cmdbundle2(ui, repo, **opts): 21 > def cmdbundle2(ui, repo, path=None, **opts):
22 > """write a bundle2 container on standard ouput""" 22 > """write a bundle2 container on standard ouput"""
23 > bundler = bundle2.bundle20() 23 > bundler = bundle2.bundle20()
24 > for p in opts['param']: 24 > for p in opts['param']:
25 > p = p.split('=', 1) 25 > p = p.split('=', 1)
26 > try: 26 > try:
27 > bundler.addparam(*p) 27 > bundler.addparam(*p)
28 > except ValueError, exc: 28 > except ValueError, exc:
29 > raise util.Abort('%s' % exc) 29 > raise util.Abort('%s' % exc)
30 > 30 >
31 > if path is None:
32 > file = sys.stdout
33 > else:
34 > file = open(path, 'w')
35 >
31 > for chunk in bundler.getchunks(): 36 > for chunk in bundler.getchunks():
32 > ui.write(chunk) 37 > file.write(chunk)
33 > 38 >
34 > @command('unbundle2', [], '') 39 > @command('unbundle2', [], '')
35 > def cmdunbundle2(ui, repo): 40 > def cmdunbundle2(ui, repo):
36 > """read a bundle2 container from standard input""" 41 > """read a bundle2 container from standard input"""
37 > unbundler = bundle2.unbundle20(sys.stdin) 42 > unbundler = bundle2.unbundle20(sys.stdin)
152 - e|! 7/ 157 - e|! 7/
153 babar%#==tutu 158 babar%#==tutu
154 - simple 159 - simple
155 parts count: 0 160 parts count: 0
156 161
162 Test debug output
163 ---------------------------------------------------
164 (no debug output yet)
165
166 $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2
167
168 file content is ok
169
170 $ cat ../out.hg2
171 HG20\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
172
157 Test buggy input 173 Test buggy input
158 --------------------------------------------------- 174 ---------------------------------------------------
159 175
160 empty parameter name 176 empty parameter name
161 177