[PATCH] rebase: allow rebase to ancestor (issue3010)

Kevin Bullock kbullock+mercurial at ringworld.org
Mon Sep 19 10:12:15 CDT 2011


Copy-edits:

On Sep 19, 2011, at 9:58 AM, pierre-yves.david at logilab.fr wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1316444233 -7200
> # Node ID 27d784f66d741ff8e12fc55fa0080862b67d9203
> # Parent  2ca855126091fb099f3534e32258e9f04e9e7169
> rebase: allow rebase to ancestor (issue3010)
> 
> We only deny rebasing onto direct parent. Thanks to the ancestor argument of
> merge. the "implementation" of this feature only consist in loosing the check

merge, the implementation of this feature only consists of loosening…

> and imply detach when rebasing on ancestor.

and implying detach when rebasing onto an ancestor.

> diff --git a/hgext/rebase.py b/hgext/rebase.py
> --- a/hgext/rebase.py
> +++ b/hgext/rebase.py
> @@ -534,15 +534,18 @@ def buildstate(repo, dest, src, base, de
>                             [s.node for s in repo.mq.applied]):
>         raise util.Abort(_('cannot rebase onto an applied mq patch'))
> 
>     if src:
>         commonbase = repo[src].ancestor(repo[dest])
> -        samebranch = repo[src].branch() == repo[dest].branch()
>         if commonbase == repo[src]:
>             raise util.Abort(_('source is ancestor of destination'))
> -        if samebranch and commonbase == repo[dest]:
> -            raise util.Abort(_('source is descendant of destination'))
> +        if commonbase == repo[dest]:
> +            samebranch = repo[src].branch() == repo[dest].branch()
> +            if samebranch and repo[src] in repo[dest].children():
> +                raise util.Abort(_('source is children of destination'))

…source is child of destination…

> +            # rebase on ancestor, force detach
> +            detach = True
>         source = repo[src].rev()
>         if detach:
>             # We need to keep track of source's ancestors up to the common base
>             srcancestors = set(repo.changelog.ancestors(source))
>             baseancestors = set(repo.changelog.ancestors(commonbase.rev()))
> diff --git a/tests/test-rebase-detach.t b/tests/test-rebase-detach.t
> --- a/tests/test-rebase-detach.t
> +++ b/tests/test-rebase-detach.t
> @@ -279,5 +279,27 @@ Rebasing across null as ancestor
>   | |
>   | o  1: 'E'
>   |/
>   o  0: 'A'
> 
> +
> +  $ hg rebase -d 5 -s 7
> +  saved backup bundle to $TESTTMP/a5/.hg/strip-backup/13547172c9c0-backup.hg
> +  $ hg tglog
> +  @  8: 'D'
> +  |
> +  o  7: 'C'
> +  |
> +  | o  6: 'B'
> +  |/
> +  o  5: 'extra branch'
> +  
> +  o  4: 'H'
> +  |
> +  | o  3: 'G'
> +  |/|
> +  o |  2: 'F'
> +  | |
> +  | o  1: 'E'
> +  |/
> +  o  0: 'A'
> +  
> diff --git a/tests/test-rebase-parameters.t b/tests/test-rebase-parameters.t
> --- a/tests/test-rebase-parameters.t
> +++ b/tests/test-rebase-parameters.t
> @@ -49,11 +49,11 @@ These fail:
> 
>   $ hg clone -q -u . a a1
>   $ cd a1
> 
>   $ hg rebase -s 8 -d 7
> -  abort: source is descendant of destination
> +  abort: source is children of destination
>   [255]
> 
>   $ hg rebase --continue --abort
>   abort: cannot use both abort and continue
>   [255]
> diff --git a/tests/test-rebase-scenario-global.t b/tests/test-rebase-scenario-global.t
> --- a/tests/test-rebase-scenario-global.t
> +++ b/tests/test-rebase-scenario-global.t
> @@ -210,11 +210,11 @@ G onto F - rebase onto an ancestor:
> 
>   $ hg clone -q -u . a a7
>   $ cd a7
> 
>   $ hg rebase -s 6 -d 5
> -  abort: source is descendant of destination
> +  abort: source is children of destination
>   [255]
> 
> F onto G - rebase onto a descendant:
> 
>   $ hg rebase -s 5 -d 6
> @@ -246,5 +246,27 @@ F onto G - rebase onto a descendant:
> 
>   $ hg rebase -b 5 -d 6
>   nothing to rebase
>   [1]
> 
> +C onto A - rebase onto a ancestor:

…an ancestor…

> +
> +  $ hg rebase -d 0 -s 2
> +  saved backup bundle to $TESTTMP/a7/.hg/strip-backup/5fddd98957c8-backup.hg
> +  $ hg tglog
> +  @  7: 'D'
> +  |
> +  o  6: 'C'
> +  |
> +  | o  5: 'H'
> +  | |
> +  | | o  4: 'G'
> +  | |/|
> +  | o |  3: 'F'
> +  |/ /
> +  | o  2: 'E'
> +  |/
> +  | o  1: 'B'
> +  |/
> +  o  0: 'A'
> +  
> +
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

pacem in terris / mir / shanti / salaam / heiwa
Kevin R. Bullock



More information about the Mercurial-devel mailing list