Mercurial > hg-stable
changeset 23170:02e8f9b60052
bundle2: support a "version" argument in `changegroup` part
When included, this mandatory parameter (mandatory == cannot be ignored) lets the
part handler select the right cgunpacker class.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 24 Sep 2014 21:33:12 -0700 |
parents | e4dc2b0be056 |
children | 8afae1d5d108 |
files | mercurial/bundle2.py |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Wed Sep 24 21:28:54 2014 -0700 +++ b/mercurial/bundle2.py Wed Sep 24 21:33:12 2014 -0700 @@ -902,7 +902,7 @@ obscaps = caps.get('b2x:obsmarkers', ()) return [int(c[1:]) for c in obscaps if c.startswith('V')] -@parthandler('b2x:changegroup') +@parthandler('b2x:changegroup', ('version',)) def handlechangegroup(op, inpart): """apply a changegroup part on the repo @@ -915,7 +915,10 @@ # we need to make sure we trigger the creation of a transaction object used # for the whole processing scope. op.gettransaction() - cg = changegroup.cg1unpacker(inpart, 'UN') + unpackerversion = inpart.params.get('version', '01') + # We should raise an appropriate exception here + unpacker = changegroup.packermap[unpackerversion][1] + cg = unpacker(inpart, 'UN') # the source and url passed here are overwritten by the one contained in # the transaction.hookargs argument. So 'bundle2' is a placeholder ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')