Skip to content
Snippets Groups Projects
Commit b6fd496e authored by Pierre-Yves David's avatar Pierre-Yves David
Browse files

bundle2: support for capabilities with values

The capabilities attributes of `bundle20` is now a dictionary and the reply caps
can encode capabilities with values.
parent 98fbf3ad
No related branches found
No related tags found
No related merge requests found
......@@ -344,7 +344,7 @@
self.ui = ui
self._params = []
self._parts = []
self.capabilities = set(capabilities)
self.capabilities = dict(capabilities)
def addparam(self, name, value=None):
"""add a stream level parameter"""
......@@ -697,8 +697,22 @@
def handlereplycaps(op, inpart):
"""Notify that a reply bundle should be created
the part payload is a list of capabilities (one per line)"""
caps = [c for c in inpart.read().splitlines() if c]
The part payload is a list of capabilities (one per line)
Capabilities may have values using a line of form::
capability=value1,value2,value3
The value are alway a list."""
caps = {}
for line in inpart.read().splitlines():
if not line:
continue
if '=' not in line:
key, vals = line, ()
else:
key, vals = line.split('=', 1)
vals = vals.split(',')
caps[key] = vals
if op.reply is None:
op.reply = bundle20(op.ui, caps)
......@@ -51,6 +51,9 @@
> op.ui.write('debugreply: capabilities:\n')
> for cap in sorted(op.reply.capabilities):
> op.ui.write('debugreply: %r\n' % cap)
> for val in op.reply.capabilities[cap]:
> op.ui.write('debugreply: %r\n' % val)
>
> @command('bundle2',
> [('', 'param', [], 'stream level parameter'),
> ('', 'unknown', False, 'include an unknown mandatory part in the bundle'),
......@@ -69,7 +72,7 @@
> raise util.Abort('%s' % exc)
>
> if opts['reply']:
> capsstring = 'ping-pong\nelephants'
> capsstring = 'ping-pong\nelephants=babar,celeste\ncity=celesteville'
> bundler.addpart(bundle2.bundlepart('replycaps', data=capsstring))
>
> revs = opts['rev']
......@@ -544,5 +547,7 @@
Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
\x00\x00\x00\x00\x00\x1b\x06output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to4\x00\x00\x00Rdebugreply: capabilities: (esc)
\x00\x00\x00\x00\x00\x1b\x06output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to4\x00\x00\x00\xc6debugreply: capabilities: (esc)
debugreply: 'city'
debugreply: 'celesteville'
debugreply: 'elephants'
......@@ -548,4 +553,6 @@
debugreply: 'elephants'
debugreply: 'babar'
debugreply: 'celeste'
debugreply: 'ping-pong'
\x00\x00\x00\x00\x00\x1e test:pong\x00\x00\x00\x02\x01\x00\x0b\x01in-reply-to6\x00\x00\x00\x00\x00\x1b\x06output\x00\x00\x00\x03\x00\x01\x0b\x01in-reply-to6\x00\x00\x00=received ping request (id 6) (esc)
replying to ping request (id 6)
......@@ -562,7 +569,7 @@
:output:
mandatory: 0
advisory: 1
payload: 82 bytes
payload: 198 bytes
:test:pong:
mandatory: 1
advisory: 0
......@@ -581,4 +588,6 @@
remote: Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
remote: Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
remote: debugreply: capabilities:
remote: debugreply: 'city'
remote: debugreply: 'celesteville'
remote: debugreply: 'elephants'
......@@ -584,4 +593,6 @@
remote: debugreply: 'elephants'
remote: debugreply: 'babar'
remote: debugreply: 'celeste'
remote: debugreply: 'ping-pong'
remote: received ping request (id 6)
remote: replying to ping request (id 6)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment