[PATCH 2 of 5] changegroup: allow use of different cg#packer in getchangegroupraw

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Nov 4 08:20:45 CST 2014


# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1413549681 -7200
#      Fri Oct 17 14:41:21 2014 +0200
# Node ID 4704aafc725bb0eb2f4f6bed459760f54e2c3f65
# Parent  8f7fd2807da7a7703984eef5ce02e298b2152922
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.
 


More information about the Mercurial-devel mailing list