D3959: rebase: add --stop option to stop rebase at any point (issue5206)

khanchi97 (Sushil khanchi) phabricator at mercurial-scm.org
Sat Jul 21 17:31:53 UTC 2018


khanchi97 added a comment.


  In https://phab.mercurial-scm.org/D3959#61670, @yuja wrote:
  
  > > +    def _stoprebase(self):
  > >  +        """stop the interrupted rebase"""
  > >  +        self.restorestatus()
  > >  +        if not self.stateobj.exists():
  > >  +            raise error.Abort(_("no interrupted rebase found"))
  > >  +        allowunstable = obsolete.isenabled(self.repo, obsolete.allowunstableopt)
  > >  +        if not (self.keepf or allowunstable):
  > >  +            raise error.Abort(_("can't remove original changesets with"
  > >  +                  " unrebased descendants"),
  > >  +                hint=_('either enable evolve extension to allow unstable '
  > >  +                       'revisions or use --keep to keep original changesets'))
  > >  +
  > >  +        # update to the last rebased node if any
  > >  +        ctx = self.repo[None]
  > >  +        pars = [p.node() for p in ctx.parents()]
  > >  +        p1 = pars[0]
  > >  +        hg.updaterepo(self.repo, p1, overwrite=True)
  >
  > Perhaps this differs from what a successful rebase would do. Unlike graft,
  >  `hg rebase` goes back to the original working directory.
  
  
  right, will change it.
  
  > 
  > 
  >> +        # either mark obsolete or keep rebased revisions
  >>  +        repo, ui, opts = self.repo, self.ui, self.opts
  >>  +        fm = ui.formatter('rebase', opts)
  >>  +        fm.startitem()
  >>  +        clearrebased(ui, repo, self.destmap, self.state, self.skipped,
  >>  +                     collapsedas=None, keepf=self.keepf, fm=fm)
  >>  +        clearstatus(self.repo)
  >>  +        fm.end()
  >>  +        return 0
  > 
  > I doubt if this would work with --collapse. Can you try writing some tests?
  
  What is the expected behaviour in case of --collapse? Should it collapse only those revisions which are rebased, then we may have to ask user to change commit message accordingly.
  
  > I'm not pretty sure, but it might be possible to utilize `_finishrebase()`
  >  to implement --stop, roughly by:
  > 
  > 1. restore status
  > 2. drop revisions that aren't rebased yet
  > 3. finish it
  
  yeah, trying to do it in _finishrebase()
  
  > 
  > 
  >> +    elif stop:
  >>  +        #todo: raise error for conflicting options
  > 
  > Yes!

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3959

To: khanchi97, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list