##// END OF EJS Templates
rebase: move abort() onto rebaseruntime...
Martin von Zweigbergk -
r40891:c8eb8d1f default
parent child Browse files
Show More
@@ -347,9 +347,9 b' class rebaseruntime(object):'
347
347
348 if isabort:
348 if isabort:
349 backup = backup and self.backupf
349 backup = backup and self.backupf
350 return abort(self.repo, self.originalwd, self.destmap, self.state,
350 return self._abort(self.repo, self.originalwd, self.destmap,
351 activebookmark=self.activebookmark, backup=backup,
351 self.state, activebookmark=self.activebookmark,
352 suppwarns=suppwarns)
352 backup=backup, suppwarns=suppwarns)
353
353
354 def _preparenewrebase(self, destmap):
354 def _preparenewrebase(self, destmap):
355 if not destmap:
355 if not destmap:
@@ -653,6 +653,66 b' class rebaseruntime(object):'
653 repo['.'].node() == repo._bookmarks[self.activebookmark]):
653 repo['.'].node() == repo._bookmarks[self.activebookmark]):
654 bookmarks.activate(repo, self.activebookmark)
654 bookmarks.activate(repo, self.activebookmark)
655
655
656 def _abort(self, repo, originalwd, destmap, state, activebookmark=None,
657 backup=True, suppwarns=False):
658 '''Restore the repository to its original state. Additional args:
659
660 activebookmark: the name of the bookmark that should be active after the
661 restore'''
662
663 try:
664 # If the first commits in the rebased set get skipped during the
665 # rebase, their values within the state mapping will be the dest
666 # rev id. The rebased list must must not contain the dest rev
667 # (issue4896)
668 rebased = [s for r, s in state.items()
669 if s >= 0 and s != r and s != destmap[r]]
670 immutable = [d for d in rebased if not repo[d].mutable()]
671 cleanup = True
672 if immutable:
673 repo.ui.warn(_("warning: can't clean up public changesets %s\n")
674 % ', '.join(bytes(repo[r]) for r in immutable),
675 hint=_("see 'hg help phases' for details"))
676 cleanup = False
677
678 descendants = set()
679 if rebased:
680 descendants = set(repo.changelog.descendants(rebased))
681 if descendants - set(rebased):
682 repo.ui.warn(_("warning: new changesets detected on "
683 "destination branch, can't strip\n"))
684 cleanup = False
685
686 if cleanup:
687 shouldupdate = False
688 if rebased:
689 strippoints = [
690 c.node() for c in repo.set('roots(%ld)', rebased)]
691
692 updateifonnodes = set(rebased)
693 updateifonnodes.update(destmap.values())
694 updateifonnodes.add(originalwd)
695 shouldupdate = repo['.'].rev() in updateifonnodes
696
697 # Update away from the rebase if necessary
698 if shouldupdate or needupdate(repo, state):
699 mergemod.update(repo, originalwd, branchmerge=False,
700 force=True)
701
702 # Strip from the first rebased revision
703 if rebased:
704 repair.strip(repo.ui, repo, strippoints, backup=backup)
705
706 if activebookmark and activebookmark in repo._bookmarks:
707 bookmarks.activate(repo, activebookmark)
708
709 finally:
710 clearstatus(repo)
711 clearcollapsemsg(repo)
712 if not suppwarns:
713 repo.ui.warn(_('rebase aborted\n'))
714 return 0
715
656 @command('rebase',
716 @command('rebase',
657 [('s', 'source', '',
717 [('s', 'source', '',
658 _('rebase the specified changeset and descendants'), _('REV')),
718 _('rebase the specified changeset and descendants'), _('REV')),
@@ -1609,64 +1669,6 b' def needupdate(repo, state):'
1609
1669
1610 return False
1670 return False
1611
1671
1612 def abort(repo, originalwd, destmap, state, activebookmark=None, backup=True,
1613 suppwarns=False):
1614 '''Restore the repository to its original state. Additional args:
1615
1616 activebookmark: the name of the bookmark that should be active after the
1617 restore'''
1618
1619 try:
1620 # If the first commits in the rebased set get skipped during the rebase,
1621 # their values within the state mapping will be the dest rev id. The
1622 # rebased list must must not contain the dest rev (issue4896)
1623 rebased = [s for r, s in state.items()
1624 if s >= 0 and s != r and s != destmap[r]]
1625 immutable = [d for d in rebased if not repo[d].mutable()]
1626 cleanup = True
1627 if immutable:
1628 repo.ui.warn(_("warning: can't clean up public changesets %s\n")
1629 % ', '.join(bytes(repo[r]) for r in immutable),
1630 hint=_("see 'hg help phases' for details"))
1631 cleanup = False
1632
1633 descendants = set()
1634 if rebased:
1635 descendants = set(repo.changelog.descendants(rebased))
1636 if descendants - set(rebased):
1637 repo.ui.warn(_("warning: new changesets detected on destination "
1638 "branch, can't strip\n"))
1639 cleanup = False
1640
1641 if cleanup:
1642 shouldupdate = False
1643 if rebased:
1644 strippoints = [
1645 c.node() for c in repo.set('roots(%ld)', rebased)]
1646
1647 updateifonnodes = set(rebased)
1648 updateifonnodes.update(destmap.values())
1649 updateifonnodes.add(originalwd)
1650 shouldupdate = repo['.'].rev() in updateifonnodes
1651
1652 # Update away from the rebase if necessary
1653 if shouldupdate or needupdate(repo, state):
1654 mergemod.update(repo, originalwd, branchmerge=False, force=True)
1655
1656 # Strip from the first rebased revision
1657 if rebased:
1658 repair.strip(repo.ui, repo, strippoints, backup=backup)
1659
1660 if activebookmark and activebookmark in repo._bookmarks:
1661 bookmarks.activate(repo, activebookmark)
1662
1663 finally:
1664 clearstatus(repo)
1665 clearcollapsemsg(repo)
1666 if not suppwarns:
1667 repo.ui.warn(_('rebase aborted\n'))
1668 return 0
1669
1670 def sortsource(destmap):
1672 def sortsource(destmap):
1671 """yield source revisions in an order that we only rebase things once
1673 """yield source revisions in an order that we only rebase things once
1672
1674
General Comments 0
You need to be logged in to leave comments. Login now