Add hg rebase --restack
Summary:
This change adds a `--restack` option to `hg rebase`. When invoked, the command will rebase all descendants of precursors of the current changeset onto the current changeset. This is similar to the behavior of `hg evolve --all`, except it only handles unstable changesets, and not other issues that can arise from shared mutable history such as divergence or bumping.
I've been playing around with some of the more advanced features (such as allowing the command to be run from anywhere in the old stack or new stack, as well as allowing the user to specify the number of changesets to rebase), but I wanted to upload the most simple iteration of this command for feedback.
Test Plan:
See unit tests for complete commands.
1. Create a stack of commits.
2. Somewhere in the middle of the stack, amend a commit, potentially several times.
3. Run `hg rebase --restack`.
4. The top half of the stack should be rebased onto the amended commit, and the preamend bookmark should be gone.
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: rmcelroy, quark, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3972103
Tasks: 13651947
Signature: t1:3972103:1476230834:8f77eac4e8d8681dd9f8125747c1ff75c8da1ad8
2016-10-12 03:41:07 +03:00
|
|
|
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 rebasestack
|
|
|
|
> hg init rebasestack
|
|
|
|
> cd rebasestack
|
|
|
|
> }
|
|
|
|
$ showgraph() {
|
|
|
|
> hg log --graph -T "{rev} {desc|firstline}"
|
|
|
|
> }
|
|
|
|
$ hg init rebasestack && cd rebasestack
|
|
|
|
|
|
|
|
Note: Repositories populated by `hg debugbuilddag` don't seem to
|
|
|
|
correctly show all commits in the log output. Manually creating the
|
|
|
|
commits results in the expected behavior, so commits are manually
|
|
|
|
created in the test cases below.
|
|
|
|
|
|
|
|
Test unsupported flags:
|
|
|
|
$ hg rebase --restack --rev .
|
|
|
|
abort: cannot use both --rev and --restack
|
|
|
|
[255]
|
|
|
|
$ hg rebase --restack --dest .
|
|
|
|
abort: cannot use both --dest and --restack
|
|
|
|
[255]
|
|
|
|
$ hg rebase --restack --source .
|
|
|
|
abort: cannot use both --source and --restack
|
|
|
|
[255]
|
|
|
|
$ hg rebase --restack --base .
|
|
|
|
abort: cannot use both --base and --restack
|
|
|
|
[255]
|
|
|
|
$ hg rebase --restack --abort
|
|
|
|
abort: cannot use both --abort and --restack
|
|
|
|
[255]
|
|
|
|
$ hg rebase --restack --continue
|
|
|
|
abort: cannot use both --continue and --restack
|
|
|
|
[255]
|
|
|
|
|
|
|
|
|
|
|
|
Test basic case of a single amend in a small stack.
|
|
|
|
$ 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 rebase --restack
|
|
|
|
rebasing 2:4538525df7e2 "add c"
|
|
|
|
rebasing 3:47d2a3944de8 "add d"
|
|
|
|
$ showgraph
|
|
|
|
o 7 add d
|
|
|
|
|
|
|
|
|
o 6 add c
|
|
|
|
|
|
|
|
|
@ 5 add b
|
|
|
|
|
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
|
|
|
|
Test multiple amends of same commit.
|
|
|
|
$ reset
|
|
|
|
$ mkcommit a
|
|
|
|
$ mkcommit b
|
|
|
|
$ mkcommit c
|
|
|
|
$ hg up 1
|
|
|
|
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 2 add c
|
|
|
|
|
|
|
|
|
@ 1 add b
|
|
|
|
|
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ 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
|
|
|
|
$ showgraph
|
|
|
|
@ 6 add b
|
|
|
|
|
|
|
|
|
| o 2 add c
|
|
|
|
| |
|
|
|
|
| o 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 2:4538525df7e2 "add c"
|
|
|
|
$ showgraph
|
|
|
|
o 7 add c
|
|
|
|
|
|
|
|
|
@ 6 add b
|
|
|
|
|
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
|
|
|
|
Test conflict during rebasing.
|
|
|
|
$ reset
|
|
|
|
$ mkcommit a
|
|
|
|
$ mkcommit b
|
|
|
|
$ mkcommit c
|
|
|
|
$ mkcommit d
|
|
|
|
$ mkcommit e
|
|
|
|
$ hg up 1
|
|
|
|
0 files updated, 0 files merged, 3 files removed, 0 files unresolved
|
|
|
|
$ echo conflict > d
|
|
|
|
$ hg add d
|
|
|
|
$ hg amend
|
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ showgraph
|
|
|
|
@ 6 add b
|
|
|
|
|
|
|
|
|
| o 4 add e
|
|
|
|
| |
|
|
|
|
| o 3 add d
|
|
|
|
| |
|
|
|
|
| o 2 add c
|
|
|
|
| |
|
|
|
|
| o 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 2:4538525df7e2 "add c"
|
|
|
|
rebasing 3:47d2a3944de8 "add d"
|
|
|
|
merging d
|
|
|
|
warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
|
|
|
|
unresolved conflicts (see hg resolve, then hg rebase --continue)
|
|
|
|
[1]
|
|
|
|
$ hg rebase --restack
|
|
|
|
abort: rebase in progress
|
|
|
|
(use 'hg rebase --continue' or 'hg rebase --abort')
|
|
|
|
[255]
|
|
|
|
$ echo merged > d
|
|
|
|
$ hg resolve --mark d
|
|
|
|
(no more unresolved files)
|
|
|
|
continue: hg rebase --continue
|
|
|
|
$ hg rebase --continue
|
|
|
|
already rebased 2:4538525df7e2 "add c" as 5532778357fd
|
|
|
|
rebasing 3:47d2a3944de8 "add d"
|
|
|
|
rebasing 4:9d206ffc875e "add e"
|
|
|
|
$ showgraph
|
|
|
|
o 9 add e
|
|
|
|
|
|
|
|
|
o 8 add d
|
|
|
|
|
|
|
|
|
o 7 add c
|
|
|
|
|
|
|
|
|
@ 6 add b
|
|
|
|
|
|
|
|
|
| o 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
2016-10-14 21:05:53 +03:00
|
|
|
|
|
|
|
Test finding a stable base commit from within the old stack.
|
|
|
|
$ 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)
|
|
|
|
$ hg up 3
|
|
|
|
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 5 add b
|
|
|
|
|
|
|
|
|
| @ 3 add d
|
|
|
|
| |
|
|
|
|
| o 2 add c
|
|
|
|
| |
|
|
|
|
| o 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 2:4538525df7e2 "add c"
|
|
|
|
rebasing 3:47d2a3944de8 "add d"
|
|
|
|
$ showgraph
|
|
|
|
@ 7 add d
|
|
|
|
|
|
|
|
|
o 6 add c
|
|
|
|
|
|
|
|
|
o 5 add b
|
|
|
|
|
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
|
|
|
|
Test finding a stable base commit from a new child of the amended commit.
|
|
|
|
$ 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)
|
|
|
|
$ mkcommit e
|
|
|
|
$ showgraph
|
|
|
|
@ 6 add e
|
|
|
|
|
|
|
|
|
o 5 add b
|
|
|
|
|
|
|
|
|
| o 3 add d
|
|
|
|
| |
|
|
|
|
| o 2 add c
|
|
|
|
| |
|
|
|
|
| o 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 2:4538525df7e2 "add c"
|
|
|
|
rebasing 3:47d2a3944de8 "add d"
|
|
|
|
$ showgraph
|
|
|
|
o 8 add d
|
|
|
|
|
|
|
|
|
o 7 add c
|
|
|
|
|
|
|
|
|
| @ 6 add e
|
|
|
|
|/
|
|
|
|
o 5 add b
|
|
|
|
|
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
|
|
|
|
Test finding a stable base commit when there are multiple amends and
|
|
|
|
a commit on top of one of the obsolete intermediate 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)
|
|
|
|
$ mkcommit e
|
|
|
|
$ hg prev
|
|
|
|
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
2016-11-03 21:11:37 +03:00
|
|
|
[*] add b (glob)
|
2016-10-14 21:05:53 +03:00
|
|
|
$ echo b >> b
|
|
|
|
$ hg amend
|
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ hg up 6
|
|
|
|
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 8 add b
|
|
|
|
|
|
|
|
|
| @ 6 add e
|
|
|
|
| |
|
|
|
|
| o 5 add b
|
|
|
|
|/
|
|
|
|
| o 3 add d
|
|
|
|
| |
|
|
|
|
| o 2 add c
|
|
|
|
| |
|
|
|
|
| o 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 2:4538525df7e2 "add c"
|
|
|
|
rebasing 3:47d2a3944de8 "add d"
|
|
|
|
rebasing 6:c1992d8998fa "add e"
|
|
|
|
$ showgraph
|
|
|
|
@ 11 add e
|
|
|
|
|
|
|
|
|
| o 10 add d
|
|
|
|
| |
|
|
|
|
| o 9 add c
|
|
|
|
|/
|
|
|
|
o 8 add b
|
|
|
|
|
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
Test that we start from the bottom of the stack. (Previously, restack would
|
|
|
|
only repair the unstable children closest to the current changeset. This
|
|
|
|
behavior is now incorrect -- restack should always fix the whole stack.)
|
2016-10-14 21:05:53 +03:00
|
|
|
$ 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)
|
|
|
|
$ hg up 2
|
|
|
|
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ echo c >> c
|
|
|
|
$ hg amend
|
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ hg up 3
|
|
|
|
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 7 add c
|
|
|
|
|
|
|
|
|
| o 5 add b
|
|
|
|
| |
|
|
|
|
| | @ 3 add d
|
|
|
|
| | |
|
|
|
|
+---o 2 add c
|
|
|
|
| |
|
|
|
|
o | 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 3:47d2a3944de8 "add d"
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
rebasing 7:a43fcd08f41f "add c" (tip)
|
|
|
|
rebasing 8:49b119a57122 "add d"
|
2016-10-14 21:05:53 +03:00
|
|
|
$ showgraph
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
@ 10 add d
|
2016-10-14 21:05:53 +03:00
|
|
|
|
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
o 9 add c
|
|
|
|
|
|
|
|
|
o 5 add b
|
2016-10-14 21:05:53 +03:00
|
|
|
|
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
|
|
|
|
Test what happens if there is no base commit found. The command should
|
|
|
|
fix up everything above the current commit, leaving other commits
|
|
|
|
below the current commit alone.
|
|
|
|
$ reset
|
|
|
|
$ mkcommit a
|
|
|
|
$ mkcommit b
|
|
|
|
$ mkcommit c
|
|
|
|
$ mkcommit d
|
|
|
|
$ mkcommit e
|
|
|
|
$ hg up 3
|
|
|
|
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
|
|
|
$ echo d >> d
|
|
|
|
$ hg amend
|
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ hg up 0
|
|
|
|
0 files updated, 0 files merged, 3 files removed, 0 files unresolved
|
|
|
|
$ mkcommit f
|
|
|
|
created new head
|
|
|
|
$ hg up 1
|
|
|
|
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 7 add f
|
|
|
|
|
|
|
|
|
| o 6 add d
|
|
|
|
| |
|
|
|
|
| | o 4 add e
|
|
|
|
| | |
|
|
|
|
| | o 3 add d
|
|
|
|
| |/
|
|
|
|
| o 2 add c
|
|
|
|
| |
|
|
|
|
| @ 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 4:9d206ffc875e "add e"
|
|
|
|
$ showgraph
|
|
|
|
o 8 add e
|
|
|
|
|
|
|
|
|
| o 7 add f
|
|
|
|
| |
|
|
|
|
o | 6 add d
|
|
|
|
| |
|
|
|
|
o | 2 add c
|
|
|
|
| |
|
|
|
|
@ | 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
|
|
|
|
Test having an unamended commit.
|
|
|
|
$ reset
|
|
|
|
$ mkcommit a
|
|
|
|
$ mkcommit b
|
|
|
|
$ mkcommit c
|
|
|
|
$ hg prev
|
|
|
|
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
2016-11-03 21:11:37 +03:00
|
|
|
[*] add b (glob)
|
2016-10-14 21:05:53 +03:00
|
|
|
$ echo b >> b
|
|
|
|
$ hg amend -m "Amended"
|
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ echo b >> b
|
|
|
|
$ hg amend -m "Unamended"
|
|
|
|
$ hg unamend
|
|
|
|
$ hg up -C 1
|
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 4 Amended
|
|
|
|
|
|
|
|
|
| o 2 add c
|
|
|
|
| |
|
|
|
|
| @ 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 2:4538525df7e2 "add c"
|
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 7 add c
|
|
|
|
|
|
|
|
|
@ 4 Amended
|
|
|
|
|
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
Test situation with divergence. Restack should rebase unstable children
|
|
|
|
onto the newest successor of their parent.
|
2016-10-14 21:05:53 +03:00
|
|
|
$ reset
|
|
|
|
$ mkcommit a
|
|
|
|
$ mkcommit b
|
|
|
|
$ mkcommit c
|
|
|
|
$ hg prev
|
|
|
|
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
2016-11-03 21:11:37 +03:00
|
|
|
[*] add b (glob)
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
$ hg amend -m "successor 1"
|
2016-10-14 21:05:53 +03:00
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ hg up 1
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ hg amend -m "successor 2"
|
2016-10-14 21:05:53 +03:00
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ hg up 1
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
2016-10-14 21:05:53 +03:00
|
|
|
$ showgraph
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
o 4 successor 2
|
2016-10-14 21:05:53 +03:00
|
|
|
|
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
| o 3 successor 1
|
2016-10-14 21:05:53 +03:00
|
|
|
|/
|
|
|
|
| o 2 add c
|
|
|
|
| |
|
|
|
|
| @ 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ hg rebase --restack
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
rebasing 2:4538525df7e2 "add c"
|
|
|
|
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 5 add c
|
|
|
|
|
|
|
|
|
@ 4 successor 2
|
|
|
|
|
|
|
|
|
| o 3 successor 1
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
2016-10-14 21:05:53 +03:00
|
|
|
|
|
|
|
Test situation with divergence due to an unamend. This should actually succeed
|
|
|
|
since the successor is obsolete.
|
|
|
|
$ reset
|
|
|
|
$ mkcommit a
|
|
|
|
$ mkcommit b
|
|
|
|
$ mkcommit c
|
|
|
|
$ hg prev
|
|
|
|
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
2016-11-03 21:11:37 +03:00
|
|
|
[*] add b (glob)
|
2016-10-14 21:05:53 +03:00
|
|
|
$ echo b >> b
|
|
|
|
$ hg amend
|
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ hg up 1
|
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ echo c >> b
|
|
|
|
$ hg amend
|
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ hg unamend
|
|
|
|
$ hg up -C 1
|
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 4 add b
|
|
|
|
|
|
|
|
|
| o 2 add c
|
|
|
|
| |
|
|
|
|
| @ 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 2:4538525df7e2 "add c"
|
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 7 add c
|
|
|
|
|
|
|
|
|
@ 4 add b
|
|
|
|
|
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
|
|
|
|
Test recursive restacking -- basic case.
|
|
|
|
$ 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)
|
|
|
|
$ hg up 2
|
|
|
|
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ echo c >> c
|
|
|
|
$ hg amend
|
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ hg up 1
|
|
|
|
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 7 add c
|
|
|
|
|
|
|
|
|
| o 5 add b
|
|
|
|
| |
|
|
|
|
| | o 3 add d
|
|
|
|
| | |
|
|
|
|
+---o 2 add c
|
|
|
|
| |
|
|
|
|
@ | 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 3:47d2a3944de8 "add d"
|
|
|
|
rebasing 7:a43fcd08f41f "add c" (tip)
|
|
|
|
rebasing 8:49b119a57122 "add d"
|
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 10 add d
|
|
|
|
|
|
|
|
|
o 9 add c
|
|
|
|
|
|
|
|
|
@ 5 add b
|
|
|
|
|
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
|
|
|
|
Test recursive restacking -- more complex case. This test is designed to
|
|
|
|
to check for a bug encountered if rebasing is performed naively from the
|
|
|
|
bottom-up wherein obsolescence information for commits further up the
|
|
|
|
stack is lost upon rebasing lower levels.
|
|
|
|
$ 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)
|
|
|
|
$ mkcommit e
|
|
|
|
$ mkcommit f
|
|
|
|
$ hg prev
|
|
|
|
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
2016-11-03 21:11:37 +03:00
|
|
|
[*] add e (glob)
|
2016-10-14 21:05:53 +03:00
|
|
|
$ echo e >> e
|
|
|
|
$ hg amend
|
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ hg up 2
|
|
|
|
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
|
|
|
$ echo c >> c
|
|
|
|
$ hg amend
|
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ mkcommit g
|
|
|
|
$ mkcommit h
|
|
|
|
$ hg prev
|
|
|
|
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
2016-11-03 21:11:37 +03:00
|
|
|
[*] add g (glob)
|
2016-10-14 21:05:53 +03:00
|
|
|
$ echo g >> g
|
|
|
|
$ hg amend
|
|
|
|
warning: the changeset's children were left behind
|
|
|
|
(use 'hg amend --fixup' to rebase them)
|
|
|
|
$ hg up 1
|
|
|
|
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 15 add g
|
|
|
|
|
|
|
|
|
| o 13 add h
|
|
|
|
| |
|
|
|
|
| o 12 add g
|
|
|
|
|/
|
|
|
|
o 11 add c
|
|
|
|
|
|
|
|
|
| o 9 add e
|
|
|
|
| |
|
|
|
|
| | o 7 add f
|
|
|
|
| | |
|
|
|
|
| | o 6 add e
|
|
|
|
| |/
|
|
|
|
| o 5 add b
|
|
|
|
| |
|
|
|
|
| | o 3 add d
|
|
|
|
| | |
|
|
|
|
+---o 2 add c
|
|
|
|
| |
|
|
|
|
@ | 1 add b
|
|
|
|
|/
|
|
|
|
o 0 add a
|
|
|
|
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 13:9f2a7cefd4b4 "add h"
|
|
|
|
rebasing 7:2a79e3a98cd6 "add f"
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
rebasing 3:47d2a3944de8 "add d"
|
2016-10-14 21:05:53 +03:00
|
|
|
rebasing 11:a43fcd08f41f "add c"
|
|
|
|
rebasing 15:604f34a1983d "add g" (tip)
|
|
|
|
rebasing 16:e1df23499b99 "add h"
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
rebasing 18:49b119a57122 "add d"
|
2016-10-14 21:05:53 +03:00
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ showgraph
|
|
|
|
o 22 add d
|
|
|
|
|
|
|
|
|
| o 21 add h
|
|
|
|
| |
|
|
|
|
| o 20 add g
|
|
|
|
|/
|
|
|
|
o 19 add c
|
|
|
|
|
|
fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.
Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.
One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.
It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.
Test Plan:
See unit tests.
1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.
Reviewers: quark, #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4144899
Tasks: 14041544
Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 22:25:19 +03:00
|
|
|
| o 17 add f
|
2016-10-14 21:05:53 +03:00
|
|
|
| |
|
|
|
|
| o 9 add e
|
|
|
|
|/
|
|
|
|
@ 5 add b
|
|
|
|
|
|
|
|
|
o 0 add a
|
|
|
|
|