[PATCH 2 of 7] bundle2: support for bundling parameter value
pierre-yves.david at ens-lyon.org
pierre-yves.david at ens-lyon.org
Fri Mar 21 21:57:27 UTC 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1395183906 25200
# Tue Mar 18 16:05:06 2014 -0700
# Node ID fabb16544076272f78e918f7ba026f31b955fee2
# Parent 87d3a675a99914ba3371debbdd5de6a96c58523a
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.
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -40,13 +40,12 @@ Binary format is as follow
:params value: arbitrary number of Bytes
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.
Stream parameters use a simple textual format for two main reasons:
@@ -114,15 +113,15 @@ class bundle20(object):
yield '\0\0'
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):
"""interpret a bundle2 stream
diff --git a/tests/test-bundle2.t b/tests/test-bundle2.t
--- a/tests/test-bundle2.t
+++ b/tests/test-bundle2.t
@@ -19,11 +19,13 @@ Create an extension to test bundle2 API
> '')
> def cmdbundle2(ui, repo, **opts):
> """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)
>
> @command('unbundle2', [], '')
> def cmdunbundle2(ui, repo):
@@ -108,5 +110,13 @@ Test unbundling
options count: 2
- caution
- 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)
+
More information about the Mercurial-devel
mailing list