mercurial/transaction.py
branchstable
changeset 50296 dda43856ef96
parent 50293 5e568d70f54d
child 50297 a43f0562220c
--- a/mercurial/transaction.py	Mon Mar 06 13:31:04 2023 +0100
+++ b/mercurial/transaction.py	Mon Mar 06 19:19:27 2023 +0100
@@ -11,6 +11,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+import os
 
 from .i18n import _
 from . import (
@@ -637,6 +638,12 @@
         if self._undoname is None:
             return
 
+        def undoname(fn: bytes) -> bytes:
+            base, name = os.path.split(fn)
+            assert name.startswith(self._journal)
+            new_name = name.replace(self._journal, self._undoname, 1)
+            return os.path.join(base, new_name)
+
         undo_backup_path = b"%s.backupfiles" % self._undoname
         undobackupfile = self._opener.open(undo_backup_path, b'w')
         undobackupfile.write(b'%d\n' % version)
@@ -653,10 +660,7 @@
                     )
                     continue
                 vfs = self._vfsmap[l]
-                base, name = vfs.split(b)
-                assert name.startswith(self._journal), name
-                uname = name.replace(self._journal, self._undoname, 1)
-                u = vfs.reljoin(base, uname)
+                u = undoname(b)
                 util.copyfile(vfs.join(b), vfs.join(u), hardlink=True)
             undobackupfile.write(b"%s\0%s\0%s\0%d\n" % (l, f, u, c))
         undobackupfile.close()