# HG changeset patch # User Pierre-Yves David # Date 2023-03-06 21:16:28 # Node ID d89eecf9605e65e1dd9a1469340989b6672154d3 # Parent 7ce9862fca7c1eab35ca4730f5a3c11f0870d2de 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. diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py --- a/hgext/narrow/narrowbundle2.py +++ b/hgext/narrow/narrowbundle2.py @@ -294,7 +294,7 @@ def handlechangegroup_widen(op, inpart): 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) diff --git a/mercurial/repair.py b/mercurial/repair.py --- a/mercurial/repair.py +++ b/mercurial/repair.py @@ -259,7 +259,7 @@ def strip(ui, repo, nodelist, backup=Tru 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: diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -932,4 +932,4 @@ def local_copy(src_repo, dest_repo): 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) diff --git a/mercurial/transaction.py b/mercurial/transaction.py --- a/mercurial/transaction.py +++ b/mercurial/transaction.py @@ -50,7 +50,7 @@ UNDO_FILES_MAY_NEED_CLEANUP = [ ] -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 @@ def cleanup_undo_files(repo): """ 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 @@ def cleanup_undo_files(repo): 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(