Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 50188:39256bee2ed9
narrow: drop the dedicated backup code
Now that the transaction manage the writes, we can simply use the transaction for backup.
Some extra cleanup to ensure all changes happens within a transaction will be
made in the next changesets.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 23 Feb 2023 03:28:44 +0100 |
parents | f18e4608bb61 |
children | ab806355fccb |
comparison
equal
deleted
inserted
replaced
50187:f18e4608bb61 | 50188:39256bee2ed9 |
---|---|
2556 # transaction running | 2556 # transaction running |
2557 repo.dirstate.write(None) | 2557 repo.dirstate.write(None) |
2558 else: | 2558 else: |
2559 # discard all changes (including ones already written | 2559 # discard all changes (including ones already written |
2560 # out) in this transaction | 2560 # out) in this transaction |
2561 narrowspec.restorebackup(self, b'journal.narrowspec') | |
2562 narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate') | |
2563 | |
2564 repo.invalidate(clearfilecache=True) | 2561 repo.invalidate(clearfilecache=True) |
2565 | 2562 |
2566 tr = transaction.transaction( | 2563 tr = transaction.transaction( |
2567 rp, | 2564 rp, |
2568 self.svfs, | 2565 self.svfs, |
2686 return tr | 2683 return tr |
2687 | 2684 |
2688 def _journalfiles(self): | 2685 def _journalfiles(self): |
2689 return ( | 2686 return ( |
2690 (self.svfs, b'journal'), | 2687 (self.svfs, b'journal'), |
2691 (self.svfs, b'journal.narrowspec'), | |
2692 (self.vfs, b'journal.narrowspec.dirstate'), | |
2693 (self.vfs, b'journal.branch'), | 2688 (self.vfs, b'journal.branch'), |
2694 (self.vfs, b'journal.desc'), | 2689 (self.vfs, b'journal.desc'), |
2695 (bookmarks.bookmarksvfs(self), b'journal.bookmarks'), | 2690 (bookmarks.bookmarksvfs(self), b'journal.bookmarks'), |
2696 (self.svfs, b'journal.phaseroots'), | 2691 (self.svfs, b'journal.phaseroots'), |
2697 ) | 2692 ) |
2699 def undofiles(self): | 2694 def undofiles(self): |
2700 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()] | 2695 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()] |
2701 | 2696 |
2702 @unfilteredmethod | 2697 @unfilteredmethod |
2703 def _writejournal(self, desc): | 2698 def _writejournal(self, desc): |
2704 narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate') | |
2705 narrowspec.savebackup(self, b'journal.narrowspec') | |
2706 self.vfs.write( | 2699 self.vfs.write( |
2707 b"journal.branch", encoding.fromlocal(self.dirstate.branch()) | 2700 b"journal.branch", encoding.fromlocal(self.dirstate.branch()) |
2708 ) | 2701 ) |
2709 self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc)) | 2702 self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc)) |
2710 bookmarksvfs = bookmarks.bookmarksvfs(self) | 2703 bookmarksvfs = bookmarks.bookmarksvfs(self) |
2818 # the existing one. | 2811 # the existing one. |
2819 with self.dirstate.changing_parents(self): | 2812 with self.dirstate.changing_parents(self): |
2820 self.dirstate.setparents(self.nullid) | 2813 self.dirstate.setparents(self.nullid) |
2821 self.dirstate.clear() | 2814 self.dirstate.clear() |
2822 | 2815 |
2823 narrowspec.restorebackup(self, b'undo.narrowspec') | |
2824 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate') | |
2825 try: | 2816 try: |
2826 branch = self.vfs.read(b'undo.branch') | 2817 branch = self.vfs.read(b'undo.branch') |
2827 self.dirstate.setbranch(encoding.tolocal(branch)) | 2818 self.dirstate.setbranch(encoding.tolocal(branch)) |
2828 except IOError: | 2819 except IOError: |
2829 ui.warn( | 2820 ui.warn( |