comparison mercurial/streamclone.py @ 50279:97e91001a4e0 stable

undo-files: use the cleanup function in streamclone Lets use the same code, so that we can fix things only once.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 06 Mar 2023 13:05:43 +0100
parents d44e3c45f0e4
children 3d0b5760851c
comparison
equal deleted inserted replaced
50278:cd680b45a920 50279:97e91001a4e0
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 8
9 import contextlib 9 import contextlib
10 import errno
11 import os 10 import os
12 import struct 11 import struct
13 12
14 from .i18n import _ 13 from .i18n import _
15 from .pycompat import open 14 from .pycompat import open
19 cacheutil, 18 cacheutil,
20 error, 19 error,
21 narrowspec, 20 narrowspec,
22 phases, 21 phases,
23 pycompat, 22 pycompat,
23 repair,
24 requirements as requirementsmod, 24 requirements as requirementsmod,
25 scmutil, 25 scmutil,
26 store, 26 store,
27 util, 27 util,
28 ) 28 )
29 from .revlogutils import ( 29 from .revlogutils import (
30 nodemap, 30 nodemap,
31 )
32 from .utils import (
33 stringutil,
34 ) 31 )
35 32
36 33
37 def new_stream_clone_requirements(default_requirements, streamed_requirements): 34 def new_stream_clone_requirements(default_requirements, streamed_requirements):
38 """determine the final set of requirement for a new stream clone 35 """determine the final set of requirement for a new stream clone
933 930
934 with dest_repo.transaction(b"localclone") as tr: 931 with dest_repo.transaction(b"localclone") as tr:
935 dest_repo.store.write(tr) 932 dest_repo.store.write(tr)
936 933
937 # clean up transaction file as they do not make sense 934 # clean up transaction file as they do not make sense
938 undo_files = [(dest_repo.svfs, b'undo.backupfiles')] 935 repair.cleanup_undo_files(dest_repo)
939 undo_files.extend(dest_repo.undofiles())
940 for undovfs, undofile in undo_files:
941 try:
942 undovfs.unlink(undofile)
943 except OSError as e:
944 if e.errno != errno.ENOENT:
945 msg = _(b'error removing %s: %s\n')
946 path = undovfs.join(undofile)
947 e_msg = stringutil.forcebytestr(e)
948 msg %= (path, e_msg)
949 dest_repo.ui.warn(msg)