repair: do not compress partial bundle if we do not keep it on disk
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Thu, 12 Aug 2010 16:53:23 +0900
changeset 11791 00cde9bddbe4
parent 11790 ba9957bcfb7c
child 11792 47d2b4a5bd1e
repair: do not compress partial bundle if we do not keep it on disk A partial bundle is created to temporarily save revisions > rev but not descending from the node to strip, to be able to restore the changesets after stripping the changelog. Since this bundle is not kept after the strip operation, and is not user-visible, it is not necessary and should be faster to avoid compression.
mercurial/repair.py
--- a/mercurial/repair.py	Thu Aug 12 16:45:47 2010 +0900
+++ b/mercurial/repair.py	Thu Aug 12 16:53:23 2010 +0900
@@ -11,14 +11,18 @@
 from i18n import _
 import os
 
-def _bundle(repo, bases, heads, node, suffix, extranodes=None):
+def _bundle(repo, bases, heads, node, suffix, extranodes=None, compress=True):
     """create a bundle with the specified revisions as a backup"""
     cg = repo.changegroupsubset(bases, heads, 'strip', extranodes)
     backupdir = repo.join("strip-backup")
     if not os.path.isdir(backupdir):
         os.mkdir(backupdir)
     name = os.path.join(backupdir, "%s-%s.hg" % (short(node), suffix))
-    return changegroup.writebundle(cg, name, "HG10BZ")
+    if compress:
+        bundletype = "HG10BZ"
+    else:
+        bundletype = "HG10UN"
+    return changegroup.writebundle(cg, name, bundletype)
 
 def _collectfiles(repo, striprev):
     """find out the filelogs affected by the strip"""
@@ -69,6 +73,8 @@
     # TODO delete the undo files, and handle undo of merge sets
     striprev = cl.rev(node)
 
+    keeppartialbundle = backup == 'strip'
+
     # Some revisions with rev > striprev may not be descendants of striprev.
     # We have to find these revisions and put them in a bundle, so that
     # we can restore them after the truncations.
@@ -110,8 +116,9 @@
         backupfile = _bundle(repo, [node], cl.heads(), node, 'backup')
         repo.ui.status(_("saved backup bundle to %s\n") % backupfile)
     if saveheads or extranodes:
+        # do not compress partial bundle if we remove it from disk later
         chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp',
-                            extranodes)
+                            extranodes=extranodes, compress=keeppartialbundle)
 
     mfst = repo.manifest
 
@@ -146,7 +153,7 @@
             if not repo.ui.verbose:
                 repo.ui.popbuffer()
             f.close()
-            if backup != "strip":
+            if not keeppartialbundle:
                 os.unlink(chgrpfile)
     except:
         if backupfile: