comparison tests/test-bundle2.t @ 20856:8a6a86c9a5b5

bundle2: support bundling of empty part (with a type) Here start the work on bundle2 parts. Our first step is to be able to bundle a simplistic part that just have a type, no parameters, empty payload.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 18 Mar 2014 14:29:33 -0700
parents 2631204d7305
children 9a75d2559cff
comparison
equal deleted inserted replaced
20855:dfad9bb23ab4 20856:8a6a86c9a5b5
14 > from mercurial import bundle2 14 > from mercurial import bundle2
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 > ('', 'parts', False, 'include some arbitrary parts to the bundle'),],
20 > '[OUTPUTFILE]') 21 > '[OUTPUTFILE]')
21 > def cmdbundle2(ui, repo, path=None, **opts): 22 > def cmdbundle2(ui, repo, path=None, **opts):
22 > """write a bundle2 container on standard ouput""" 23 > """write a bundle2 container on standard ouput"""
23 > bundler = bundle2.bundle20(ui) 24 > bundler = bundle2.bundle20(ui)
24 > for p in opts['param']: 25 > for p in opts['param']:
25 > p = p.split('=', 1) 26 > p = p.split('=', 1)
26 > try: 27 > try:
27 > bundler.addparam(*p) 28 > bundler.addparam(*p)
28 > except ValueError, exc: 29 > except ValueError, exc:
29 > raise util.Abort('%s' % exc) 30 > raise util.Abort('%s' % exc)
31 >
32 > if opts['parts']:
33 > part = bundle2.part('test:empty')
34 > bundler.addpart(part)
35 > # add a second one to make sure we handle multiple parts
36 > part = bundle2.part('test:empty')
37 > bundler.addpart(part)
30 > 38 >
31 > if path is None: 39 > if path is None:
32 > file = sys.stdout 40 > file = sys.stdout
33 > else: 41 > else:
34 > file = open(path, 'w') 42 > file = open(path, 'w')
176 bundling debug 184 bundling debug
177 185
178 $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2 186 $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2
179 start emission of HG20 stream 187 start emission of HG20 stream
180 bundle parameter: e%7C%21%207/=babar%25%23%3D%3Dtutu simple 188 bundle parameter: e%7C%21%207/=babar%25%23%3D%3Dtutu simple
189 start of parts
181 end of bundle 190 end of bundle
182 191
183 file content is ok 192 file content is ok
184 193
185 $ cat ../out.hg2 194 $ cat ../out.hg2
213 bad parameter name 222 bad parameter name
214 223
215 $ hg bundle2 --param 42babar 224 $ hg bundle2 --param 42babar
216 abort: non letter first character: '42babar' 225 abort: non letter first character: '42babar'
217 [255] 226 [255]
227
228
229 Test part
230 =================
231
232 $ hg bundle2 --parts ../parts.hg2 --debug
233 start emission of HG20 stream
234 bundle parameter:
235 start of parts
236 bundle part: "test:empty"
237 bundle part: "test:empty"
238 end of bundle
239
240 $ cat ../parts.hg2
241 HG20\x00\x00\x00\r (esc)
242 test:empty\x00\x00\x00\x00\x00\x00\x00\r (esc)
243 test:empty\x00\x00\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
244
245