--- 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: