comparison mercurial/bundle2.py @ 20813:8c74b3ce5b70

bundle2: refuse empty parameter name The bundle2 now raise value error when seeing invalid parameter names. The first introduced rules is: no empty parameter. The test extension is improve to properly abort when ValueError are encountered.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 18 Mar 2014 18:40:31 -0700
parents e2f908773754
children 8532f5e1b9df
comparison
equal deleted inserted replaced
20812:e2f908773754 20813:8c74b3ce5b70
43 parameters. 43 parameters.
44 44
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
51 crazy usage. 53 crazy usage.
52 - Textual data allow easy human inspection of a the bundle2 header in case of 54 - Textual data allow easy human inspection of a the bundle2 header in case of
53 troubles. 55 troubles.
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
57 58
58 Payload part 59 Payload part
59 ------------------------ 60 ------------------------
60 61
61 Binary format is as follow 62 Binary format is as follow
95 self._params = [] 96 self._params = []
96 self._parts = [] 97 self._parts = []
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):
103 yield _magicstring 106 yield _magicstring
104 param = self._paramchunk() 107 param = self._paramchunk()