[PATCH] rebase: block collapse and keepbranches on multiple named branches (issue2112)

Matt Mackall mpm at selenic.com
Tue Jul 19 15:58:47 CDT 2011


On Mon, 2011-07-18 at 22:58 +0200, Stefano Tortarolo wrote:
> # HG changeset patch
> # User Stefano Tortarolo <stefano.tortarolo at gmail.com>
> # Date 1311022701 -7200
> # Node ID b9fff4df56509c1c3c7f714f30041057b97c9877
> # Parent  647071c6dfcfc19a4dedb37c1e4c0b60378d953b
> rebase: block collapse and keepbranches on multiple named branches (issue2112)
> 
> Collapse and keepbranches should be blocked when there is more than
> one named branch on the branch that's going to be rebased.

Why can't keepbranches work with more than one branch name?


> diff --git a/hgext/rebase.py b/hgext/rebase.py
> --- a/hgext/rebase.py
> +++ b/hgext/rebase.py
> @@ -175,6 +175,14 @@
>              assert not extrafn, 'cannot use both keepbranches and extrafn'
>              def extrafn(ctx, extra):
>                  extra['branch'] = ctx.branch()
> +            if collapsef:
> +                branches = set()
> +                for rev in state:
> +                    branches.add(repo[rev].branch())
> +                    if len(branches) > 1:
> +                        raise util.Abort(_('cannot collapse multiple named ' 
> +                            'branches'))
> +
>  
>          # Rebase
>          if not targetancestors:
> diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
> --- a/tests/test-rebase-collapse.t
> +++ b/tests/test-rebase-collapse.t
> @@ -442,3 +442,41 @@
>    D
>    F
>  
> +Interactions between collapse and keepbranches
> +  $ cd ..
> +  $ hg init e
> +  $ cd e
> +  $ echo 'a' > a
> +  $ hg ci -Am 'A'
> +  adding a
> +
> +  $ hg branch '1'
> +  marked working directory as branch 1
> +  $ echo 'b' > b
> +  $ hg ci -Am 'B'
> +  adding b
> +
> +  $ hg branch '2'
> +  marked working directory as branch 2
> +  $ echo 'c' > c
> +  $ hg ci -Am 'C'
> +  adding c
> +
> +  $ hg up -q 0
> +  $ echo 'd' > d
> +  $ hg ci -Am 'D'
> +  adding d
> +
> +  $ hg tglog
> +  @  3: 'D'
> +  |
> +  | o  2: 'C' 2
> +  | |
> +  | o  1: 'B' 1
> +  |/
> +  o  0: 'A'
> +  
> +  $ hg rebase --keepbranches --collapse -s 1 -d 3
> +  abort: cannot collapse multiple named branches
> +  [255]
> +
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list