# HG changeset patch # User Pierre-Yves David # Date 2015-09-29 21:41:40 # Node ID 60825fbe2be1fadad243880effb7352cf885c127 # Parent c93f91c1db1c0b1374403967298e7a88bfeff9c9 writebundle: add a compression argument for the bundle2 case Bundle2 compression is more complex than the bundle1 one. Therefore it is handled by the bundler itself. Moreover, on-disk bundle2 will probably have a large number of flavors so simply adding a new "format" for it does not seems the way to go. This will be used in the next changeset to compress bundle2 strip backup. diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -92,7 +92,7 @@ bundletypes = { # hgweb uses this list to communicate its preferred type bundlepriority = ['HG10GZ', 'HG10BZ', 'HG10UN'] -def writebundle(ui, cg, filename, bundletype, vfs=None): +def writebundle(ui, cg, filename, bundletype, vfs=None, compression=None): """Write a bundle file and return its filename. Existing files will not be overwritten. @@ -117,11 +117,14 @@ def writebundle(ui, cg, filename, bundle if bundletype == "HG20": from . import bundle2 bundle = bundle2.bundle20(ui) + bundle.setcompression(compression) part = bundle.newpart('changegroup', data=cg.getchunks()) part.addparam('version', cg.version) z = util.compressors[None]() chunkiter = bundle.getchunks() else: + # compression argument is only for the bundle2 case + assert compression is None if cg.version != '01': raise util.Abort(_('old bundle types only supports v1 ' 'changegroups'))