diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -50,6 +50,27 @@ # The rollback command is dangerous. As a rule, don't use it. rollback = False +[alias] +# Move orphaned changesets to better places. +# Destination revset explanation: +# - max(roots(ALLSRC) & ::SRC)^ +# The obsoleted changeset that the SRC stack is based on. +# - successors(...)-obsolete() +# A non-obsoleted successor. Or an empty set (no successor). +# - max(...::) +# Get the top of the stack, so history is more linear. +# This is the rebase destination for SRC when there is a successor. +# - max(::((roots(ALLSRC) & ::SRC)^)-obsolete()) +# The first non-obsoleted changeset before the obsoleted changeset that the +# SRC stack is based on. +# This is the rebase destination for SRC when there is no successor. +# - first(A+B) +# Pick B if A is empty. +restack = rebase + -r 'orphan()-obsolete()' + -d 'first(max((successors(max(roots(ALLSRC) & ::SRC)^)-obsolete())::)+ + max(::((roots(ALLSRC) & ::SRC)^)-obsolete()))' + [commands] # Make `hg status` emit cwd-relative paths by default. status.relative = yes @@ -60,6 +81,9 @@ [diff] git = 1 + +[experimental] +rebase.multidest = 1 """ samplehgrcs = { diff --git a/tests/test-tweakdefaults-restack.t b/tests/test-tweakdefaults-restack.t new file mode 100644 --- /dev/null +++ b/tests/test-tweakdefaults-restack.t @@ -0,0 +1,54 @@ + $ cat >> $HGRCPATH< [ui] + > tweakdefaults=1 + > [extensions] + > drawdag=$TESTDIR/drawdag.py + > [experimental] + > stabilization=createmarkers allowunstable + > EOF + + $ hg init repo1 + $ cd repo1 + $ hg debugdrawdag <<'EOS' + > G1 F2 # rebase: F1 -> F2 + > | | + > F1 H # prune: H + > | | + > D E + > | | + > B1 B2 B3 # amend: B1 -> B2 -> B3 + > \ | / + > \|/ + > A + > EOS + $ hg restack + rebasing 8:70cffc4fc494 "F2" (F2) + rebasing 4:68fe7abd1dcc "D" (D) + rebasing 9:7c43db0f1f66 "G1" (G1 tip) + $ hg log -G -T '{desc}' -r 'sort(all(), topo)' + o G1 + | + o D + | + o F2 + | + | x F2 + | | + | x H + |/ + o E + | + o B3 + | + | x B2 + |/ + | x G1 + | | + | x F1 + | | + | x D + | | + | x B1 + |/ + o A +