555 raise |
555 raise |
556 raise util.Abort(_('no rebase in progress')) |
556 raise util.Abort(_('no rebase in progress')) |
557 |
557 |
558 def abort(repo, originalwd, target, state): |
558 def abort(repo, originalwd, target, state): |
559 'Restore the repository to its original state' |
559 'Restore the repository to its original state' |
560 descendants = repo.changelog.descendants |
560 dstates = [s for s in state.values() if s != nullrev] |
561 ispublic = lambda r: repo._phaserev[r] == phases.public |
561 if [d for d in dstates if not repo[d].mutable()]: |
562 if filter(ispublic, descendants(target)): |
|
563 repo.ui.warn(_("warning: immutable rebased changeset detected, " |
562 repo.ui.warn(_("warning: immutable rebased changeset detected, " |
564 "can't abort\n")) |
563 "can't abort\n")) |
565 return -1 |
564 return -1 |
566 elif set(descendants(target)) - set(state.values()): |
565 |
|
566 descendants = set() |
|
567 if dstates: |
|
568 descendants = set(repo.changelog.descendants(*dstates)) |
|
569 if descendants - set(dstates): |
567 repo.ui.warn(_("warning: new changesets detected on target branch, " |
570 repo.ui.warn(_("warning: new changesets detected on target branch, " |
568 "can't abort\n")) |
571 "can't abort\n")) |
569 return -1 |
572 return -1 |
570 else: |
573 else: |
571 # Strip from the first rebased revision |
574 # Strip from the first rebased revision |
572 merge.update(repo, repo[originalwd].rev(), False, True, False) |
575 merge.update(repo, repo[originalwd].rev(), False, True, False) |
573 rebased = filter(lambda x: x > -1 and x != target, state.values()) |
576 rebased = filter(lambda x: x > -1 and x != target, state.values()) |