Show More
@@ -45,6 +45,8 b' Binary format is as follow' | |||||
45 | The blob contains a space separated list of parameters. parameter with value |
|
45 | The blob contains a space separated list of parameters. parameter with value | |
46 | are stored in the form `<name>=<value>`. Both name and value are urlquoted. |
|
46 | are stored in the form `<name>=<value>`. Both name and value are urlquoted. | |
47 |
|
47 | |||
|
48 | Empty name are obviously forbidden. | |||
|
49 | ||||
48 | Stream parameters use a simple textual format for two main reasons: |
|
50 | Stream parameters use a simple textual format for two main reasons: | |
49 |
|
51 | |||
50 | - Stream level parameters should remains simple and we want to discourage any |
|
52 | - Stream level parameters should remains simple and we want to discourage any | |
@@ -54,7 +56,6 b' Binary format is as follow' | |||||
54 |
|
56 | |||
55 | Any Applicative level options MUST go into a bundle2 part instead. |
|
57 | Any Applicative level options MUST go into a bundle2 part instead. | |
56 |
|
58 | |||
57 |
|
||||
58 | Payload part |
|
59 | Payload part | |
59 | ------------------------ |
|
60 | ------------------------ | |
60 |
|
61 | |||
@@ -97,6 +98,8 b' class bundle20(object):' | |||||
97 |
|
98 | |||
98 | def addparam(self, name, value=None): |
|
99 | def addparam(self, name, value=None): | |
99 | """add a stream level parameter""" |
|
100 | """add a stream level parameter""" | |
|
101 | if not name: | |||
|
102 | raise ValueError('empty parameter name') | |||
100 | self._params.append((name, value)) |
|
103 | self._params.append((name, value)) | |
101 |
|
104 | |||
102 | def getchunks(self): |
|
105 | def getchunks(self): |
@@ -10,6 +10,7 b' Create an extension to test bundle2 API' | |||||
10 | > |
|
10 | > | |
11 | > import sys |
|
11 | > import sys | |
12 | > from mercurial import cmdutil |
|
12 | > from mercurial import cmdutil | |
|
13 | > from mercurial import util | |||
13 | > from mercurial import bundle2 |
|
14 | > from mercurial import bundle2 | |
14 | > cmdtable = {} |
|
15 | > cmdtable = {} | |
15 | > command = cmdutil.command(cmdtable) |
|
16 | > command = cmdutil.command(cmdtable) | |
@@ -22,7 +23,10 b' Create an extension to test bundle2 API' | |||||
22 | > bundler = bundle2.bundle20() |
|
23 | > bundler = bundle2.bundle20() | |
23 | > for p in opts['param']: |
|
24 | > for p in opts['param']: | |
24 | > p = p.split('=', 1) |
|
25 | > p = p.split('=', 1) | |
25 | > bundler.addparam(*p) |
|
26 | > try: | |
|
27 | > bundler.addparam(*p) | |||
|
28 | > except ValueError, exc: | |||
|
29 | > raise util.Abort('%s' % exc) | |||
26 | > |
|
30 | > | |
27 | > for chunk in bundler.getchunks(): |
|
31 | > for chunk in bundler.getchunks(): | |
28 | > ui.write(chunk) |
|
32 | > ui.write(chunk) | |
@@ -149,3 +153,12 b' Test unbundling' | |||||
149 | babar%#==tutu |
|
153 | babar%#==tutu | |
150 | - simple |
|
154 | - simple | |
151 | parts count: 0 |
|
155 | parts count: 0 | |
|
156 | ||||
|
157 | Test buggy input | |||
|
158 | --------------------------------------------------- | |||
|
159 | ||||
|
160 | empty parameter name | |||
|
161 | ||||
|
162 | $ hg bundle2 --param '' --quiet | |||
|
163 | abort: empty parameter name | |||
|
164 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now