sapling/tests/test-fbamend-nextrebase.t
Arun Kulshreshtha bc3b0cd1c7 Make hg next --rebase intelligently obsolete/inhibit changesets
Summary:
This change updates the behavior hg next --rebase. Specifically:

  - Only one changeset can be rebased at a time. If there are multiple candidate changesets, the command aborts.
  - Each time a changeset is rebased, its precursor is marked as obsolete, inhibition markers are stripped from it and its ancestors, and its preamend bookmark is deleted, if one exists.
  - The result of this is that if no non-obsolete changesets depend on the existence of the pre-rebased changeset, that changeset and its ancestors will be stripped, resulting in a cleaner user experience.
  - This change also adds back the --evolve flag, but makes it show in error instead of working. It turns out that removing the flag outright breaks the evolve extension.

Test Plan:
See updated unit tests for the exact commands to run to test this, as well as an overview of all of the new situations where behavior was changed.

A basic test plan would be:
1. Initialize a new repository, and create a stack of 4 commits.
2. Amend the second commit in the stack.
3. Do `hg next --rebase`. It should work as before.
4. Do `hg next --rebase` again. This time, the entire old stack should "disappear" from hg sl.

Additionally, attempting to run `hg next --rebase` when there are multiple possible child changesets should fail.

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: quark, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3941922

Tasks: 13570554

Signature: t1:3941922:1475205056:58a8d1726cfcccbf14a38727be0220a09532ec97
2016-09-30 10:40:58 -07:00

307 lines
6.6 KiB
Perl

