Comments
Patch
@@ -45,10 +45,14 @@ Binary format is as follow
The blob contains a space separated list of parameters. parameter with value
are stored in the form `<name>=<value>`. Both name and value are urlquoted.
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
crazy usage.
- Textual data allow easy human inspection of a the bundle2 header in case of
@@ -70,10 +74,11 @@ Binary format is as follow
"""
import util
import struct
import urllib
+import string
import changegroup
from i18n import _
_pack = struct.pack
@@ -98,10 +103,12 @@ class bundle20(object):
def addparam(self, name, value=None):
"""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):
yield _magicstring
param = self._paramchunk()
@@ -160,5 +160,11 @@ Test buggy input
empty parameter name
$ hg bundle2 --param '' --quiet
abort: empty parameter name
[255]
+
+bad parameter name
+
+ $ hg bundle2 --param 42babar
+ abort: non letter first character: '42babar'
+ [255]