##// END OF EJS Templates
undo-files: extract the cleanup code from strip in a function...
marmoute -
r51184:80110176 stable
parent child Browse files
Show More
@@ -113,6 +113,22 b' def _collectbrokencsets(repo, files, str'
113 return s
113 return s
114
114
115
115
116 def cleanup_undo_files(repo):
117 """remove "undo" files used by the rollback logic
118
119 This is useful to prevent rollback running in situation were it does not
120 make sense. For example after a strip.
121 """
122 for undovfs, undofile in repo.undofiles():
123 try:
124 undovfs.unlink(undofile)
125 except OSError as e:
126 if e.errno != errno.ENOENT:
127 msg = _(b'error removing %s: %s\n')
128 msg %= (undovfs.join(undofile), stringutil.forcebytestr(e))
129 repo.ui.warn(msg)
130
131
116 def strip(ui, repo, nodelist, backup=True, topic=b'backup'):
132 def strip(ui, repo, nodelist, backup=True, topic=b'backup'):
117 # This function requires the caller to lock the repo, but it operates
133 # This function requires the caller to lock the repo, but it operates
118 # within a transaction of its own, and thus requires there to be no current
134 # within a transaction of its own, and thus requires there to be no current
@@ -261,19 +277,7 b' def strip(ui, repo, nodelist, backup=Tru'
261 bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm]
277 bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm]
262 repo._bookmarks.applychanges(repo, tr, bmchanges)
278 repo._bookmarks.applychanges(repo, tr, bmchanges)
263
279
264 # remove undo files
280 cleanup_undo_files(repo)
265 for undovfs, undofile in repo.undofiles():
266 try:
267 undovfs.unlink(undofile)
268 except OSError as e:
269 if e.errno != errno.ENOENT:
270 ui.warn(
271 _(b'error removing %s: %s\n')
272 % (
273 undovfs.join(undofile),
274 stringutil.forcebytestr(e),
275 )
276 )
277
281
278 except: # re-raises
282 except: # re-raises
279 if backupfile:
283 if backupfile:
General Comments 0
You need to be logged in to leave comments. Login now