35 b'cannot use transaction when it is already committed/aborted' |
36 b'cannot use transaction when it is already committed/aborted' |
36 ) |
37 ) |
37 return func(self, *args, **kwds) |
38 return func(self, *args, **kwds) |
38 |
39 |
39 return _active |
40 return _active |
|
41 |
|
42 |
|
43 UNDO_BACKUP = b'undo.backupfiles' |
|
44 |
|
45 |
|
46 def cleanup_undo_files(repo): |
|
47 """remove "undo" files used by the rollback logic |
|
48 |
|
49 This is useful to prevent rollback running in situation were it does not |
|
50 make sense. For example after a strip. |
|
51 """ |
|
52 backup_entries = [] |
|
53 undo_files = [] |
|
54 vfsmap = repo.vfs_map |
|
55 try: |
|
56 with repo.svfs(UNDO_BACKUP) as f: |
|
57 backup_entries = read_backup_files(repo.ui.warn, f) |
|
58 except OSError as e: |
|
59 if e.errno != errno.ENOENT: |
|
60 msg = _(b'could not read %s: %s\n') |
|
61 msg %= (repo.svfs.join(UNDO_BACKUP), stringutil.forcebytestr(e)) |
|
62 repo.ui.warn(msg) |
|
63 |
|
64 for location, f, backup_path, c in backup_entries: |
|
65 if location in vfsmap and backup_path: |
|
66 undo_files.append((vfsmap[location], backup_path)) |
|
67 |
|
68 undo_files.append((repo.svfs, UNDO_BACKUP)) |
|
69 undo_files.extend(repo.undofiles()) |
|
70 for undovfs, undofile in undo_files: |
|
71 try: |
|
72 undovfs.unlink(undofile) |
|
73 except OSError as e: |
|
74 if e.errno != errno.ENOENT: |
|
75 msg = _(b'error removing %s: %s\n') |
|
76 msg %= (undovfs.join(undofile), stringutil.forcebytestr(e)) |
|
77 repo.ui.warn(msg) |
40 |
78 |
41 |
79 |
42 def _playback( |
80 def _playback( |
43 journal, |
81 journal, |
44 report, |
82 report, |