Patchwork [7,of,8] changegroup: allow use of cg2packer in getchangegroupraw

login
register
mail settings
Submitter Sune Foldager
Date Oct. 17, 2014, 1:14 p.m.
Message ID <7b3ef1e1d1d40c5838f2.1413551698@Cuivienen.local>
Download mbox | patch
Permalink /patch/6366/
State Superseded
Headers show

Comments

Sune Foldager - Oct. 17, 2014, 1:14 p.m.
# HG changeset patch
# User Sune Foldager <cryo@cyanite.org>
# Date 1413549681 -7200
#      Fri Oct 17 14:41:21 2014 +0200
# Node ID 7b3ef1e1d1d40c5838f2df7afaf6d4029855c1ed
# Parent  958fbc8c90b8d2e5eab44909e99705e615375b78
changegroup: allow use of cg2packer in getchangegroupraw

Also, exchange now explicitly sets the changegroup version
for bundle2 changegroups.
Pierre-Yves David - Oct. 17, 2014, 7:23 p.m.
On 10/17/2014 06:14 AM, Sune Foldager wrote:
> # HG changeset patch
> # User Sune Foldager <cryo@cyanite.org>
> # Date 1413549681 -7200
> #      Fri Oct 17 14:41:21 2014 +0200
> # Node ID 7b3ef1e1d1d40c5838f2df7afaf6d4029855c1ed
> # Parent  958fbc8c90b8d2e5eab44909e99705e615375b78
> changegroup: allow use of cg2packer in getchangegroupraw
>
> Also, exchange now explicitly sets the changegroup version
> for bundle2 changegroups.
>
> diff -r 958fbc8c90b8 -r 7b3ef1e1d1d4 mercurial/changegroup.py
> --- a/mercurial/changegroup.py	Fri Oct 17 14:41:11 2014 +0200
> +++ b/mercurial/changegroup.py	Fri Oct 17 14:41:21 2014 +0200
> @@ -523,14 +523,15 @@
>       bundler = cg1packer(repo)
>       return getsubset(repo, outgoing, bundler, source)
>
> -def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None):
> +def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None,
> +                           version=None):
>       """Like getbundle, but taking a discovery.outgoing as an argument.
>
>       This is only implemented for local repos and reuses potentially
>       precomputed sets in outgoing. Returns a raw changegroup generator."""
>       if not outgoing.missing:
>           return None
> -    bundler = cg1packer(repo, bundlecaps)
> +    bundler = packermap[version or '1'][0](repo, bundlecaps)

I changed that to use regular python default parameter value.

Patch

diff -r 958fbc8c90b8 -r 7b3ef1e1d1d4 mercurial/changegroup.py
--- a/mercurial/changegroup.py	Fri Oct 17 14:41:11 2014 +0200
+++ b/mercurial/changegroup.py	Fri Oct 17 14:41:21 2014 +0200
@@ -523,14 +523,15 @@ 
     bundler = cg1packer(repo)
     return getsubset(repo, outgoing, bundler, source)
 
-def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None):
+def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None,
+                           version=None):
     """Like getbundle, but taking a discovery.outgoing as an argument.
 
     This is only implemented for local repos and reuses potentially
     precomputed sets in outgoing. Returns a raw changegroup generator."""
     if not outgoing.missing:
         return None
-    bundler = cg1packer(repo, bundlecaps)
+    bundler = packermap[version or '1'][0](repo, bundlecaps)
     return getsubsetraw(repo, outgoing, bundler, source)
 
 def getlocalchangegroup(repo, source, outgoing, bundlecaps=None):
@@ -562,17 +563,21 @@ 
         heads = cl.heads()
     return discovery.outgoing(cl, common, heads)
 
-def getchangegroupraw(repo, source, heads=None, common=None, bundlecaps=None):
+def getchangegroupraw(repo, source, heads=None, common=None, bundlecaps=None,
+                      version=None):
     """Like changegroupsubset, but returns the set difference between the
     ancestors of heads and the ancestors common.
 
     If heads is None, use the local heads. If common is None, use [nullid].
 
+    If version is None, use a version '1' changegroup.
+
     The nodes in common might not all be known locally due to the way the
     current discovery protocol works. Returns a raw changegroup generator.
     """
     outgoing = _computeoutgoing(repo, heads, common)
-    return getlocalchangegroupraw(repo, source, outgoing, bundlecaps=bundlecaps)
+    return getlocalchangegroupraw(repo, source, outgoing, bundlecaps=bundlecaps,
+                                  version=version)
 
 def getchangegroup(repo, source, heads=None, common=None, bundlecaps=None):
     """Like changegroupsubset, but returns the set difference between the
diff -r 958fbc8c90b8 -r 7b3ef1e1d1d4 mercurial/exchange.py
--- a/mercurial/exchange.py	Fri Oct 17 14:41:11 2014 +0200
+++ b/mercurial/exchange.py	Fri Oct 17 14:41:21 2014 +0200
@@ -1172,11 +1172,14 @@ 
     cg = None
     if kwargs.get('cg', True):
         # build changegroup bundle here.
+        version = '1'
         cg = changegroup.getchangegroupraw(repo, source, heads=heads,
-                                           common=common, bundlecaps=bundlecaps)
+                                           common=common, bundlecaps=bundlecaps,
+                                           version=version)
 
     if cg:
-        bundler.newpart('b2x:changegroup', data=cg)
+        part = bundler.newpart('b2x:changegroup', data=cg)
+        part.addparam('version', version)
 
 @getbundle2partsgenerator('listkeys')
 def _getbundlelistkeysparts(bundler, repo, source, bundlecaps=None,