[PATCH 5 of 8 V2] changegroup: allow use of different cg#packer in getchangegroupraw
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri Oct 17 14:56:29 CDT 2014
# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1413549681 -7200
# Fri Oct 17 14:41:21 2014 +0200
# Node ID f71a2dedeb81b6194e2560313384e7d5c0bb1b2b
# Parent f836daa75636bd6c43f3ca4a86de6c40f27822ba
changegroup: allow use of different cg#packer in getchangegroupraw
This will allow the use of general delta aware changegroup formats.
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -486,18 +486,19 @@ def changegroupsubset(repo, roots, heads
discbases.extend([p for p in cl.parents(n) if p != nullid])
outgoing = discovery.outgoing(cl, discbases, heads)
bundler = cg1packer(repo)
return getsubset(repo, outgoing, bundler, source)
-def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None):
+def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None,
+ version='01'):
"""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][0](repo, bundlecaps)
return getsubsetraw(repo, outgoing, bundler, source)
def getlocalchangegroup(repo, source, outgoing, bundlecaps=None):
"""Like getbundle, but taking a discovery.outgoing as an argument.
@@ -525,21 +526,25 @@ def _computeoutgoing(repo, heads, common
common = [nullid]
if not heads:
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='01'):
"""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
ancestors of heads and the ancestors common.
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1177,15 +1177,18 @@ def _getbundlechangegrouppart(bundler, r
b2caps=None, heads=None, common=None, **kwargs):
"""add a changegroup part to the requested bundle"""
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,
b2caps=None, **kwargs):
"""add parts containing listkeys namespaces to the requested bundle"""
More information about the Mercurial-devel
mailing list