diff -r e06331275a53 -r f57f5ab0e220 mercurial/transaction.py --- a/mercurial/transaction.py Fri Apr 28 12:12:42 2023 +0200 +++ b/mercurial/transaction.py Tue May 09 11:35:50 2023 +0200 @@ -414,6 +414,11 @@ if vfs.exists(file): filepath = vfs.join(file) backuppath = vfs.join(backupfile) + # store encoding may result in different directory here. + # so we have to ensure the destination directory exist + final_dir_name = os.path.dirname(backuppath) + util.makedirs(final_dir_name, mode=vfs.createmode, notindexed=True) + # then we can copy the backup util.copyfile(filepath, backuppath, hardlink=hardlink) else: backupfile = b''