Patchwork [2,of,2] bundle2: handle empty 'b2x:changegroup' value in push and pull

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 6, 2014, 10:56 a.m.
Message ID <95b64edc965a67696f80.1415271367@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6601/
State Accepted
Headers show

Comments

Pierre-Yves David - Nov. 6, 2014, 10:56 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1415267577 0
#      Thu Nov 06 09:52:57 2014 +0000
# Node ID 95b64edc965a67696f80d07dd47c48ca7d94e5f4
# Parent  d5d10a9e09e43ec3f9efe21d33321c698d81bb3d
bundle2: handle empty 'b2x:changegroup' value in push and pull

Changeset e4dc2b0be056 added advertising of supported changegroup version
through the new 'b2x:changegroup' capability. However, this capability is not
new and have been around since 3.1 with an empty value. This makes new clients
unable to push to 3.2 server through bundle2 as they cannot find a common
changegroup version to use from and empty list.

Treating empty 'b2x:changegroup' value as old client fixes it.
Augie Fackler - Nov. 9, 2014, 2:09 p.m.
On Thu, Nov 06, 2014 at 10:56:07AM +0000, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1415267577 0
> #      Thu Nov 06 09:52:57 2014 +0000
> # Node ID 95b64edc965a67696f80d07dd47c48ca7d94e5f4
> # Parent  d5d10a9e09e43ec3f9efe21d33321c698d81bb3d
> bundle2: handle empty 'b2x:changegroup' value in push and pull

Queued these a few days ago, but forgot to include list when I replied. Sigh.

>
> Changeset e4dc2b0be056 added advertising of supported changegroup version
> through the new 'b2x:changegroup' capability. However, this capability is not
> new and have been around since 3.1 with an empty value. This makes new clients
> unable to push to 3.2 server through bundle2 as they cannot find a common
> changegroup version to use from and empty list.
>
> Treating empty 'b2x:changegroup' value as old client fixes it.
>
> diff --git a/mercurial/exchange.py b/mercurial/exchange.py
> --- a/mercurial/exchange.py
> +++ b/mercurial/exchange.py
> @@ -446,11 +446,11 @@ def _pushb2ctx(pushop, bundler):
>      if not pushop.force:
>          bundler.newpart('B2X:CHECK:HEADS', data=iter(pushop.remoteheads))
>      b2caps = bundle2.bundle2caps(pushop.remote)
>      version = None
>      cgversions = b2caps.get('b2x:changegroup')
> -    if cgversions is None:
> +    if not cgversions:  # 3.1 and 3.2 ship with an empty value
>          cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push',
>                                                  pushop.outgoing)
>      else:
>          cgversions = [v for v in cgversions if v in changegroup.packermap]
>          if not cgversions:
> @@ -1198,11 +1198,11 @@ def _getbundlechangegrouppart(bundler, r
>      cg = None
>      if kwargs.get('cg', True):
>          # build changegroup bundle here.
>          version = None
>          cgversions = b2caps.get('b2x:changegroup')
> -        if cgversions is None:
> +        if not cgversions:  # 3.1 and 3.2 ship with an empty value
>              cg = changegroup.getchangegroupraw(repo, source, heads=heads,
>                                                 common=common,
>                                                 bundlecaps=bundlecaps)
>          else:
>              cgversions = [v for v in cgversions if v in changegroup.packermap]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -446,11 +446,11 @@  def _pushb2ctx(pushop, bundler):
     if not pushop.force:
         bundler.newpart('B2X:CHECK:HEADS', data=iter(pushop.remoteheads))
     b2caps = bundle2.bundle2caps(pushop.remote)
     version = None
     cgversions = b2caps.get('b2x:changegroup')
-    if cgversions is None:
+    if not cgversions:  # 3.1 and 3.2 ship with an empty value
         cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push',
                                                 pushop.outgoing)
     else:
         cgversions = [v for v in cgversions if v in changegroup.packermap]
         if not cgversions:
@@ -1198,11 +1198,11 @@  def _getbundlechangegrouppart(bundler, r
     cg = None
     if kwargs.get('cg', True):
         # build changegroup bundle here.
         version = None
         cgversions = b2caps.get('b2x:changegroup')
-        if cgversions is None:
+        if not cgversions:  # 3.1 and 3.2 ship with an empty value
             cg = changegroup.getchangegroupraw(repo, source, heads=heads,
                                                common=common,
                                                bundlecaps=bundlecaps)
         else:
             cgversions = [v for v in cgversions if v in changegroup.packermap]