Mercurial > public > mercurial-scm > hg
comparison mercurial/bundle2.py @ 20814:8532f5e1b9df
bundle2: force the first char of parameter to be an letter.
We need a case sensitive character to convey mandatory/advisory parameter
semantic in a later patches.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 18 Mar 2014 18:56:08 -0700 |
parents | 8c74b3ce5b70 |
children | 938718d72624 |
comparison
equal
deleted
inserted
replaced
20813:8c74b3ce5b70 | 20814:8532f5e1b9df |
---|---|
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. | 48 Empty name are obviously forbidden. |
49 | 49 |
50 Name MUST start with a letter. This first character has to be capitalizable. | |
51 The capitalisation of the first letter will be used to know if an option is | |
52 advisory or mandatory. This is not implemented yet. | |
53 | |
50 Stream parameters use a simple textual format for two main reasons: | 54 Stream parameters use a simple textual format for two main reasons: |
51 | 55 |
52 - Stream level parameters should remains simple and we want to discourage any | 56 - Stream level parameters should remains simple and we want to discourage any |
53 crazy usage. | 57 crazy usage. |
54 - Textual data allow easy human inspection of a the bundle2 header in case of | 58 - Textual data allow easy human inspection of a the bundle2 header in case of |
70 """ | 74 """ |
71 | 75 |
72 import util | 76 import util |
73 import struct | 77 import struct |
74 import urllib | 78 import urllib |
79 import string | |
75 | 80 |
76 import changegroup | 81 import changegroup |
77 from i18n import _ | 82 from i18n import _ |
78 | 83 |
79 _pack = struct.pack | 84 _pack = struct.pack |
98 | 103 |
99 def addparam(self, name, value=None): | 104 def addparam(self, name, value=None): |
100 """add a stream level parameter""" | 105 """add a stream level parameter""" |
101 if not name: | 106 if not name: |
102 raise ValueError('empty parameter name') | 107 raise ValueError('empty parameter name') |
108 if name[0] not in string.letters: | |
109 raise ValueError('non letter first character: %r' % name) | |
103 self._params.append((name, value)) | 110 self._params.append((name, value)) |
104 | 111 |
105 def getchunks(self): | 112 def getchunks(self): |
106 yield _magicstring | 113 yield _magicstring |
107 param = self._paramchunk() | 114 param = self._paramchunk() |