Mercurial > hg
changeset 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 | c7d543eebe1a |
files | mercurial/bundle2.py tests/test-bundle2.t |
diffstat | 2 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Tue Mar 18 18:40:31 2014 -0700 +++ b/mercurial/bundle2.py Tue Mar 18 18:56:08 2014 -0700 @@ -47,6 +47,10 @@ Empty name are obviously forbidden. + Name MUST start with a letter. This first character has to be capitalizable. + The capitalisation of the first letter will be used to know if an option is + advisory or mandatory. This is not implemented yet. + Stream parameters use a simple textual format for two main reasons: - Stream level parameters should remains simple and we want to discourage any @@ -72,6 +76,7 @@ import util import struct import urllib +import string import changegroup from i18n import _ @@ -100,6 +105,8 @@ """add a stream level parameter""" if not name: raise ValueError('empty parameter name') + if name[0] not in string.letters: + raise ValueError('non letter first character: %r' % name) self._params.append((name, value)) def getchunks(self):
--- a/tests/test-bundle2.t Tue Mar 18 18:40:31 2014 -0700 +++ b/tests/test-bundle2.t Tue Mar 18 18:56:08 2014 -0700 @@ -162,3 +162,9 @@ $ hg bundle2 --param '' --quiet abort: empty parameter name [255] + +bad parameter name + + $ hg bundle2 --param 42babar + abort: non letter first character: '42babar' + [255]