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

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Wed Aug 8 09:06:35 EDT 2018


yuja added a comment.


  > - def _finishrebase(self): +    def _finishrebase(self, stoprebase=False): repo, ui, opts = self.repo, self.ui, self.opts fm = ui.formatter('rebase', opts) fm.startitem() +        if stoprebase: +            self.restorestatus() +            if self.collapsef: +                ui.status(_("cannot stop in --collapse session\n")) +                return
  
  raise Abort because it's an error?
  
  > +
  >  +            allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
  >  +            if not (self.keepf or allowunstable):
  >  +                raise error.Abort(_("can't remove original changesets with"
  >  +                      " unrebased descendants"),
  >  +                    hint=_('either enable obsmarkers to allow unstable '
  >  +                           'revisions or use --keep to keep original '
  >  +                           'changesets'))
  
  It will be nice if we can move the pre-process out from `_finishrebase()`,
  and get rid of the `stoprebase` flag somehow.
  
  >   if self.collapsef:
  >       p1, p2, _base = defineparents(repo, min(self.state), self.destmap,
  >                                     self.state, self.skipped,
  > 
  > @@ -626,7 +640,10 @@
  > 
  >       newwd = self.originalwd
  >   if newwd not in [c.rev() for c in repo[None].parents()]:
  >       ui.note(_("update back to initial working directory parent\n"))
  > 
  > - hg.updaterepo(repo, newwd, overwrite=False) +            if stoprebase: +                hg.updaterepo(repo, newwd, overwrite=True) +            else: +                hg.updaterepo(repo, newwd, overwrite=False)
  
  This implies an interrupted merge won't be cleared if no update is required.
  (try `hg up 3 && hg rebase -s 1 -d 5` in the first test you've added.)
  
  Perhaps the `rebase --stop` flow can be processed as follows?
  
    rbsrt = rebaseruntime(repo, ui)
    rbsrt.restorestatus()
    ... check unsupported options ...
    with repo.wlock(), repo.lock():
        if needupdate(repo, state):
            .. update to the current working revision with overwrite=True
            .. to clear interrupted merge
        rbsrt._finishrebase()

REPOSITORY
  rHG Mercurial

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

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


More information about the Mercurial-devel mailing list