##// END OF EJS Templates
repair: make "strip()" treat bundle files via vfs...
FUJIWARA Katsunori -
r20979:ad5b6137 default
parent child Browse files
Show More
@@ -9,7 +9,6 b''
9 from mercurial import changegroup
9 from mercurial import changegroup
10 from mercurial.node import short
10 from mercurial.node import short
11 from mercurial.i18n import _
11 from mercurial.i18n import _
12 import os
13 import errno
12 import errno
14
13
15 def _bundle(repo, bases, heads, node, suffix, compress=True):
14 def _bundle(repo, bases, heads, node, suffix, compress=True):
@@ -24,7 +23,7 b' def _bundle(repo, bases, heads, node, su'
24 bundletype = "HG10BZ"
23 bundletype = "HG10BZ"
25 else:
24 else:
26 bundletype = "HG10UN"
25 bundletype = "HG10UN"
27 return vfs.join(changegroup.writebundle(cg, name, bundletype, vfs))
26 return changegroup.writebundle(cg, name, bundletype, vfs)
28
27
29 def _collectfiles(repo, striprev):
28 def _collectfiles(repo, striprev):
30 """find out the filelogs affected by the strip"""
29 """find out the filelogs affected by the strip"""
@@ -109,10 +108,13 b' def strip(ui, repo, nodelist, backup="al'
109
108
110 # create a changegroup for all the branches we need to keep
109 # create a changegroup for all the branches we need to keep
111 backupfile = None
110 backupfile = None
111 vfs = repo.vfs
112 if backup == "all":
112 if backup == "all":
113 backupfile = _bundle(repo, stripbases, cl.heads(), node, topic)
113 backupfile = _bundle(repo, stripbases, cl.heads(), node, topic)
114 repo.ui.status(_("saved backup bundle to %s\n") % backupfile)
114 repo.ui.status(_("saved backup bundle to %s\n") %
115 repo.ui.log("backupbundle", "saved backup bundle to %s\n", backupfile)
115 vfs.join(backupfile))
116 repo.ui.log("backupbundle", "saved backup bundle to %s\n",
117 vfs.join(backupfile))
116 if saveheads or savebases:
118 if saveheads or savebases:
117 # do not compress partial bundle if we remove it from disk later
119 # do not compress partial bundle if we remove it from disk later
118 chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp',
120 chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp',
@@ -144,18 +146,18 b' def strip(ui, repo, nodelist, backup="al'
144
146
145 if saveheads or savebases:
147 if saveheads or savebases:
146 ui.note(_("adding branch\n"))
148 ui.note(_("adding branch\n"))
147 f = open(chgrpfile, "rb")
149 f = vfs.open(chgrpfile, "rb")
148 gen = changegroup.readbundle(f, chgrpfile)
150 gen = changegroup.readbundle(f, chgrpfile, vfs)
149 if not repo.ui.verbose:
151 if not repo.ui.verbose:
150 # silence internal shuffling chatter
152 # silence internal shuffling chatter
151 repo.ui.pushbuffer()
153 repo.ui.pushbuffer()
152 changegroup.addchangegroup(repo, gen, 'strip',
154 changegroup.addchangegroup(repo, gen, 'strip',
153 'bundle:' + chgrpfile, True)
155 'bundle:' + vfs.join(chgrpfile), True)
154 if not repo.ui.verbose:
156 if not repo.ui.verbose:
155 repo.ui.popbuffer()
157 repo.ui.popbuffer()
156 f.close()
158 f.close()
157 if not keeppartialbundle:
159 if not keeppartialbundle:
158 os.unlink(chgrpfile)
160 vfs.unlink(chgrpfile)
159
161
160 # remove undo files
162 # remove undo files
161 for undovfs, undofile in repo.undofiles():
163 for undovfs, undofile in repo.undofiles():
@@ -172,10 +174,10 b' def strip(ui, repo, nodelist, backup="al'
172 except: # re-raises
174 except: # re-raises
173 if backupfile:
175 if backupfile:
174 ui.warn(_("strip failed, full bundle stored in '%s'\n")
176 ui.warn(_("strip failed, full bundle stored in '%s'\n")
175 % backupfile)
177 % vfs.join(backupfile))
176 elif saveheads:
178 elif saveheads:
177 ui.warn(_("strip failed, partial bundle stored in '%s'\n")
179 ui.warn(_("strip failed, partial bundle stored in '%s'\n")
178 % chgrpfile)
180 % vfs.join(chgrpfile))
179 raise
181 raise
180
182
181 repo.destroyed()
183 repo.destroyed()
General Comments 0
You need to be logged in to leave comments. Login now