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

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 4, 2014, 12:41 p.m.
Message ID <155b5be162deb030c73f.1415104919@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6556/
State Accepted
Headers show

Comments

Pierre-Yves David - Nov. 4, 2014, 12:41 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 155b5be162deb030c73f388ac0605243447a23f8
# Parent  23a8e90ed88a4f78637f282aec71a96184076278
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.
Augie Fackler - Nov. 4, 2014, 1:22 p.m.
On Tue, Nov 04, 2014 at 12:41:59PM +0000, Pierre-Yves David wrote:
> # 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 155b5be162deb030c73f388ac0605243447a23f8
> # Parent  23a8e90ed88a4f78637f282aec71a96184076278
> bundle2: support a "version" argument in `changegroup` part

Queued, wording/spelling fixes to happen in flight.

>
> 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
> @@ -900,11 +900,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.
> @@ -913,11 +913,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:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -900,11 +900,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.
@@ -913,11 +913,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: