Mercurial > public > mercurial-scm > hg
diff mercurial/bundlecaches.py @ 49331:1b04d5213d0f
bundlespec: add processing of some parameter value
The boolean option needs to be turned into boolean.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 18 May 2022 10:38:11 +0100 |
parents | 5d17dd74177d |
children | d89bfc075289 |
line wrap: on
line diff
--- a/mercurial/bundlecaches.py Wed May 18 10:06:43 2022 +0100 +++ b/mercurial/bundlecaches.py Wed May 18 10:38:11 2022 +0100 @@ -102,6 +102,24 @@ _bundlespecv1compengines = {b'gzip', b'bzip2', b'none'} +def param_bool(key, value): + """make a boolean out of a parameter value""" + b = stringutil.parsebool(value) + if b is None: + msg = _(b"parameter %s should be a boolean ('%s')") + msg %= (key, value) + raise error.InvalidBundleSpecification(msg) + return b + + +# mapping of known parameter name need their value processed +bundle_spec_param_processing = { + b"obsolescence": param_bool, + b"obsolescence-mandatory": param_bool, + b"phases": param_bool, +} + + def _parseparams(s): """parse bundlespec parameter section @@ -124,6 +142,9 @@ key, value = p.split(b'=', 1) key = urlreq.unquote(key) value = urlreq.unquote(value) + process = bundle_spec_param_processing.get(key) + if process is not None: + value = process(key, value) params[key] = value return version, params