Show More
@@ -102,6 +102,33 b' class bundlespec:' | |||||
102 | _bundlespecv1compengines = {b'gzip', b'bzip2', b'none'} |
|
102 | _bundlespecv1compengines = {b'gzip', b'bzip2', b'none'} | |
103 |
|
103 | |||
104 |
|
104 | |||
|
105 | def _parseparams(s): | |||
|
106 | """parse bundlespec parameter section | |||
|
107 | ||||
|
108 | input: "comp-version;params" string | |||
|
109 | ||||
|
110 | return: (spec; {param_key: param_value}) | |||
|
111 | """ | |||
|
112 | if b';' not in s: | |||
|
113 | return s, {} | |||
|
114 | ||||
|
115 | params = {} | |||
|
116 | version, paramstr = s.split(b';', 1) | |||
|
117 | ||||
|
118 | err = _(b'invalid bundle specification: missing "=" in parameter: %s') | |||
|
119 | for p in paramstr.split(b';'): | |||
|
120 | if b'=' not in p: | |||
|
121 | msg = err % p | |||
|
122 | raise error.InvalidBundleSpecification(msg) | |||
|
123 | ||||
|
124 | key, value = p.split(b'=', 1) | |||
|
125 | key = urlreq.unquote(key) | |||
|
126 | value = urlreq.unquote(value) | |||
|
127 | params[key] = value | |||
|
128 | ||||
|
129 | return version, params | |||
|
130 | ||||
|
131 | ||||
105 | def parsebundlespec(repo, spec, strict=True): |
|
132 | def parsebundlespec(repo, spec, strict=True): | |
106 | """Parse a bundle string specification into parts. |
|
133 | """Parse a bundle string specification into parts. | |
107 |
|
134 | |||
@@ -135,31 +162,6 b' def parsebundlespec(repo, spec, strict=T' | |||||
135 | Note: this function will likely eventually return a more complex data |
|
162 | Note: this function will likely eventually return a more complex data | |
136 | structure, including bundle2 part information. |
|
163 | structure, including bundle2 part information. | |
137 | """ |
|
164 | """ | |
138 |
|
||||
139 | def parseparams(s): |
|
|||
140 | if b';' not in s: |
|
|||
141 | return s, {} |
|
|||
142 |
|
||||
143 | params = {} |
|
|||
144 | version, paramstr = s.split(b';', 1) |
|
|||
145 |
|
||||
146 | for p in paramstr.split(b';'): |
|
|||
147 | if b'=' not in p: |
|
|||
148 | raise error.InvalidBundleSpecification( |
|
|||
149 | _( |
|
|||
150 | b'invalid bundle specification: ' |
|
|||
151 | b'missing "=" in parameter: %s' |
|
|||
152 | ) |
|
|||
153 | % p |
|
|||
154 | ) |
|
|||
155 |
|
||||
156 | key, value = p.split(b'=', 1) |
|
|||
157 | key = urlreq.unquote(key) |
|
|||
158 | value = urlreq.unquote(value) |
|
|||
159 | params[key] = value |
|
|||
160 |
|
||||
161 | return version, params |
|
|||
162 |
|
||||
163 | if strict and b'-' not in spec: |
|
165 | if strict and b'-' not in spec: | |
164 | raise error.InvalidBundleSpecification( |
|
166 | raise error.InvalidBundleSpecification( | |
165 | _( |
|
167 | _( | |
@@ -177,7 +179,7 b' def parsebundlespec(repo, spec, strict=T' | |||||
177 | _(b'%s compression is not supported') % compression |
|
179 | _(b'%s compression is not supported') % compression | |
178 | ) |
|
180 | ) | |
179 |
|
181 | |||
180 | version, params = parseparams(version) |
|
182 | version, params = _parseparams(version) | |
181 |
|
183 | |||
182 | if version not in _bundlespeccontentopts: |
|
184 | if version not in _bundlespeccontentopts: | |
183 | raise error.UnsupportedBundleSpecification( |
|
185 | raise error.UnsupportedBundleSpecification( | |
@@ -188,7 +190,7 b' def parsebundlespec(repo, spec, strict=T' | |||||
188 | # case some defaults are assumed (but only when not in strict mode). |
|
190 | # case some defaults are assumed (but only when not in strict mode). | |
189 | assert not strict |
|
191 | assert not strict | |
190 |
|
192 | |||
191 | spec, params = parseparams(spec) |
|
193 | spec, params = _parseparams(spec) | |
192 |
|
194 | |||
193 | if spec in util.compengines.supportedbundlenames: |
|
195 | if spec in util.compengines.supportedbundlenames: | |
194 | compression = spec |
|
196 | compression = spec |
General Comments 0
You need to be logged in to leave comments.
Login now