##// END OF EJS Templates
undo-files: add a undoname closure to the _write_undo method...
marmoute -
r51191:dda43856 stable
parent child Browse files
Show More
@@ -11,6 +11,7 b''
11 # This software may be used and distributed according to the terms of the
11 # This software may be used and distributed according to the terms of the
12 # GNU General Public License version 2 or any later version.
12 # GNU General Public License version 2 or any later version.
13
13
14 import os
14
15
15 from .i18n import _
16 from .i18n import _
16 from . import (
17 from . import (
@@ -637,6 +638,12 b' class transaction(util.transactional):'
637 if self._undoname is None:
638 if self._undoname is None:
638 return
639 return
639
640
641 def undoname(fn: bytes) -> bytes:
642 base, name = os.path.split(fn)
643 assert name.startswith(self._journal)
644 new_name = name.replace(self._journal, self._undoname, 1)
645 return os.path.join(base, new_name)
646
640 undo_backup_path = b"%s.backupfiles" % self._undoname
647 undo_backup_path = b"%s.backupfiles" % self._undoname
641 undobackupfile = self._opener.open(undo_backup_path, b'w')
648 undobackupfile = self._opener.open(undo_backup_path, b'w')
642 undobackupfile.write(b'%d\n' % version)
649 undobackupfile.write(b'%d\n' % version)
@@ -653,10 +660,7 b' class transaction(util.transactional):'
653 )
660 )
654 continue
661 continue
655 vfs = self._vfsmap[l]
662 vfs = self._vfsmap[l]
656 base, name = vfs.split(b)
663 u = undoname(b)
657 assert name.startswith(self._journal), name
658 uname = name.replace(self._journal, self._undoname, 1)
659 u = vfs.reljoin(base, uname)
660 util.copyfile(vfs.join(b), vfs.join(u), hardlink=True)
664 util.copyfile(vfs.join(b), vfs.join(u), hardlink=True)
661 undobackupfile.write(b"%s\0%s\0%s\0%d\n" % (l, f, u, c))
665 undobackupfile.write(b"%s\0%s\0%s\0%d\n" % (l, f, u, c))
662 undobackupfile.close()
666 undobackupfile.close()
General Comments 0
You need to be logged in to leave comments. Login now