With the multidest rebase (D470), restack could be implemented as specifying
the source (orphan() - obsolete()) and a revset specifying destination for
each source revision.
This patch changes restack implementation to use that. The revset is
implemented as a private function _destrestack, like _destrebase in
rebase.py.
Most test changes are because the topo-sort in rebase.py removes some
unnecessary steps. So the resulting revision numbers are smaller.
There is one interesting test case that gets changed:
D | # amend: B1 -> B2 -> B1 B2 B1 B3 # amend: B1 -> B3 \ | / A
Previously, restack will move D to be on top of B3. Now restack will not
move it because D is considered stable (not orphaned) since none of its
ancestors are obsoleted. The new behavior seems to be more desirable.
More tests are added to test restack source revisions (should be in a same
stack) and some "prune" cases.
The transaction logic is also made more robust so test-copytrace-amend.t
does not cause a broken rebase state.
Since the rebase operation runs in a same rebase state, restack can be
continued via rebase --continue correctly after resolving merge conflicts.
This is reflected in a newly added test.
Would it also make sense to have a revset that finds all of the draft changesets related to the current stack, and then use that here?
If I'm not mistaken, this would also allow restack to just be an alias to hg rebase with the appropriate source and destination revsets.