hgext/rebase.py
changeset 40857 2041991f1ce2
parent 40856 c8eb8d1fc6cf
child 40864 09680349cc2d
equal deleted inserted replaced
40856:c8eb8d1fc6cf 40857:2041991f1ce2
   345                 hint = _('use "hg rebase --abort" to clear broken state')
   345                 hint = _('use "hg rebase --abort" to clear broken state')
   346                 raise error.Abort(msg, hint=hint)
   346                 raise error.Abort(msg, hint=hint)
   347 
   347 
   348         if isabort:
   348         if isabort:
   349             backup = backup and self.backupf
   349             backup = backup and self.backupf
   350             return self._abort(self.repo, self.originalwd, self.destmap,
   350             return self._abort(backup=backup, suppwarns=suppwarns)
   351                                self.state, activebookmark=self.activebookmark,
       
   352                                backup=backup, suppwarns=suppwarns)
       
   353 
   351 
   354     def _preparenewrebase(self, destmap):
   352     def _preparenewrebase(self, destmap):
   355         if not destmap:
   353         if not destmap:
   356             return _nothingtorebase()
   354             return _nothingtorebase()
   357 
   355 
   651 
   649 
   652         if (self.activebookmark and self.activebookmark in repo._bookmarks and
   650         if (self.activebookmark and self.activebookmark in repo._bookmarks and
   653             repo['.'].node() == repo._bookmarks[self.activebookmark]):
   651             repo['.'].node() == repo._bookmarks[self.activebookmark]):
   654                 bookmarks.activate(repo, self.activebookmark)
   652                 bookmarks.activate(repo, self.activebookmark)
   655 
   653 
   656     def _abort(self, repo, originalwd, destmap, state, activebookmark=None,
   654     def _abort(self, backup=True, suppwarns=False):
   657         backup=True, suppwarns=False):
   655         '''Restore the repository to its original state.'''
   658         '''Restore the repository to its original state.  Additional args:
   656 
   659 
   657         repo = self.repo
   660         activebookmark: the name of the bookmark that should be active after the
       
   661             restore'''
       
   662 
       
   663         try:
   658         try:
   664             # If the first commits in the rebased set get skipped during the
   659             # If the first commits in the rebased set get skipped during the
   665             # rebase, their values within the state mapping will be the dest
   660             # rebase, their values within the state mapping will be the dest
   666             # rev id. The rebased list must must not contain the dest rev
   661             # rev id. The rebased list must must not contain the dest rev
   667             # (issue4896)
   662             # (issue4896)
   668             rebased = [s for r, s in state.items()
   663             rebased = [s for r, s in self.state.items()
   669                        if s >= 0 and s != r and s != destmap[r]]
   664                        if s >= 0 and s != r and s != self.destmap[r]]
   670             immutable = [d for d in rebased if not repo[d].mutable()]
   665             immutable = [d for d in rebased if not repo[d].mutable()]
   671             cleanup = True
   666             cleanup = True
   672             if immutable:
   667             if immutable:
   673                 repo.ui.warn(_("warning: can't clean up public changesets %s\n")
   668                 repo.ui.warn(_("warning: can't clean up public changesets %s\n")
   674                              % ', '.join(bytes(repo[r]) for r in immutable),
   669                              % ', '.join(bytes(repo[r]) for r in immutable),
   688                 if rebased:
   683                 if rebased:
   689                     strippoints = [
   684                     strippoints = [
   690                         c.node() for c in repo.set('roots(%ld)', rebased)]
   685                         c.node() for c in repo.set('roots(%ld)', rebased)]
   691 
   686 
   692                 updateifonnodes = set(rebased)
   687                 updateifonnodes = set(rebased)
   693                 updateifonnodes.update(destmap.values())
   688                 updateifonnodes.update(self.destmap.values())
   694                 updateifonnodes.add(originalwd)
   689                 updateifonnodes.add(self.originalwd)
   695                 shouldupdate = repo['.'].rev() in updateifonnodes
   690                 shouldupdate = repo['.'].rev() in updateifonnodes
   696 
   691 
   697                 # Update away from the rebase if necessary
   692                 # Update away from the rebase if necessary
   698                 if shouldupdate or needupdate(repo, state):
   693                 if shouldupdate or needupdate(repo, self.state):
   699                     mergemod.update(repo, originalwd, branchmerge=False,
   694                     mergemod.update(repo, self.originalwd, branchmerge=False,
   700                                     force=True)
   695                                     force=True)
   701 
   696 
   702                 # Strip from the first rebased revision
   697                 # Strip from the first rebased revision
   703                 if rebased:
   698                 if rebased:
   704                     repair.strip(repo.ui, repo, strippoints, backup=backup)
   699                     repair.strip(repo.ui, repo, strippoints, backup=backup)
   705 
   700 
   706             if activebookmark and activebookmark in repo._bookmarks:
   701             if self.activebookmark and self.activebookmark in repo._bookmarks:
   707                 bookmarks.activate(repo, activebookmark)
   702                 bookmarks.activate(repo, self.activebookmark)
   708 
   703 
   709         finally:
   704         finally:
   710             clearstatus(repo)
   705             clearstatus(repo)
   711             clearcollapsemsg(repo)
   706             clearcollapsemsg(repo)
   712             if not suppwarns:
   707             if not suppwarns: