changeset 37005:66c0ff381cfc

bundle: condition the changegroup part when creating a new bundle We will generate stream bundle in the next changesets which doesn't need the changegroup part. Differential Revision: https://phab.mercurial-scm.org/D1951
author Boris Feld <boris.feld@octobus.net>
date Wed, 31 Jan 2018 09:41:47 +0100
parents 68fcc5503ec5
children 8e89c2bec1f7
files mercurial/bundle2.py mercurial/commands.py
diffstat 2 files changed, 16 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Fri Jan 19 17:29:50 2018 +0100
+++ b/mercurial/bundle2.py	Wed Jan 31 09:41:47 2018 +0100
@@ -1577,19 +1577,21 @@
     # different right now. So we keep them separated for now for the sake of
     # simplicity.
 
-    # we always want a changegroup in such bundle
-    cgversion = opts.get('cg.version')
-    if cgversion is None:
-        cgversion = changegroup.safeversion(repo)
-    cg = changegroup.makechangegroup(repo, outgoing, cgversion, source)
-    part = bundler.newpart('changegroup', data=cg.getchunks())
-    part.addparam('version', cg.version)
-    if 'clcount' in cg.extras:
-        part.addparam('nbchanges', '%d' % cg.extras['clcount'],
-                      mandatory=False)
-    if opts.get('phases') and repo.revs('%ln and secret()',
-                                        outgoing.missingheads):
-        part.addparam('targetphase', '%d' % phases.secret, mandatory=False)
+    # we might not always want a changegroup in such bundle, for example in
+    # stream bundles
+    if opts.get('changegroup', True):
+        cgversion = opts.get('cg.version')
+        if cgversion is None:
+            cgversion = changegroup.safeversion(repo)
+        cg = changegroup.makechangegroup(repo, outgoing, cgversion, source)
+        part = bundler.newpart('changegroup', data=cg.getchunks())
+        part.addparam('version', cg.version)
+        if 'clcount' in cg.extras:
+            part.addparam('nbchanges', '%d' % cg.extras['clcount'],
+                          mandatory=False)
+        if opts.get('phases') and repo.revs('%ln and secret()',
+                                            outgoing.missingheads):
+            part.addparam('targetphase', '%d' % phases.secret, mandatory=False)
 
     addparttagsfnodescache(repo, bundler, outgoing)
     addpartrevbranchcache(repo, bundler, outgoing)
--- a/mercurial/commands.py	Fri Jan 19 17:29:50 2018 +0100
+++ b/mercurial/commands.py	Wed Jan 31 09:41:47 2018 +0100
@@ -1263,7 +1263,7 @@
         compopts['level'] = complevel
 
 
-    contentopts = {'cg.version': cgversion}
+    contentopts = {'cg.version': cgversion, 'changegroup': True}
     if repo.ui.configbool('experimental', 'evolution.bundle-obsmarker'):
         contentopts['obsolescence'] = True
     if repo.ui.configbool('experimental', 'bundle-phases'):