[PATCH STABLE] rebase: fix rebase with no common ancestors (issue4446)

Augie Fackler raf at durin42.com
Mon Nov 10 13:14:01 CST 2014


On Mon, Nov 10, 2014 at 10:46:59AM -0800, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1415645082 28800
> #      Mon Nov 10 10:44:42 2014 -0800
> # Node ID 15e6fe3cd01beba4232780cdef715d47cc0b0df5
> # Parent  2d54aa5397cdb1c697673ba10b7618d5ac25c69e
> rebase: fix rebase with no common ancestors (issue4446)

Queued, many thanks.

>
> The new rebase revset didn't check for the case when there are no common
> ancestors. Now it does. The new behavior should be the same as the pre-3.2
> behavior. Added a test.
>
> diff --git a/hgext/rebase.py b/hgext/rebase.py
> --- a/hgext/rebase.py
> +++ b/hgext/rebase.py
> @@ -274,8 +274,12 @@ def rebase(ui, repo, **opts):
>                                  "can't compute rebase set\n"))
>                      return 1
>                  commonanc = repo.revs('ancestor(%ld, %d)', base, dest).first()
> -                rebaseset = repo.revs('(%d::(%ld) - %d)::',
> -                                      commonanc, base, commonanc)
> +                if commonanc is not None:
> +                    rebaseset = repo.revs('(%d::(%ld) - %d)::',
> +                                          commonanc, base, commonanc)
> +                else:
> +                    rebaseset = []
> +
>                  if not rebaseset:
>                      # transform to list because smartsets are not comparable to
>                      # lists. This should be improved to honor laziness of
> 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
> @@ -468,3 +468,17 @@ Test --tool parameter:
>    [255]
>
>    $ cd ..
> +
> +No common ancestor
> +
> +  $ hg init separaterepo
> +  $ cd separaterepo
> +  $ touch a
> +  $ hg commit -Aqm a
> +  $ hg up -q null
> +  $ touch b
> +  $ hg commit -Aqm b
> +  $ hg rebase -d 0
> +  nothing to rebase from d7486e00c6f1 to 3903775176ed
> +  [1]
> +  $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list