# HG changeset patch # User Pierre-Yves David # Date 2011-09-19 14:57:13 # 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 --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -536,11 +536,14 @@ def buildstate(repo, dest, src, base, de 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 --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 @@ -281,3 +281,25 @@ Rebasing across null as ancestor |/ 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 @@ -51,7 +51,7 @@ These fail: $ 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 --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 @@ -212,7 +212,7 @@ G onto F - rebase onto an ancestor: $ 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 @@ F onto G - rebase onto a descendant: 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' + +