Mercurial > public > mercurial-scm > hg
diff tests/test-rebase-partial.t @ 32272:78496ac30025
rebase: allow rebase even if some revisions need no rebase (BC) (issue5422)
This allows you to do e.g. "hg rebase -d @ -r 'draft()'" even if some
drafts are already based off of @. You'd still need to exclude
obsolete and troubled revisions, though. We will deal with those cases
later.
Implemented by treating state[rev]==rev as "no need to rebase". I
considered adding another fake revision number like revdone=-6. That
would make the code clearer in a few places, but would add extra code
in other places.
I moved the existing test out of test-rebase-base.t and into a new
file and added more tests there, since not all are using --base.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 11 May 2017 11:37:18 -0700 |
parents | |
children | 6c1a9fd8361b |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-rebase-partial.t Thu May 11 11:37:18 2017 -0700 @@ -0,0 +1,95 @@ +Tests rebasing with part of the rebase set already in the +destination (issue5422) + + $ cat >> $HGRCPATH <<EOF + > [extensions] + > rebase= + > drawdag=$TESTDIR/drawdag.py + > + > [experimental] + > evolution=createmarkers,allowunstable + > + > [alias] + > tglog = log -G --template "{rev}: {desc}" + > EOF + + $ rebasewithdag() { + > N=`$PYTHON -c "print($N+1)"` + > hg init repo$N && cd repo$N + > hg debugdrawdag + > hg rebase "$@" > _rebasetmp + > r=$? + > grep -v 'saved backup bundle' _rebasetmp + > [ $r -eq 0 ] && hg tglog + > cd .. + > return $r + > } + +Rebase two commits, of which one is already in the right place + + $ rebasewithdag -r C+D -d B <<EOF + > C + > | + > B D + > |/ + > A + > EOF + rebasing 2:b18e25de2cf5 "D" (D) + already rebased 3:26805aba1e60 "C" (C tip) + o 4: D + | + | o 3: C + |/ + | x 2: D + | | + o | 1: B + |/ + o 0: A + +Can collapse commits even if one is already in the right place + + $ rebasewithdag --collapse -r C+D -d B <<EOF + > C + > | + > B D + > |/ + > A + > EOF + rebasing 2:b18e25de2cf5 "D" (D) + rebasing 3:26805aba1e60 "C" (C tip) + o 4: Collapsed revision + | * D + | * C + | x 3: C + |/ + | x 2: D + | | + o | 1: B + |/ + o 0: A + +Rebase with "holes". The commits after the hole should end up on the parent of +the hole (B below), not on top of the destination (A). + + $ rebasewithdag -r B+D -d A <<EOF + > D + > | + > C + > | + > B + > | + > A + > EOF + already rebased 1:112478962961 "B" (B) + not rebasing ignored 2:26805aba1e60 "C" (C) + rebasing 3:f585351a92f8 "D" (D tip) + o 4: D + | + | x 3: D + | | + | o 2: C + |/ + o 1: B + | + o 0: A +