writebundle: add a compression argument for the bundle2 case
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 29 Sep 2015 14:41:40 -0700
changeset 26424 60825fbe2be1
parent 26423 c93f91c1db1c
child 26425 eb21b6679dc6
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.
mercurial/changegroup.py
--- a/mercurial/changegroup.py	Tue Sep 29 13:16:51 2015 -0700
+++ b/mercurial/changegroup.py	Tue Sep 29 14:41:40 2015 -0700
@@ -92,7 +92,7 @@
 # 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 @@
         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'))