Mercurial > hg
comparison mercurial/localrepo.py @ 50071:d91fc026071c
rollback: remove the dirstateguard usage
Thanks to the previous changeset, we no longer needs it.
begone !
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 16 Feb 2023 00:14:21 +0100 |
parents | c8f32aa80dca |
children | a66926099c0f |
comparison
equal
deleted
inserted
replaced
50070:c8f32aa80dca | 50071:d91fc026071c |
---|---|
40 changegroup, | 40 changegroup, |
41 color, | 41 color, |
42 commit, | 42 commit, |
43 context, | 43 context, |
44 dirstate, | 44 dirstate, |
45 dirstateguard, | |
46 discovery, | 45 discovery, |
47 encoding, | 46 encoding, |
48 error, | 47 error, |
49 exchange, | 48 exchange, |
50 extensions, | 49 extensions, |
2693 else: | 2692 else: |
2694 self.ui.warn(_(b"no interrupted transaction available\n")) | 2693 self.ui.warn(_(b"no interrupted transaction available\n")) |
2695 return False | 2694 return False |
2696 | 2695 |
2697 def rollback(self, dryrun=False, force=False): | 2696 def rollback(self, dryrun=False, force=False): |
2698 wlock = lock = dsguard = None | 2697 wlock = lock = None |
2699 try: | 2698 try: |
2700 wlock = self.wlock() | 2699 wlock = self.wlock() |
2701 lock = self.lock() | 2700 lock = self.lock() |
2702 if self.svfs.exists(b"undo"): | 2701 if self.svfs.exists(b"undo"): |
2703 dsguard = dirstateguard.dirstateguard(self, b'rollback') | 2702 return self._rollback(dryrun, force) |
2704 | |
2705 return self._rollback(dryrun, force, dsguard) | |
2706 else: | 2703 else: |
2707 self.ui.warn(_(b"no rollback information available\n")) | 2704 self.ui.warn(_(b"no rollback information available\n")) |
2708 return 1 | 2705 return 1 |
2709 finally: | 2706 finally: |
2710 release(dsguard, lock, wlock) | 2707 release(lock, wlock) |
2711 | 2708 |
2712 @unfilteredmethod # Until we get smarter cache management | 2709 @unfilteredmethod # Until we get smarter cache management |
2713 def _rollback(self, dryrun, force, dsguard): | 2710 def _rollback(self, dryrun, force): |
2714 ui = self.ui | 2711 ui = self.ui |
2715 | 2712 |
2716 parents = self.dirstate.parents() | 2713 parents = self.dirstate.parents() |
2717 try: | 2714 try: |
2718 args = self.vfs.read(b'undo.desc').splitlines() | 2715 args = self.vfs.read(b'undo.desc').splitlines() |
2770 if self.svfs.exists(b'undo.phaseroots'): | 2767 if self.svfs.exists(b'undo.phaseroots'): |
2771 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True) | 2768 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True) |
2772 self.invalidate() | 2769 self.invalidate() |
2773 | 2770 |
2774 if parentgone: | 2771 if parentgone: |
2775 # prevent dirstateguard from overwriting already restored one | |
2776 dsguard.close() | |
2777 | |
2778 narrowspec.restorebackup(self, b'undo.narrowspec') | 2772 narrowspec.restorebackup(self, b'undo.narrowspec') |
2779 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate') | 2773 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate') |
2780 self.dirstate.restorebackup(None, b'undo.dirstate') | 2774 self.dirstate.restorebackup(None, b'undo.dirstate') |
2781 try: | 2775 try: |
2782 branch = self.vfs.read(b'undo.branch') | 2776 branch = self.vfs.read(b'undo.branch') |