Patchwork [3,of,8] bundle2: support a "version" argument in `changegroup` part

login
register
mail settings
Submitter Sune Foldager
Date Oct. 17, 2014, 1:14 p.m.
Message ID <a26075a46a0da39db23d.1413551694@Cuivienen.local>
Download mbox | patch
Permalink /patch/6362/
State Superseded
Headers show

Comments

Sune Foldager - Oct. 17, 2014, 1:14 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1411619592 25200
#      Wed Sep 24 21:33:12 2014 -0700
# Node ID a26075a46a0da39db23d6dcefb4e1937da8d7bc2
# Parent  9280656032da93b18a28333506f19e394ed2680a
bundle2: support a "version" argument in `changegroup` part

When included, this mandatory parametre (mandatory == cannot be ignored) let the
part handler select the right cgunpacker class.

Patch

diff -r 9280656032da -r a26075a46a0d mercurial/bundle2.py
--- a/mercurial/bundle2.py	Wed Sep 24 21:28:54 2014 -0700
+++ b/mercurial/bundle2.py	Wed Sep 24 21:33:12 2014 -0700
@@ -807,7 +807,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
 
@@ -820,7 +820,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', 'HG10')
+    # We should raise an appropriate exception here
+    unpacker = changegroup.packermap[unpackerversion][1]
+    cg = unpacker(inpart, 'UN')
     ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')
     op.records.add('changegroup', {'return': ret})
     if op.reply is not None: