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

Sune Foldager sune.foldager at me.com
Fri Oct 17 08:14:54 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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')]
 
- at parthandler('b2x:changegroup')
+ at 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:


More information about the Mercurial-devel mailing list