Mercurial > hg
comparison mercurial/transaction.py @ 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 |
comparison
equal
deleted
inserted
replaced
50287:7ce9862fca7c | 50288:d89eecf9605e |
---|---|
48 # the process is interrupted. | 48 # the process is interrupted. |
49 (b'store', b'undo'), | 49 (b'store', b'undo'), |
50 ] | 50 ] |
51 | 51 |
52 | 52 |
53 def cleanup_undo_files(repo): | 53 def cleanup_undo_files(report, vfsmap): |
54 """remove "undo" files used by the rollback logic | 54 """remove "undo" files used by the rollback logic |
55 | 55 |
56 This is useful to prevent rollback running in situation were it does not | 56 This is useful to prevent rollback running in situation were it does not |
57 make sense. For example after a strip. | 57 make sense. For example after a strip. |
58 """ | 58 """ |
59 backup_entries = [] | 59 backup_entries = [] |
60 undo_files = [] | 60 undo_files = [] |
61 vfsmap = repo.vfs_map | 61 svfs = vfsmap[b'store'] |
62 try: | 62 try: |
63 with repo.svfs(UNDO_BACKUP) as f: | 63 with svfs(UNDO_BACKUP) as f: |
64 backup_entries = read_backup_files(repo.ui.warn, f) | 64 backup_entries = read_backup_files(report, f) |
65 except OSError as e: | 65 except OSError as e: |
66 if e.errno != errno.ENOENT: | 66 if e.errno != errno.ENOENT: |
67 msg = _(b'could not read %s: %s\n') | 67 msg = _(b'could not read %s: %s\n') |
68 msg %= (repo.svfs.join(UNDO_BACKUP), stringutil.forcebytestr(e)) | 68 msg %= (svfs.join(UNDO_BACKUP), stringutil.forcebytestr(e)) |
69 repo.ui.warn(msg) | 69 report(msg) |
70 | 70 |
71 for location, f, backup_path, c in backup_entries: | 71 for location, f, backup_path, c in backup_entries: |
72 if location in vfsmap and backup_path: | 72 if location in vfsmap and backup_path: |
73 undo_files.append((vfsmap[location], backup_path)) | 73 undo_files.append((vfsmap[location], backup_path)) |
74 | 74 |
75 undo_files.append((repo.svfs, UNDO_BACKUP)) | 75 undo_files.append((svfs, UNDO_BACKUP)) |
76 for location, undo_path in UNDO_FILES_MAY_NEED_CLEANUP: | 76 for location, undo_path in UNDO_FILES_MAY_NEED_CLEANUP: |
77 undo_files.append((vfsmap[location], undo_path)) | 77 undo_files.append((vfsmap[location], undo_path)) |
78 for undovfs, undofile in undo_files: | 78 for undovfs, undofile in undo_files: |
79 try: | 79 try: |
80 undovfs.unlink(undofile) | 80 undovfs.unlink(undofile) |
81 except OSError as e: | 81 except OSError as e: |
82 if e.errno != errno.ENOENT: | 82 if e.errno != errno.ENOENT: |
83 msg = _(b'error removing %s: %s\n') | 83 msg = _(b'error removing %s: %s\n') |
84 msg %= (undovfs.join(undofile), stringutil.forcebytestr(e)) | 84 msg %= (undovfs.join(undofile), stringutil.forcebytestr(e)) |
85 repo.ui.warn(msg) | 85 report(msg) |
86 | 86 |
87 | 87 |
88 def _playback( | 88 def _playback( |
89 journal, | 89 journal, |
90 report, | 90 report, |