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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Oct 17 14:56:27 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 c36a8b35f3c846458dcdec956ed4674be1b01923
# Parent  df5caaacde8b95b5eda6ddef48b9bbbec8374a69
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 --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -826,11 +826,11 @@ def obsmarkersversion(caps):
     """extract the list of supported obsmarkers versions from a bundle2caps dict
     """
     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
 
     This is a very early implementation that will massive rework before being
     inflicted to any end-user.
@@ -839,11 +839,14 @@ def handlechangegroup(op, inpart):
     #
     # The addchangegroup function will get a transaction object by itself, but
     # 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')
     op.records.add('changegroup', {'return': ret})
     if op.reply is not None:


More information about the Mercurial-devel mailing list