##// END OF EJS Templates
rebase: allow aborting if last-message.txt is missing...
Durham Goode -
r31225:749b057b default
parent child Browse files
Show More
@@ -283,7 +283,7 b' class rebaseruntime(object):'
283 def _prepareabortorcontinue(self, isabort):
283 def _prepareabortorcontinue(self, isabort):
284 try:
284 try:
285 self.restorestatus()
285 self.restorestatus()
286 self.collapsemsg = restorecollapsemsg(self.repo)
286 self.collapsemsg = restorecollapsemsg(self.repo, isabort)
287 except error.RepoLookupError:
287 except error.RepoLookupError:
288 if isabort:
288 if isabort:
289 clearstatus(self.repo)
289 clearstatus(self.repo)
@@ -369,6 +369,10 b' class rebaseruntime(object):'
369 if self.activebookmark:
369 if self.activebookmark:
370 bookmarks.deactivate(repo)
370 bookmarks.deactivate(repo)
371
371
372 # Store the state before we begin so users can run 'hg rebase --abort'
373 # if we fail before the transaction closes.
374 self.storestatus()
375
372 sortedrevs = repo.revs('sort(%ld, -topo)', self.state)
376 sortedrevs = repo.revs('sort(%ld, -topo)', self.state)
373 cands = [k for k, v in self.state.iteritems() if v == revtodo]
377 cands = [k for k, v in self.state.iteritems() if v == revtodo]
374 total = len(cands)
378 total = len(cands)
@@ -1092,7 +1096,7 b' def clearcollapsemsg(repo):'
1092 'Remove collapse message file'
1096 'Remove collapse message file'
1093 util.unlinkpath(repo.join("last-message.txt"), ignoremissing=True)
1097 util.unlinkpath(repo.join("last-message.txt"), ignoremissing=True)
1094
1098
1095 def restorecollapsemsg(repo):
1099 def restorecollapsemsg(repo, isabort):
1096 'Restore previously stored collapse message'
1100 'Restore previously stored collapse message'
1097 try:
1101 try:
1098 f = repo.vfs("last-message.txt")
1102 f = repo.vfs("last-message.txt")
@@ -1101,7 +1105,11 b' def restorecollapsemsg(repo):'
1101 except IOError as err:
1105 except IOError as err:
1102 if err.errno != errno.ENOENT:
1106 if err.errno != errno.ENOENT:
1103 raise
1107 raise
1104 raise error.Abort(_('no rebase in progress'))
1108 if isabort:
1109 # Oh well, just abort like normal
1110 collapsemsg = ''
1111 else:
1112 raise error.Abort(_('missing .hg/last-message.txt for rebase'))
1105 return collapsemsg
1113 return collapsemsg
1106
1114
1107 def clearstatus(repo):
1115 def clearstatus(repo):
@@ -218,6 +218,7 b' Check that the right ancestors is used w'
218
218
219 $ hg rebase -s9 -d2 --debug # use debug to really check merge base used
219 $ hg rebase -s9 -d2 --debug # use debug to really check merge base used
220 rebase onto 4bc80088dc6b starting from e31216eec445
220 rebase onto 4bc80088dc6b starting from e31216eec445
221 rebase status stored
221 ignoring null merge rebase of 3
222 ignoring null merge rebase of 3
222 ignoring null merge rebase of 4
223 ignoring null merge rebase of 4
223 ignoring null merge rebase of 6
224 ignoring null merge rebase of 6
@@ -272,7 +272,8 b' G onto B - merge revision with both pare'
272 rebasing 6:eea13746799a "G"
272 rebasing 6:eea13746799a "G"
273 abort: cannot use revision 6 as base, result would have 3 parents
273 abort: cannot use revision 6 as base, result would have 3 parents
274 [255]
274 [255]
275
275 $ hg rebase --abort
276 rebase aborted
276
277
277 These will abort gracefully (using --base):
278 These will abort gracefully (using --base):
278
279
General Comments 0
You need to be logged in to leave comments. Login now