diff mercurial/transaction.py @ 50287:7ce9862fca7c stable

undo-files: relies on a explicit list of possible undo files Instead of infering the list of undo files from the `_journalfiles` method on `localrepository`, we explicitly have the list of file in a constant next to the cleanup code. In practice this does not change much as `_journalfiles` is already returning the same "static" list and no internal or extensions extensions seems to actually wrap that. In addition, that list is not "too short" for cleanup, in case we need to cleanup undo files from older version of Mercurial that used to use more of them. this will be dealt with in a later changesets. This change is a step toward our goal to use the `cleanup_undo_files` within the transaction. The transaction has no reference to the `repo` object, so we need to move toward `cleanup_undo_files` not having one either.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 06 Mar 2023 20:16:17 +0100
parents 3d0b5760851c
children d89eecf9605e
line wrap: on
line diff
--- a/mercurial/transaction.py	Mon Mar 06 21:03:45 2023 +0100
+++ b/mercurial/transaction.py	Mon Mar 06 20:16:17 2023 +0100
@@ -42,6 +42,13 @@
 
 UNDO_BACKUP = b'undo.backupfiles'
 
+UNDO_FILES_MAY_NEED_CLEANUP = [
+    (b'plain', b'undo.desc'),
+    # Always delete undo last to make sure we detect that a clean up is needed if
+    # the process is interrupted.
+    (b'store', b'undo'),
+]
+
 
 def cleanup_undo_files(repo):
     """remove "undo" files used by the rollback logic
@@ -66,7 +73,8 @@
             undo_files.append((vfsmap[location], backup_path))
 
     undo_files.append((repo.svfs, UNDO_BACKUP))
-    undo_files.extend(repo.undofiles())
+    for location, undo_path in UNDO_FILES_MAY_NEED_CLEANUP:
+        undo_files.append((vfsmap[location], undo_path))
     for undovfs, undofile in undo_files:
         try:
             undovfs.unlink(undofile)