Patchwork [3,of,3] strip: compress bundle2 backup using BZ

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 29, 2015, 10:28 p.m.
Message ID <f5539f6be041729f2726.1443565682@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/10692/
State Accepted
Headers show

Comments

Pierre-Yves David - Sept. 29, 2015, 10:28 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1443562923 25200
#      Tue Sep 29 14:42:03 2015 -0700
# Node ID f5539f6be041729f27261270563914e8c06208a9
# Parent  405450625fe8de8f75f66f05b10be3c6a9a93b62
strip: compress bundle2 backup using BZ

Storing uncompressed bundle on disk would be a regression. Strip backup using
bundle2 are now compressed when requested.
Matt Mackall - Sept. 30, 2015, 10:34 p.m.
On Tue, 2015-09-29 at 15:28 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1443562923 25200
> #      Tue Sep 29 14:42:03 2015 -0700
> # Node ID f5539f6be041729f27261270563914e8c06208a9
> # Parent  405450625fe8de8f75f66f05b10be3c6a9a93b62
> strip: compress bundle2 backup using BZ

These are queued for default, thanks.

Patch

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -36,17 +36,21 @@  def _bundle(repo, bases, heads, node, su
     allcommits = repo.set('%ln::%ln', bases, heads)
     allhashes = sorted(c.hex() for c in allcommits)
     totalhash = util.sha1(''.join(allhashes)).hexdigest()
     name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix)
 
+    comp = None
     if cgversion != '01':
         bundletype = "HG20"
+        if compress:
+            comp = 'BZ'
     elif compress:
         bundletype = "HG10BZ"
     else:
         bundletype = "HG10UN"
-    return changegroup.writebundle(repo.ui, cg, name, bundletype, vfs)
+    return changegroup.writebundle(repo.ui, cg, name, bundletype, vfs,
+                                   compression=comp)
 
 def _collectfiles(repo, striprev):
     """find out the filelogs affected by the strip"""
     files = set()
 
diff --git a/tests/test-generaldelta.t b/tests/test-generaldelta.t
--- a/tests/test-generaldelta.t
+++ b/tests/test-generaldelta.t
@@ -105,10 +105,10 @@  Test format.aggressivemergedeltas
 Test that strip bundle use bundle2
   $ hg --config extensions.strip= strip .
   0 files updated, 0 files merged, 5 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/aggressive/.hg/strip-backup/1c5d4dc9a8b8-6c68e60c-backup.hg (glob)
   $ hg debugbundle .hg/strip-backup/*
-  Stream params: {}
+  Stream params: {'Compression': 'BZ'}
   changegroup -- "{'version': '02'}"
       1c5d4dc9a8b8d6e1750966d343e94db665e7a1e9
 
   $ cd ..