undo-files: use the cleanup function in streamclone
Lets use the same code, so that we can fix things only once.
--- a/mercurial/streamclone.py Mon Mar 06 13:05:08 2023 +0100
+++ b/mercurial/streamclone.py Mon Mar 06 13:05:43 2023 +0100
@@ -7,7 +7,6 @@
import contextlib
-import errno
import os
import struct
@@ -21,6 +20,7 @@
narrowspec,
phases,
pycompat,
+ repair,
requirements as requirementsmod,
scmutil,
store,
@@ -29,9 +29,6 @@
from .revlogutils import (
nodemap,
)
-from .utils import (
- stringutil,
-)
def new_stream_clone_requirements(default_requirements, streamed_requirements):
@@ -935,15 +932,4 @@
dest_repo.store.write(tr)
# clean up transaction file as they do not make sense
- undo_files = [(dest_repo.svfs, b'undo.backupfiles')]
- undo_files.extend(dest_repo.undofiles())
- for undovfs, undofile in undo_files:
- try:
- undovfs.unlink(undofile)
- except OSError as e:
- if e.errno != errno.ENOENT:
- msg = _(b'error removing %s: %s\n')
- path = undovfs.join(undofile)
- e_msg = stringutil.forcebytestr(e)
- msg %= (path, e_msg)
- dest_repo.ui.warn(msg)
+ repair.cleanup_undo_files(dest_repo)