changeset 50288:d89eecf9605e stable

undo-files: no longer pass the `repo` to `cleanup_undo_files` As foretold in the previous changesets, we no longer need a full repository object here.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 06 Mar 2023 22:16:28 +0100
parents 7ce9862fca7c
children 94a8c354242b
files hgext/narrow/narrowbundle2.py mercurial/repair.py mercurial/streamclone.py mercurial/transaction.py
diffstat 4 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/narrow/narrowbundle2.py	Mon Mar 06 20:16:17 2023 +0100
+++ b/hgext/narrow/narrowbundle2.py	Mon Mar 06 22:16:28 2023 +0100
@@ -294,7 +294,7 @@
     finally:
         f.close()
 
-    transaction.cleanup_undo_files(repo)
+    transaction.cleanup_undo_files(repo.ui.warn, repo.vfs_map)
 
     # Remove partial backup only if there were no exceptions
     op._widen_uninterr.__exit__(None, None, None)
--- a/mercurial/repair.py	Mon Mar 06 20:16:17 2023 +0100
+++ b/mercurial/repair.py	Mon Mar 06 22:16:28 2023 +0100
@@ -259,7 +259,7 @@
                 bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm]
                 repo._bookmarks.applychanges(repo, tr, bmchanges)
 
-            transaction.cleanup_undo_files(repo)
+            transaction.cleanup_undo_files(repo.ui.warn, repo.vfs_map)
 
         except:  # re-raises
             if backupfile:
--- a/mercurial/streamclone.py	Mon Mar 06 20:16:17 2023 +0100
+++ b/mercurial/streamclone.py	Mon Mar 06 22:16:28 2023 +0100
@@ -932,4 +932,4 @@
             dest_repo.store.write(tr)
 
         # clean up transaction file as they do not make sense
-        transaction.cleanup_undo_files(dest_repo)
+        transaction.cleanup_undo_files(dest_repo.ui.warn, dest_repo.vfs_map)
--- a/mercurial/transaction.py	Mon Mar 06 20:16:17 2023 +0100
+++ b/mercurial/transaction.py	Mon Mar 06 22:16:28 2023 +0100
@@ -50,7 +50,7 @@
 ]
 
 
-def cleanup_undo_files(repo):
+def cleanup_undo_files(report, vfsmap):
     """remove "undo" files used by the rollback logic
 
     This is useful to prevent rollback running in situation were it does not
@@ -58,21 +58,21 @@
     """
     backup_entries = []
     undo_files = []
-    vfsmap = repo.vfs_map
+    svfs = vfsmap[b'store']
     try:
-        with repo.svfs(UNDO_BACKUP) as f:
-            backup_entries = read_backup_files(repo.ui.warn, f)
+        with svfs(UNDO_BACKUP) as f:
+            backup_entries = read_backup_files(report, f)
     except OSError as e:
         if e.errno != errno.ENOENT:
             msg = _(b'could not read %s: %s\n')
-            msg %= (repo.svfs.join(UNDO_BACKUP), stringutil.forcebytestr(e))
-            repo.ui.warn(msg)
+            msg %= (svfs.join(UNDO_BACKUP), stringutil.forcebytestr(e))
+            report(msg)
 
     for location, f, backup_path, c in backup_entries:
         if location in vfsmap and backup_path:
             undo_files.append((vfsmap[location], backup_path))
 
-    undo_files.append((repo.svfs, UNDO_BACKUP))
+    undo_files.append((svfs, UNDO_BACKUP))
     for location, undo_path in UNDO_FILES_MAY_NEED_CLEANUP:
         undo_files.append((vfsmap[location], undo_path))
     for undovfs, undofile in undo_files:
@@ -82,7 +82,7 @@
             if e.errno != errno.ENOENT:
                 msg = _(b'error removing %s: %s\n')
                 msg %= (undovfs.join(undofile), stringutil.forcebytestr(e))
-                repo.ui.warn(msg)
+                report(msg)
 
 
 def _playback(