2018-07-02 21:27:20 +03:00
|
|
|
$ . helpers-usechg.sh
|
2018-07-02 22:27:44 +03:00
|
|
|
|
2018-07-02 21:27:20 +03:00
|
|
|
$ enable fbamend inhibit rebase
|
|
|
|
$ setconfig experimental.evolution.allowdivergence=True
|
|
|
|
$ setconfig experimental.evolution="createmarkers, allowunstable"
|
|
|
|
$ mkcommit() {
|
|
|
|
> echo "$1" > "$1"
|
|
|
|
> hg add "$1"
|
|
|
|
> hg ci -m "add $1"
|
|
|
|
> }
|
|
|
|
$ showgraph() {
|
|
|
|
> hg log --graph -T "{rev} {desc|firstline}" | sed \$d
|
|
|
|
> }
|
|
|
|
|
|
|
|
Restack does topological sort and only rebases "D" once:
|
|
|
|
|
|
|
|
$ newrepo
|
|
|
|
$ hg debugdrawdag<<'EOS'
|
|
|
|
> D
|
|
|
|
> |
|
|
|
|
> C
|
|
|
|
> |
|
|
|
|
> B
|
|
|
|
> |
|
|
|
|
> A
|
|
|
|
> EOS
|
|
|
|
$ hg update B -q
|
|
|
|
$ hg commit --amend -m B2 -q --no-rebase 2>/dev/null
|
|
|
|
$ hg tag --local B2
|
|
|
|
$ hg rebase -r C -d B2 -q
|
|
|
|
$ hg commit --amend -m B3 -q --no-rebase 2>/dev/null
|
|
|
|
$ hg tag --local B3
|
|
|
|
$ showgraph
|
|
|
|
@ 6 B3
|
|
|
|
|
|
|
|
|
| o 5 C
|
|
|
|
| |
|
|
|
|
| x 4 B2
|
|
|
|
|/
|
|
|
|
| o 3 D
|
|
|
|
| |
|
|
|
|
| x 2 C
|
|
|
|
| |
|
|
|
|
| x 1 B
|
|
|
|
|/
|
|
|
|
o 0 A
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 5:ca53c8ceb284 "C"
|
|
|
|
rebasing 3:f585351a92f8 "D" (D)
|
|
|
|
$ showgraph
|
|
|
|
o 8 D
|
|
|
|
|
|
|
|
|
o 7 C
|
|
|
|
|
|
|
|
|
@ 6 B3
|
|
|
|
|
|
|
|
|
| x 4 B2
|
|
|
|
|/
|
|
|
|
| x 3 D
|
|
|
|
| |
|
|
|
|
| x 2 C
|
|
|
|
| |
|
|
|
|
| x 1 B
|
|
|
|
|/
|
|
|
|
o 0 A
|
|
|
|
|
|
|
|
Restack will only restack the "current" stack and leave other stacks untouched.
|
|
|
|
|
|
|
|
$ newrepo
|
|
|
|
$ hg debugdrawdag<<'EOS'
|
|
|
|
> D H K
|
|
|
|
> | | |
|
|
|
|
> B C F G J L # amend: B -> C
|
|
|
|
> |/ |/ |/ # amend: F -> G
|
|
|
|
> A E I Z # amend: J -> L
|
|
|
|
> EOS
|
|
|
|
|
|
|
|
$ hg phase --public -r Z+I+A+E
|
|
|
|
|
|
|
|
$ hg update -q Z
|
|
|
|
$ hg rebase --restack
|
|
|
|
nothing to restack
|
|
|
|
[1]
|
|
|
|
|
|
|
|
$ hg update -q D
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 10:be0ef73c17ad "D" (D)
|
|
|
|
|
|
|
|
$ hg update -q G
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 11:cc209258a732 "H" (H)
|
|
|
|
|
|
|
|
$ hg update -q I
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 12:59760668f0e1 "K" (K)
|
|
|
|
|
|
|
|
$ rm .hg/localtags
|
|
|
|
$ showgraph
|
|
|
|
o 15 K
|
|
|
|
|
|
|
|
|
| o 14 H
|
|
|
|
| |
|
|
|
|
| | o 13 D
|
|
|
|
| | |
|
|
|
|
o | | 9 L
|
|
|
|
| | |
|
|
|
|
| o | 7 G
|
|
|
|
| | |
|
|
|
|
| | o 5 C
|
|
|
|
| | |
|
|
|
|
| | | o 3 Z
|
|
|
|
| | |
|
|
|
|
@ | | 2 I
|
|
|
|
/ /
|
|
|
|
o / 1 E
|
|
|
|
/
|
|
|
|
o 0 A
|
|
|
|
|
|
|
|
The "prune" cases.
|
|
|
|
|
|
|
|
$ newrepo
|
|
|
|
$ hg debugdrawdag<<'EOS'
|
|
|
|
> D E
|
|
|
|
> |/
|
|
|
|
> C
|
|
|
|
> | # amend: F -> F2
|
|
|
|
> B G H # prune: A, C, F2
|
|
|
|
> | |/
|
|
|
|
> A F F2
|
|
|
|
> EOS
|
|
|
|
|
|
|
|
$ hg update -q B
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 3:112478962961 "B" (B)
|
|
|
|
rebasing 7:f585351a92f8 "D" (D)
|
|
|
|
rebasing 8:78d2dca436b2 "E" (E tip)
|
|
|
|
|
|
|
|
$ hg update -q H
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 4:8fdb2c1feb20 "G" (G)
|
|
|
|
rebasing 5:02ac06fe83b9 "H" (H)
|
|
|
|
|
|
|
|
$ rm .hg/localtags
|
|
|
|
$ showgraph
|
|
|
|
@ 13 H
|
|
|
|
|
|
|
|
o 12 G
|
|
|
|
|
|
|
|
o 11 E
|
|
|
|
|
|
|
|
|
| o 10 D
|
|
|
|
|/
|
|
|
|
o 9 B
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Restack could resume after resolving merge conflicts.
|
|
|
|
|
|
|
|
$ newrepo
|
|
|
|
$ hg debugdrawdag<<'EOS'
|
|
|
|
> F G # F/C = F # cause conflict
|
|
|
|
> | | # G/E = G # cause conflict
|
|
|
|
> B C D E # amend: B -> C
|
|
|
|
> |/ |/ # amend: D -> E
|
|
|
|
> | /
|
|
|
|
> | /
|
|
|
|
> | /
|
|
|
|
> |/
|
|
|
|
> A
|
|
|
|
> EOS
|
|
|
|
|
|
|
|
$ hg update -q F
|
|
|
|
$ hg rebase --restack
|
|
|
|
rebasing 5:ed8545a5c22a "F" (F)
|
|
|
|
merging C
|
|
|
|
warning: conflicts while merging C! (edit, then use 'hg resolve --mark')
|
|
|
|
unresolved conflicts (see hg resolve, then hg rebase --continue)
|
|
|
|
[1]
|
|
|
|
|
|
|
|
$ rm .hg/localtags
|
|
|
|
|
|
|
|
$ echo R > C
|
|
|
|
$ hg resolve --mark -q
|
|
|
|
continue: hg rebase --continue
|
|
|
|
$ hg rebase --continue
|
|
|
|
rebasing 5:ed8545a5c22a "F"
|
|
|
|
rebasing 6:4d1ef7d890c5 "G" (tip)
|
|
|
|
merging E
|
|
|
|
warning: conflicts while merging E! (edit, then use 'hg resolve --mark')
|
|
|
|
unresolved conflicts (see hg resolve, then hg rebase --continue)
|
|
|
|
[1]
|
|
|
|
|
|
|
|
$ echo R > E
|
|
|
|
$ hg resolve --mark -q
|
|
|
|
continue: hg rebase --continue
|
|
|
|
$ hg rebase --continue
|
|
|
|
already rebased 5:ed8545a5c22a "F" as 2282fe522d5c
|
|
|
|
rebasing 6:4d1ef7d890c5 "G"
|
|
|
|
|
|
|
|
$ showgraph
|
|
|
|
o 8 G
|
|
|
|
|
|
|
|
|
| @ 7 F
|
|
|
|
| |
|
|
|
|
o | 4 E
|
|
|
|
| |
|
|
|
|
| o 2 C
|
|
|
|
|/
|
|
|
|
o 0 A
|
|
|
|
|