mercurial/transaction.py
branchstable
changeset 50452 a445194f0a4d
parent 50340 4c1061b3e55a
child 50460 f57f5ab0e220
child 50642 05d429fe84ed
--- a/mercurial/transaction.py	Wed May 03 00:12:34 2023 +0200
+++ b/mercurial/transaction.py	Wed May 03 00:16:38 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''