Mercurial > hg-stable
changeset 50289:94a8c354242b stable
undo-files: make the undo-prefix configurable in `cleanup_undo_files`
The transaction is configuration undo prefix, so we "need" it too.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 07 Mar 2023 03:31:21 +0100 |
parents | d89eecf9605e |
children | 92734603e33e |
files | mercurial/transaction.py |
diffstat | 1 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/transaction.py Mon Mar 06 22:16:28 2023 +0100 +++ b/mercurial/transaction.py Tue Mar 07 03:31:21 2023 +0100 @@ -40,41 +40,43 @@ return _active -UNDO_BACKUP = b'undo.backupfiles' +UNDO_BACKUP = b'%s.backupfiles' UNDO_FILES_MAY_NEED_CLEANUP = [ - (b'plain', b'undo.desc'), + (b'plain', b'%s.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'), + (b'store', b'%s'), ] -def cleanup_undo_files(report, vfsmap): +def cleanup_undo_files(report, vfsmap, undo_prefix=b'undo'): """remove "undo" files used by the rollback logic This is useful to prevent rollback running in situation were it does not make sense. For example after a strip. """ + backup_listing = UNDO_BACKUP % undo_prefix + backup_entries = [] undo_files = [] svfs = vfsmap[b'store'] try: - with svfs(UNDO_BACKUP) as f: + with svfs(backup_listing) 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 %= (svfs.join(UNDO_BACKUP), stringutil.forcebytestr(e)) + msg %= (svfs.join(backup_listing), 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((svfs, UNDO_BACKUP)) + undo_files.append((svfs, backup_listing)) for location, undo_path in UNDO_FILES_MAY_NEED_CLEANUP: - undo_files.append((vfsmap[location], undo_path)) + undo_files.append((vfsmap[location], undo_path % undo_prefix)) for undovfs, undofile in undo_files: try: undovfs.unlink(undofile)