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

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 25, 2014, 4:36 a.m.
Message ID <2ec013921e690244d3be.1411619791@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5980/
State Superseded
Commit 02e8f9b6005246a70a0188c62539fd0a1b750438
Headers show

Comments

Pierre-Yves David - Sept. 25, 2014, 4:36 a.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 2ec013921e690244d3beb90a5d9c6cfaee593939
# Parent  d77b259843fe058eceef0e56fc05959b17b3a961
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 --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -805,11 +805,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')]
 
-@parthandler('b2x:changegroup')
+@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.
@@ -818,11 +818,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', '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:
         # This is definitly not the final form of this
         # return. But one need to start somewhere.