bundle2: support for bundling parameter value
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 18 Mar 2014 16:05:06 -0700
changeset 20809 b93bb639451a
parent 20808 4c9130c7a29f
child 20810 47293877b54c
bundle2: support for bundling parameter value Parameter can now have a value. We use a `<name>=<value>` form inspired from capabilities. There is still no kind of escaping in the name or value, yet.
mercurial/bundle2.py
tests/test-bundle2.t
--- a/mercurial/bundle2.py	Thu Mar 20 13:18:34 2014 -0700
+++ b/mercurial/bundle2.py	Tue Mar 18 16:05:06 2014 -0700
@@ -42,9 +42,8 @@
   A blob of `params size` containing the serialized version of all stream level
   parameters.
 
-  The blob contains a space separated list of parameters.
-
-  Parameter value are not supported yet.
+  The blob contains a space separated list of parameters. parameter with value
+  are stored in the form `<name>=<value>`.
 
   Special character in param name are not supported yet.
 
@@ -116,11 +115,11 @@
     def _paramchunk(self):
         """return a encoded version of all stream parameters"""
         blocks = []
-        for key, value in self._params:
-            # XXX no support for value yet
-            assert value is None
+        for par, value in self._params:
             # XXX no escaping yet
-            blocks.append(key)
+            if value is not None:
+                par = '%s=%s' % (par, value)
+            blocks.append(par)
         return ' '.join(blocks)
 
 class unbundle20(object):
--- a/tests/test-bundle2.t	Thu Mar 20 13:18:34 2014 -0700
+++ b/tests/test-bundle2.t	Tue Mar 18 16:05:06 2014 -0700
@@ -21,7 +21,9 @@
   >     """write a bundle2 container on standard ouput"""
   >     bundler = bundle2.bundle20()
   >     for p in opts['param']:
-  >         bundler.addparam(p)
+  >         p = p.split('=', 1)
+  >         bundler.addparam(*p)
+  > 
   >     for chunk in bundler.getchunks():
   >         ui.write(chunk)
   > 
@@ -110,3 +112,11 @@
   - meal
   parts count:   0
 
+advisory parameters, with value
+-------------------------------
+
+Test generation
+
+  $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants'
+  HG20\x00\x1ccaution meal=vegan elephants\x00\x00 (no-eol) (esc)
+