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.
--- 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')