##// END OF EJS Templates
rebase: allow aborting when descendants detected...
Matt Mackall -
r19518:12843143 stable
parent child Browse files
Show More
@@ -608,32 +608,36 b' def abort(repo, originalwd, target, stat'
608 'Restore the repository to its original state'
608 'Restore the repository to its original state'
609 dstates = [s for s in state.values() if s != nullrev]
609 dstates = [s for s in state.values() if s != nullrev]
610 immutable = [d for d in dstates if not repo[d].mutable()]
610 immutable = [d for d in dstates if not repo[d].mutable()]
611 cleanup = True
611 if immutable:
612 if immutable:
612 repo.ui.warn(_("warning: can't clean up immutable changesets %s\n")
613 repo.ui.warn(_("warning: can't clean up immutable changesets %s\n")
613 % ', '.join(str(repo[r]) for r in immutable),
614 % ', '.join(str(repo[r]) for r in immutable),
614 hint=_('see hg help phases for details'))
615 hint=_('see hg help phases for details'))
616 cleanup = False
615
617
616 descendants = set()
618 descendants = set()
617 if dstates:
619 if dstates:
618 descendants = set(repo.changelog.descendants(dstates))
620 descendants = set(repo.changelog.descendants(dstates))
619 if descendants - set(dstates):
621 if descendants - set(dstates):
620 repo.ui.warn(_("warning: new changesets detected on target branch, "
622 repo.ui.warn(_("warning: new changesets detected on target branch, "
621 "can't abort\n"))
623 "can't strip\n"))
622 return -1
624 cleanup = False
623 else:
625
626 if cleanup:
624 # Update away from the rebase if necessary
627 # Update away from the rebase if necessary
625 if not immutable and inrebase(repo, originalwd, state):
628 if inrebase(repo, originalwd, state):
626 merge.update(repo, repo[originalwd].rev(), False, True, False)
629 merge.update(repo, repo[originalwd].rev(), False, True, False)
627
630
628 # Strip from the first rebased revision
631 # Strip from the first rebased revision
629 rebased = filter(lambda x: x > -1 and x != target, state.values())
632 rebased = filter(lambda x: x > -1 and x != target, state.values())
630 if rebased and not immutable:
633 if rebased:
631 strippoints = [c.node() for c in repo.set('roots(%ld)', rebased)]
634 strippoints = [c.node() for c in repo.set('roots(%ld)', rebased)]
632 # no backup of rebased cset versions needed
635 # no backup of rebased cset versions needed
633 repair.strip(repo.ui, repo, strippoints)
636 repair.strip(repo.ui, repo, strippoints)
634 clearstatus(repo)
637
635 repo.ui.warn(_('rebase aborted\n'))
638 clearstatus(repo)
636 return 0
639 repo.ui.warn(_('rebase aborted\n'))
640 return 0
637
641
638 def buildstate(repo, dest, rebaseset, collapse):
642 def buildstate(repo, dest, rebaseset, collapse):
639 '''Define which revisions are going to be rebased and where
643 '''Define which revisions are going to be rebased and where
@@ -180,8 +180,8 b" Force a commit on B' during the interrup"
180 Abort the rebasing:
180 Abort the rebasing:
181
181
182 $ hg rebase --abort
182 $ hg rebase --abort
183 warning: new changesets detected on target branch, can't abort
183 warning: new changesets detected on target branch, can't strip
184 [255]
184 rebase aborted
185
185
186 $ hg tglog
186 $ hg tglog
187 @ 6: 'Extra'
187 @ 6: 'Extra'
General Comments 0
You need to be logged in to leave comments. Login now