# HG changeset patch # User Pierre-Yves David # Date 1316444233 -7200 # Node ID 81f76098211ed22265f821aa95f831d440ed43f2 # Parent 7c26ce9edbd2964868dbe1c80026a0cfac9926cd 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 and imply detach when rebasing on ancestor. diff -r 7c26ce9edbd2 -r 81f76098211e hgext/rebase.py --- a/hgext/rebase.py Sun Sep 18 19:59:33 2011 -0400 +++ b/hgext/rebase.py Mon Sep 19 16:57:13 2011 +0200 @@ -536,11 +536,14 @@ 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 a 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 diff -r 7c26ce9edbd2 -r 81f76098211e tests/test-rebase-detach.t --- a/tests/test-rebase-detach.t Sun Sep 18 19:59:33 2011 -0400 +++ b/tests/test-rebase-detach.t Mon Sep 19 16:57:13 2011 +0200 @@ -281,3 +281,25 @@ |/ 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 -r 7c26ce9edbd2 -r 81f76098211e tests/test-rebase-parameters.t --- a/tests/test-rebase-parameters.t Sun Sep 18 19:59:33 2011 -0400 +++ b/tests/test-rebase-parameters.t Mon Sep 19 16:57:13 2011 +0200 @@ -51,7 +51,7 @@ $ cd a1 $ hg rebase -s 8 -d 7 - abort: source is descendant of destination + abort: source is a child of destination [255] $ hg rebase --continue --abort diff -r 7c26ce9edbd2 -r 81f76098211e tests/test-rebase-scenario-global.t --- a/tests/test-rebase-scenario-global.t Sun Sep 18 19:59:33 2011 -0400 +++ b/tests/test-rebase-scenario-global.t Mon Sep 19 16:57:13 2011 +0200 @@ -212,7 +212,7 @@ $ cd a7 $ hg rebase -s 6 -d 5 - abort: source is descendant of destination + abort: source is a child of destination [255] F onto G - rebase onto a descendant: @@ -248,3 +248,25 @@ nothing to rebase [1] +C onto A - rebase onto 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' + +