##// END OF EJS Templates
strip: extract bookmark movement into a separate function...
Boris Feld -
r41135:c9a2c4d0 default
parent child Browse files
Show More
@@ -153,22 +153,7 b' def strip(ui, repo, nodelist, backup=Tru'
153 stripobsidx = [i for i, m in enumerate(repo.obsstore)
153 stripobsidx = [i for i, m in enumerate(repo.obsstore)
154 if m in obsmarkers]
154 if m in obsmarkers]
155
155
156 # compute necessary bookmark movement
156 newbmtarget, updatebm = _bookmarkmovements(repo, tostrip)
157 bm = repo._bookmarks
158 updatebm = []
159 for m in bm:
160 rev = repo[bm[m]].rev()
161 if rev in tostrip:
162 updatebm.append(m)
163 newbmtarget = None
164 if updatebm: # don't compute anything is there is no bookmark to move anyway
165 # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)),
166 # but is much faster
167 newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip)
168 if newbmtarget:
169 newbmtarget = repo[newbmtarget.first()].node()
170 else:
171 newbmtarget = '.'
172
157
173 backupfile = None
158 backupfile = None
174 node = nodelist[-1]
159 node = nodelist[-1]
@@ -235,7 +220,7 b' def strip(ui, repo, nodelist, backup=Tru'
235
220
236 with repo.transaction('repair') as tr:
221 with repo.transaction('repair') as tr:
237 bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm]
222 bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm]
238 bm.applychanges(repo, tr, bmchanges)
223 repo._bookmarks.applychanges(repo, tr, bmchanges)
239
224
240 # remove undo files
225 # remove undo files
241 for undovfs, undofile in repo.undofiles():
226 for undovfs, undofile in repo.undofiles():
@@ -267,6 +252,25 b' def strip(ui, repo, nodelist, backup=Tru'
267 # extensions can use it
252 # extensions can use it
268 return backupfile
253 return backupfile
269
254
255 def _bookmarkmovements(repo, tostrip):
256 # compute necessary bookmark movement
257 bm = repo._bookmarks
258 updatebm = []
259 for m in bm:
260 rev = repo[bm[m]].rev()
261 if rev in tostrip:
262 updatebm.append(m)
263 newbmtarget = None
264 if updatebm: # don't compute anything is there is no bookmark to move anyway
265 # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)),
266 # but is much faster
267 newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip)
268 if newbmtarget:
269 newbmtarget = repo[newbmtarget.first()].node()
270 else:
271 newbmtarget = '.'
272 return newbmtarget, updatebm
273
270 def _createstripbackup(repo, stripbases, node, topic):
274 def _createstripbackup(repo, stripbases, node, topic):
271 # backup the changeset we are about to strip
275 # backup the changeset we are about to strip
272 vfs = repo.vfs
276 vfs = repo.vfs
General Comments 0
You need to be logged in to leave comments. Login now