##// END OF EJS Templates
rollback: detect "parentgone" case earlier...
marmoute -
r50964:81870c92 default
parent child Browse files
Show More
@@ -2709,6 +2709,8 b' class localrepository:'
2709 @unfilteredmethod # Until we get smarter cache management
2709 @unfilteredmethod # Until we get smarter cache management
2710 def _rollback(self, dryrun, force, dsguard):
2710 def _rollback(self, dryrun, force, dsguard):
2711 ui = self.ui
2711 ui = self.ui
2712
2713 parents = self.dirstate.parents()
2712 try:
2714 try:
2713 args = self.vfs.read(b'undo.desc').splitlines()
2715 args = self.vfs.read(b'undo.desc').splitlines()
2714 (oldlen, desc, detail) = (int(args[0]), args[1], None)
2716 (oldlen, desc, detail) = (int(args[0]), args[1], None)
@@ -2725,9 +2727,11 b' class localrepository:'
2725 msg = _(
2727 msg = _(
2726 b'repository tip rolled back to revision %d (undo %s)\n'
2728 b'repository tip rolled back to revision %d (undo %s)\n'
2727 ) % (oldtip, desc)
2729 ) % (oldtip, desc)
2730 parentgone = any(self[p].rev() > oldtip for p in parents)
2728 except IOError:
2731 except IOError:
2729 msg = _(b'rolling back unknown transaction\n')
2732 msg = _(b'rolling back unknown transaction\n')
2730 desc = None
2733 desc = None
2734 parentgone = True
2731
2735
2732 if not force and self[b'.'] != self[b'tip'] and desc == b'commit':
2736 if not force and self[b'.'] != self[b'tip'] and desc == b'commit':
2733 raise error.Abort(
2737 raise error.Abort(
@@ -2742,7 +2746,6 b' class localrepository:'
2742 if dryrun:
2746 if dryrun:
2743 return 0
2747 return 0
2744
2748
2745 parents = self.dirstate.parents()
2746 self.destroying()
2749 self.destroying()
2747 vfsmap = {b'plain': self.vfs, b'': self.svfs}
2750 vfsmap = {b'plain': self.vfs, b'': self.svfs}
2748 transaction.rollback(
2751 transaction.rollback(
@@ -2757,8 +2760,6 b' class localrepository:'
2757 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
2760 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
2758 self.invalidate()
2761 self.invalidate()
2759
2762
2760 has_node = self.changelog.index.has_node
2761 parentgone = any(not has_node(p) for p in parents)
2762 if parentgone:
2763 if parentgone:
2763 # prevent dirstateguard from overwriting already restored one
2764 # prevent dirstateguard from overwriting already restored one
2764 dsguard.close()
2765 dsguard.close()
@@ -200,6 +200,7 b' same again, but emulate an old client th'
200 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
200 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
201 $ hg rollback
201 $ hg rollback
202 rolling back unknown transaction
202 rolling back unknown transaction
203 working directory now based on revision 0
203 $ cat a
204 $ cat a
204 a
205 a
205
206
General Comments 0
You need to be logged in to leave comments. Login now