# HG changeset patch # User Pierre-Yves David # Date 1678126767 -3600 # Node ID dda43856ef96257a6f8791deb7c4ed3bd136e26c # Parent 4bcb91c8b9d81fd78866c9008f3afe06a1d9d805 undo-files: add a undoname closure to the _write_undo method We will also needs it when the transaction will take care of the other journal files, which is soon™. diff -r 4bcb91c8b9d8 -r dda43856ef96 mercurial/transaction.py --- 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()