Patchwork [2,of,3] writebundle: add a compression argument for the bundle2 case

mail settings
Submitter Pierre-Yves David
Date Sept. 29, 2015, 10:28 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/10691/
State Accepted
Headers show


Pierre-Yves David - Sept. 29, 2015, 10:28 p.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1443562900 25200
#      Tue Sep 29 14:41:40 2015 -0700
# Node ID 405450625fe8de8f75f66f05b10be3c6a9a93b62
# Parent  4e5c7e8778bfa9114d7e37719cb2009d5a9d284b
writebundle: add a compression argument for the bundle2 case

Bundle2 compression is more complex than the bundle1 one. Therefore it is
handler by the bundler himself. Moreover, on-disk bundle2 will probably have a
large number of flavor so simply adding a new "format" for it does not seems the
way to go.

This will be used in the next changeset to compression bundle2 strip backup>


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -90,11 +90,11 @@  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.
     If no filename is specified, a temporary file is created.
     bz2 compression can be turned off.
@@ -115,15 +115,18 @@  def writebundle(ui, cg, filename, bundle
         cleanup = filename
         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()
+            # 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 '
             header, comp = bundletypes[bundletype]