[PATCH 2 of 8 v8] rebase: move new rebase preparation to be a method of the RR class

Yuya Nishihara yuya at tcha.org
Sun Jul 3 05:21:02 EDT 2016


On Fri, 1 Jul 2016 12:29:53 +0000, Kostiantyn Balytskyi wrote:
> # HG changeset patch
> # User Kostia Balytskyi <ikostia at fb.com>
> # Date 1467374993 -7200
> #      Fri Jul 01 14:09:53 2016 +0200
> # Node ID e81fd23ec13aaad3fc0035994bc8a5904d23b72a
> # Parent  16792bbea1d2886c5f98178b22be8edc5d4efc31
> rebase: move new rebase preparation to be a method of the RR class
> 
> This commit moves logic that prepares the execution of a new rebase
> operation to be a method of the rebaseruntime class.
> 
> diff --git a/hgext/rebase.py b/hgext/rebase.py
> --- a/hgext/rebase.py
> +++ b/hgext/rebase.py
> @@ -258,6 +258,57 @@ class rebaseruntime(object):
>              _checkobsrebase(self.repo, self.ui, rebaseobsrevs, rebasesetrevs,
>                              rebaseobsskipped)
>  
> +    def _preparenewrebase(self, dest, rebaseset):
> +        if dest is None:
> +            return _nothingtorebase()
> +
> +        allowunstable = obsolete.isenabled(self.repo, obsolete.allowunstableopt)
> +        if (not (self.keepf or allowunstable)
> +              and self.repo.revs('first(children(%ld) - %ld)',
> +                                 rebaseset, rebaseset)):
> +            raise error.Abort(
> +                _("can't remove original changesets with"
> +                  " unrebased descendants"),
> +                hint=_('use --keep to keep original changesets'))
> +
> +        self.obsoletenotrebased = {}
> +        if self.ui.configbool('experimental', 'rebaseskipobsolete',
> +                              default=True):
> +            rebasesetrevs = set(rebaseset)
> +            rebaseobsrevs = _filterobsoleterevs(self.repo, rebasesetrevs)
> +            self.obsoletenotrebased = _computeobsoletenotrebased(self.repo,
> +                                                            rebaseobsrevs,
> +                                                            dest)
> +            rebaseobsskipped = set(self.obsoletenotrebased)
> +            _checkobsrebase(self.repo, self.ui, rebaseobsrevs,
> +                                          rebasesetrevs,
> +                                          rebaseobsskipped)
> +
> +        result = buildstate(self.repo, dest, rebaseset, self.collapsef,
> +                            self.obsoletenotrebased)
> +
> +        if not result:
> +            # Empty state built, nothing to rebase
> +            self.ui.status(_('nothing to rebase\n'))
> +            return _nothingtorebase()

[snip]

> +            retcode = rbsrt._preparenewrebase(dest, rebaseset)
> +            if retcode is not None:
> +                return retcode

If _nothingtorebase() raises exception, this branching would be clearer.


More information about the Mercurial-devel mailing list