# HG changeset patch # User Pierre-Yves David # Date 2014-09-25 04:33:12 # Node ID 02e8f9b6005246a70a0188c62539fd0a1b750438 # Parent e4dc2b0be056bc1f5a8cd650eeed59ea684b91fc 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. diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -902,7 +902,7 @@ def obsmarkersversion(caps): 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 @@ def handlechangegroup(op, inpart): # 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')