Set up test environment.
$ . $TESTDIR/require-ext.sh directaccess evolve inhibit
$ extpath=`dirname $TESTDIR`
$ cp $extpath/hgext3rd/fbamend.py $TESTTMP # use $TESTTMP substitution in message
$ cat >> $HGRCPATH << EOF
> [extensions]
> directaccess=
> evolve=
> fbamend=$TESTTMP/fbamend.py
> inhibit=
> rebase=
> strip=
> [experimental]
> evolution = createmarkers
> evolutioncommands = prev next
> EOF
$ mkcommit() {
> echo "$1" > "$1"
> hg add "$1"
> echo "add $1" > msg
> hg ci -l msg
> }
$ reset() {
> cd ..
> rm -rf nextrebase
> hg init nextrebase
> cd nextrebase
> }
$ showgraph() {
> hg log --graph -T "{rev} {desc|firstline}"
> }
$ hg init nextrebase && cd nextrebase
Ensure that the hg next --evolve is disabled.
$ hg next --evolve
abort: the --evolve flag is not supported
(use 'hg next --rebase' instead)
[255]
Check case where there's nothing to rebase.
$ mkcommit a
$ mkcommit b
$ mkcommit c
$ hg prev
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[1] add b
$ hg next --rebase
found no changesets to rebase, doing normal 'hg next' instead
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[2] add c
Create a situation where child commits are left behind after amend.
$ hg prev
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[1] add b
$ echo "b2" > b2
$ hg add b2
$ hg amend -m "add b and b2"
warning: the changeset's children were left behind
(use 'hg amend --fixup' to rebase them)
$ showgraph
@ 4 add b and b2
|
| o 2 add c
| |
| o 1 add b
|/
o 0 add a
Check that hg rebase --next works in the simple case.
$ hg next --rebase --dry-run
hg rebase -r 4538525df7e2b9f09423636c61ef63a4cb872a2d -d 29509da8015c02a5a44d703e561252f6478a1430 -k
hg next
$ hg next --rebase
rebasing 2:4538525df7e2 "add c"
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[5] add c
$ showgraph
@ 5 add c
|
o 4 add b and b2
|
o 0 add a
Ensure we abort if there are multiple children on a precursor.
$ reset
$ mkcommit a
$ mkcommit b
$ mkcommit c
$ hg prev
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[1] add b
$ mkcommit d
created new head
$ hg prev
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[1] add b
$ echo "b3" > b3
$ hg add b3
$ hg amend -m "add b and b3"
warning: the changeset's children were left behind
(use 'hg amend --fixup' to rebase them)
$ showgraph
@ 5 add b and b3
|
| o 3 add d
| |
| | o 2 add c
| |/
| o 1 add b
|/
o 0 add a
$ hg next --rebase
there are multiple child changesets on previous versions of the current changeset, namely:
[4538] add c
[78f8] add d
abort: ambiguous next changeset to rebase
(please rebase the desired one manually)
[255]
Check behavior when there is a child on the current changeset and on
a precursor.
$ reset
$ mkcommit a
$ mkcommit b
$ mkcommit c
$ hg prev
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[1] add b
$ echo b >> b
$ hg amend
warning: the changeset's children were left behind
(use 'hg amend --fixup' to rebase them)
$ mkcommit d
$ hg prev
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[4] add b
$ showgraph
o 5 add d
|
@ 4 add b
|
| o 2 add c
| |
| o 1 add b
|/
o 0 add a
$ hg next --rebase
there are child changesets on one or more previous versions of the current changeset, but the current version also has children
skipping rebasing the following child changesets:
[4538] add c
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[5] add d
Check the case where multiple amends have occurred.
$ reset
$ mkcommit a
$ mkcommit b
$ mkcommit c
$ hg prev
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[1] add b
$ echo b >> b
$ hg amend
warning: the changeset's children were left behind
(use 'hg amend --fixup' to rebase them)
$ echo b >> b
$ hg amend
$ echo b >> b
$ hg amend
$ showgraph
@ 8 add b
|
| o 2 add c
| |
| o 1 add b
|/
o 0 add a
$ hg next --rebase
rebasing 2:4538525df7e2 "add c"
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[9] add c
$ showgraph
@ 9 add c
|
o 8 add b
|
o 0 add a
Check whether we can rebase a stack of commits.
$ reset
$ mkcommit a
$ mkcommit b
$ mkcommit c
$ mkcommit d
$ hg up 1
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
$ echo b >> b
$ hg amend
warning: the changeset's children were left behind
(use 'hg amend --fixup' to rebase them)
$ showgraph
@ 5 add b
|
| o 3 add d
| |
| o 2 add c
| |
| o 1 add b
|/
o 0 add a
$ hg next --rebase
rebasing 2:4538525df7e2 "add c"
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[6] add c
$ showgraph
@ 6 add c
|
o 5 add b
|
| o 3 add d
| |
| o 2 add c
| |
| o 1 add b
|/
o 0 add a
After rebasing the last commit in the stack, the old stack should be stripped.
$ hg next --rebase
rebasing 3:47d2a3944de8 "add d"
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[7] add d
$ showgraph
@ 7 add d
|
o 6 add c
|
o 5 add b
|
o 0 add a
Check whether hg next --rebase behaves correctly when there is a conflict.
$ reset
$ mkcommit a
$ mkcommit b
$ mkcommit conflict
$ hg prev
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[1] add b
$ echo "different" > conflict
$ hg add conflict
$ hg amend
warning: the changeset's children were left behind
(use 'hg amend --fixup' to rebase them)
$ showgraph
@ 4 add b
|
| o 2 add conflict
| |
| o 1 add b
|/
o 0 add a
$ hg next --rebase
rebasing 2:391efaa4d81f "add conflict"
merging conflict
warning: conflicts while merging conflict! (edit, then use 'hg resolve --mark')
please resolve any conflicts, run 'hg rebase --continue', and then run 'hg next'
unresolved conflicts (see hg resolve, then hg rebase --continue)
[1]
$ hg next --rebase
abort: rebase in progress
(use 'hg rebase --continue' or 'hg rebase --abort')
[255]
$ echo "merged" > conflict
$ hg resolve --mark conflict
(no more unresolved files)
continue: hg rebase --continue
$ hg rebase --continue
rebasing 2:391efaa4d81f "add conflict"
$ showgraph
o 5 add conflict
|
@ 4 add b
|
| o 2 add conflict
| |
| o 1 add b
|/
o 0 add a