Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bundle2.py @ 21136:b6fd496e5c72
bundle2: support for capabilities with values
The capabilities attributes of `bundle20` is now a dictionary and the reply caps
can encode capabilities with values.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 17 Apr 2014 11:44:49 -0400 |
parents | 98fbf3adfd83 |
children | 341a083603a5 |
line wrap: on
line diff
--- a/mercurial/bundle2.py Thu Apr 17 11:32:30 2014 -0400 +++ b/mercurial/bundle2.py Thu Apr 17 11:44:49 2014 -0400 @@ -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)