# HG changeset patch # User Pierre-Yves David # Date 1395189491 25200 # Node ID 9785c3f8f59865df934550e667a486ef79e8eb15 # Parent 47293877b54c13a46dca4ffd8086d572a86af6e7 bundle2: urlquote stream parameter name and value This introduces support for arbitrary characters in stream parameters name and value. The urlquote format has been chosen because it is: - simple, - standard, - no-op on simple alphanumerical entry. diff -r 47293877b54c -r 9785c3f8f598 mercurial/bundle2.py --- a/mercurial/bundle2.py Tue Mar 18 16:12:33 2014 -0700 +++ b/mercurial/bundle2.py Tue Mar 18 17:38:11 2014 -0700 @@ -43,9 +43,7 @@ parameters. The blob contains a space separated list of parameters. parameter with value - are stored in the form `=`. - - Special character in param name are not supported yet. + are stored in the form `=`. Both name and value are urlquoted. Stream parameters use a simple textual format for two main reasons: @@ -72,6 +70,7 @@ import util import struct +import urllib import changegroup from i18n import _ @@ -116,8 +115,9 @@ """return a encoded version of all stream parameters""" blocks = [] for par, value in self._params: - # XXX no escaping yet + par = urllib.quote(par) if value is not None: + value = urllib.quote(value) par = '%s=%s' % (par, value) blocks.append(par) return ' '.join(blocks) diff -r 47293877b54c -r 9785c3f8f598 tests/test-bundle2.t --- a/tests/test-bundle2.t Tue Mar 18 16:12:33 2014 -0700 +++ b/tests/test-bundle2.t Tue Mar 18 17:38:11 2014 -0700 @@ -132,3 +132,11 @@ - meal vegan parts count: 0 + +parameter with special char in value +--------------------------------------------------- + +Test generation + + $ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple + HG20\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)