Show More
@@ -11,14 +11,18 from node import nullrev, short | |||||
11 | from i18n import _ |
|
11 | from i18n import _ | |
12 | import os |
|
12 | import os | |
13 |
|
13 | |||
14 | def _bundle(repo, bases, heads, node, suffix, extranodes=None): |
|
14 | def _bundle(repo, bases, heads, node, suffix, extranodes=None, compress=True): | |
15 | """create a bundle with the specified revisions as a backup""" |
|
15 | """create a bundle with the specified revisions as a backup""" | |
16 | cg = repo.changegroupsubset(bases, heads, 'strip', extranodes) |
|
16 | cg = repo.changegroupsubset(bases, heads, 'strip', extranodes) | |
17 | backupdir = repo.join("strip-backup") |
|
17 | backupdir = repo.join("strip-backup") | |
18 | if not os.path.isdir(backupdir): |
|
18 | if not os.path.isdir(backupdir): | |
19 | os.mkdir(backupdir) |
|
19 | os.mkdir(backupdir) | |
20 | name = os.path.join(backupdir, "%s-%s.hg" % (short(node), suffix)) |
|
20 | name = os.path.join(backupdir, "%s-%s.hg" % (short(node), suffix)) | |
21 | return changegroup.writebundle(cg, name, "HG10BZ") |
|
21 | if compress: | |
|
22 | bundletype = "HG10BZ" | |||
|
23 | else: | |||
|
24 | bundletype = "HG10UN" | |||
|
25 | return changegroup.writebundle(cg, name, bundletype) | |||
22 |
|
26 | |||
23 | def _collectfiles(repo, striprev): |
|
27 | def _collectfiles(repo, striprev): | |
24 | """find out the filelogs affected by the strip""" |
|
28 | """find out the filelogs affected by the strip""" | |
@@ -69,6 +73,8 def strip(ui, repo, node, backup="all"): | |||||
69 | # TODO delete the undo files, and handle undo of merge sets |
|
73 | # TODO delete the undo files, and handle undo of merge sets | |
70 | striprev = cl.rev(node) |
|
74 | striprev = cl.rev(node) | |
71 |
|
75 | |||
|
76 | keeppartialbundle = backup == 'strip' | |||
|
77 | ||||
72 | # Some revisions with rev > striprev may not be descendants of striprev. |
|
78 | # Some revisions with rev > striprev may not be descendants of striprev. | |
73 | # We have to find these revisions and put them in a bundle, so that |
|
79 | # We have to find these revisions and put them in a bundle, so that | |
74 | # we can restore them after the truncations. |
|
80 | # we can restore them after the truncations. | |
@@ -110,8 +116,9 def strip(ui, repo, node, backup="all"): | |||||
110 | backupfile = _bundle(repo, [node], cl.heads(), node, 'backup') |
|
116 | backupfile = _bundle(repo, [node], cl.heads(), node, 'backup') | |
111 | repo.ui.status(_("saved backup bundle to %s\n") % backupfile) |
|
117 | repo.ui.status(_("saved backup bundle to %s\n") % backupfile) | |
112 | if saveheads or extranodes: |
|
118 | if saveheads or extranodes: | |
|
119 | # do not compress partial bundle if we remove it from disk later | |||
113 | chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp', |
|
120 | chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp', | |
114 | extranodes) |
|
121 | extranodes=extranodes, compress=keeppartialbundle) | |
115 |
|
122 | |||
116 | mfst = repo.manifest |
|
123 | mfst = repo.manifest | |
117 |
|
124 | |||
@@ -146,7 +153,7 def strip(ui, repo, node, backup="all"): | |||||
146 | if not repo.ui.verbose: |
|
153 | if not repo.ui.verbose: | |
147 | repo.ui.popbuffer() |
|
154 | repo.ui.popbuffer() | |
148 | f.close() |
|
155 | f.close() | |
149 | if backup != "strip": |
|
156 | if not keeppartialbundle: | |
150 | os.unlink(chgrpfile) |
|
157 | os.unlink(chgrpfile) | |
151 | except: |
|
158 | except: | |
152 | if backupfile: |
|
159 | if backupfile: |
General Comments 0
You need to be logged in to leave comments.
Login now