sapling/eden/scm/tests/test-rebase-collapse.t

498 lines
7.5 KiB
Perl
Raw Normal View History

$ setconfig extensions.treemanifest=!
$ enable rebase strip
$ setconfig phases.publish=0
2010-10-01 18:10:06 +04:00
Create repo a:
$ newrepo a
$ drawdag <<'EOS'
> o H
> |
> | o G
> |/|
> o | F
> | |
> | o E
> |/
> | o D
> | |
> | o C
> | |
> | o B
> |/
> o A
> EOS
$ cd $TESTTMP
Rebasing B onto H and collapsing changesets:
$ hg clone -q -u $D a a1
2010-10-01 18:10:06 +04:00
$ cd a1
$ cat > $TESTTMP/editor.sh <<EOF
> echo "==== before editing"
> cat \$1
> echo "===="
> echo "edited manually" >> \$1
> EOF
$ HGEDITOR="sh $TESTTMP/editor.sh" hg rebase --collapse -e --dest $H
rebasing 112478962961 "B"
rebasing 26805aba1e60 "C"
rebasing f585351a92f8 "D" (tip)
==== before editing
Collapsed revision
* B
* C
* D
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: test
HG: branch 'default'
HG: added B
HG: added C
HG: added D
====
2010-10-01 18:10:06 +04:00
$ hg log -Gr 'all()' -T '{desc}'
@ Collapsed revision
2010-10-01 18:10:06 +04:00
| * B
| * C
| * D
|
|
| edited manually
o H
2010-10-01 18:10:06 +04:00
|
| o G
2010-10-01 18:10:06 +04:00
|/|
o | F
2010-10-01 18:10:06 +04:00
| |
| o E
2010-10-01 18:10:06 +04:00
|/
o A
2010-10-01 18:10:06 +04:00
$ hg manifest --rev tip
2010-10-01 18:10:06 +04:00
A
B
C
D
F
H
$ cd $TESTTMP
2010-10-01 18:10:06 +04:00
Rebasing E onto H:
2010-10-01 18:10:06 +04:00
$ hg clone -q -u $H a a2
2010-10-01 18:10:06 +04:00
$ cd a2
$ hg rebase --source $E --collapse --dest $H
rebasing 7fb047a69f22 "E"
rebasing c6001eacfde5 "G"
2010-10-01 18:10:06 +04:00
$ hg log -Gr 'all()' -T '{desc}'
o Collapsed revision
2010-10-01 18:10:06 +04:00
| * E
| * G
| o D
| |
@ | H
| |
| o C
2010-10-01 18:10:06 +04:00
| |
o | F
2010-10-01 18:10:06 +04:00
| |
| o B
2010-10-01 18:10:06 +04:00
|/
o A
2010-10-01 18:10:06 +04:00
$ hg manifest --rev tip
2010-10-01 18:10:06 +04:00
A
E
F
H
$ cd ..
Rebasing G onto H with custom message:
$ hg clone -q -u $H a a3
$ cd a3
$ hg rebase --base 6 -m 'custom message'
abort: message can only be specified with collapse
[255]
$ cat > $TESTTMP/checkeditform.sh <<EOF
> env | grep HGEDITFORM
> true
> EOF
$ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg rebase --source $E --collapse -m 'custom message' -e --dest $H
rebasing 7fb047a69f22 "E"
rebasing c6001eacfde5 "G"
HGEDITFORM=rebase.collapse
$ hg log -Gr 'all()' -T '{desc}'
o custom message
|
| o D
| |
@ | H
| |
| o C
| |
o | F
| |
| o B
|/
o A
$ hg manifest --rev tip
A
E
F
H
$ cd ..
2010-10-01 18:10:06 +04:00
Create repo b:
$ newrepo b
$ drawdag <<'EOS'
> o H
> |
> | o G
> | |\
> | | o F
> | | |
> | | o E
> | | |
> | o | D # D/D=D
> | |\|
> | o | C
> |/ /
> | o B
> |/
> o A
> EOS
$ cd $TESTTMP
2010-10-01 18:10:06 +04:00
Rebase and collapse - more than one external (fail):
$ hg clone -q -u $H b b1
2010-10-01 18:10:06 +04:00
$ cd b1
$ hg rebase -s $C --dest $H --collapse
abort: unable to collapse on top of 3, there is more than one external parent: 1, 6
2010-10-01 18:10:06 +04:00
[255]
Rebase and collapse - E onto H:
$ hg rebase -s $E --dest $H --collapse # root (E) is not a merge
rebasing 49cb92066bfd "E"
rebasing 11abe3fb10b8 "F"
rebasing 202d1982ae8b "G" (tip)
2010-10-01 18:10:06 +04:00
$ hg log -Gr 'all()' -T '{desc}'
o Collapsed revision
2010-10-01 18:10:06 +04:00
|\ * E
| | * F
| | * G
| o D
| |\
@ | | H
| | |
+---o C
2010-10-01 18:10:06 +04:00
| |
| o B
2010-10-01 18:10:06 +04:00
|/
o A
2010-10-01 18:10:06 +04:00
$ hg manifest --rev tip
2010-10-01 18:10:06 +04:00
A
C
D
E
F
H
Create repo c:
$ newrepo c
$ drawdag <<'EOS'
> o I
> |
> | o H
> | |\
> | | o G
> | | |
> | | o F # F/E=F\n
> | | | # F/F=(removed)
> | | o E
> | | |
> | o | D # D/D=D
> | |\|
> | o | C
> |/ /
> | o B
> |/
> o A
> EOS
$ cd $TESTTMP
2010-10-01 18:10:06 +04:00
Rebase and collapse - E onto I:
$ hg clone -q -u $I c c1
2010-10-01 18:10:06 +04:00
$ cd c1
$ hg rebase -s $E --dest $I --collapse # root (E) is not a merge
rebasing 49cb92066bfd "E"
rebasing 3cf8a9483881 "F"
2010-10-01 18:10:06 +04:00
merging E
rebasing 066fd31e12b9 "G"
rebasing c8947cb2e149 "H" (tip)
2010-10-01 18:10:06 +04:00
$ hg log -Gr 'all()' -T '{desc}'
o Collapsed revision
2010-10-01 18:10:06 +04:00
|\ * E
| | * F
| | * G
| | * H
| o D
| |\
@ | | I
| | |
+---o C
2010-10-01 18:10:06 +04:00
| |
| o B
2010-10-01 18:10:06 +04:00
|/
o A
2010-10-01 18:10:06 +04:00
$ hg manifest --rev tip
2010-10-01 18:10:06 +04:00
A
C
D
E
G
I
$ hg up tip -q
2010-10-01 18:10:06 +04:00
$ cat E
F
Create repo d:
$ newrepo d
$ drawdag <<'EOS'
> o F
> |
> | o E
> | |\
> | | o D
> | | |
> | o | C
> | |/
> | o B
> |/
> o A
> EOS
$ cd $TESTTMP
2010-10-01 18:10:06 +04:00
Rebase and collapse - B onto F:
$ hg clone -q -u $F d d1
2010-10-01 18:10:06 +04:00
$ cd d1
$ hg rebase -s $B --collapse --dest $F
rebasing 112478962961 "B"
rebasing 26805aba1e60 "C"
rebasing be0ef73c17ad "D"
rebasing 02c4367d6973 "E" (tip)
2010-10-01 18:10:06 +04:00
$ hg log -Gr 'all()' -T '{desc}'
o Collapsed revision
2010-10-01 18:10:06 +04:00
| * B
| * C
| * D
| * E
@ F
2010-10-01 18:10:06 +04:00
|
o A
2010-10-01 18:10:06 +04:00
$ hg manifest --rev tip
2010-10-01 18:10:06 +04:00
A
B
C
D
F
Rebase, collapse and copies
$ newrepo copies
$ drawdag << 'EOS'
> Q # Q/c=c\n (renamed from f)
> | # Q/g=b\n (renamed from e)
> |
> P # P/d=a\n (copied from a)
> | # P/e=b\n (renamed from b)
> | # P/f=c\n (renamed from c)
> |
> | Y # Y/a=a\na\n
> |/ # Y/b=b\nb\n
> | # Y/c=c\nc\n
> |
> | # X/a=a\n
> X # X/b=b\n
> # X/c=c\n
> # drawdag.defaultfiles=false
> EOS
$ hg up -q $Q
$ hg rebase --collapse -d $Y
rebasing 24b95cf2173d "P"
merging a and d to d
merging b and e to e
merging c and f to f
rebasing 2ccc3426bf6d "Q" (tip)
merging f and c to c
merging e and g to g
$ hg st
$ hg st --copies --change tip
A d
a
A g
b
R b
$ hg up tip -q
$ cat c
c
c
$ cat d
a
a
$ cat g
b
b
$ hg log -r . --template "{file_copies}\n"
d (a)g (b)
rebase: allow collapsing branches in place (issue3111) We allow rebase plus collapse, but not collapse only? I imagine people would rebase first then collapse once they are sure the rebase is correct and it is the right time to finish it. I was reluctant to submit this patch for reasons detailed below, but it improves rebase --collapse usefulness so much it is worth the ugliness. The fix is ugly because we should be fixing the collapse code path rather than the merge. Collapsing by merging changesets repeatedly is inefficient compared to what commit --amend does: commitctx(), update, strip. The problem with the latter is, to generate the synthetic changeset, copy records are gathered with copies.pathcopies(). copies.pathcopies() is still implemented with merging in mind and discards information like file replaced by the copy of another, criss-cross copies and so forth. I believe this information should not be lost, even if we decide not to interpret it fully later, at merge time. The second issue with improving rebase --collapse is the option should not be there to begin with. Rebasing and collapsing are orthogonal and a dedicated command would probably enable a better, simpler ui. We should avoid advertizing rebase --collapse, but with this fix it becomes the best shipped solution to collapse changesets. And for the record, available techniques are: - revert + commit + strip: lose copies - mq/qfold: repeated patching() (mostly correct, fragile) - rebase: repeated merges (mostly correct, fragile) - collapse: revert + tag rewriting wizardry, lose copies - histedit: repeated patching() (mostly correct, fragile) - amend: copies.pathcopies() + commitctx() + update + strip
2012-05-03 17:14:58 +04:00
$ hg log -Gr 'all()' -T '{desc}'
@ Collapsed revision
| * P
| * Q
o Y
rebase: allow collapsing branches in place (issue3111) We allow rebase plus collapse, but not collapse only? I imagine people would rebase first then collapse once they are sure the rebase is correct and it is the right time to finish it. I was reluctant to submit this patch for reasons detailed below, but it improves rebase --collapse usefulness so much it is worth the ugliness. The fix is ugly because we should be fixing the collapse code path rather than the merge. Collapsing by merging changesets repeatedly is inefficient compared to what commit --amend does: commitctx(), update, strip. The problem with the latter is, to generate the synthetic changeset, copy records are gathered with copies.pathcopies(). copies.pathcopies() is still implemented with merging in mind and discards information like file replaced by the copy of another, criss-cross copies and so forth. I believe this information should not be lost, even if we decide not to interpret it fully later, at merge time. The second issue with improving rebase --collapse is the option should not be there to begin with. Rebasing and collapsing are orthogonal and a dedicated command would probably enable a better, simpler ui. We should avoid advertizing rebase --collapse, but with this fix it becomes the best shipped solution to collapse changesets. And for the record, available techniques are: - revert + commit + strip: lose copies - mq/qfold: repeated patching() (mostly correct, fragile) - rebase: repeated merges (mostly correct, fragile) - collapse: revert + tag rewriting wizardry, lose copies - histedit: repeated patching() (mostly correct, fragile) - amend: copies.pathcopies() + commitctx() + update + strip
2012-05-03 17:14:58 +04:00
|
o X
rebase: allow collapsing branches in place (issue3111) We allow rebase plus collapse, but not collapse only? I imagine people would rebase first then collapse once they are sure the rebase is correct and it is the right time to finish it. I was reluctant to submit this patch for reasons detailed below, but it improves rebase --collapse usefulness so much it is worth the ugliness. The fix is ugly because we should be fixing the collapse code path rather than the merge. Collapsing by merging changesets repeatedly is inefficient compared to what commit --amend does: commitctx(), update, strip. The problem with the latter is, to generate the synthetic changeset, copy records are gathered with copies.pathcopies(). copies.pathcopies() is still implemented with merging in mind and discards information like file replaced by the copy of another, criss-cross copies and so forth. I believe this information should not be lost, even if we decide not to interpret it fully later, at merge time. The second issue with improving rebase --collapse is the option should not be there to begin with. Rebasing and collapsing are orthogonal and a dedicated command would probably enable a better, simpler ui. We should avoid advertizing rebase --collapse, but with this fix it becomes the best shipped solution to collapse changesets. And for the record, available techniques are: - revert + commit + strip: lose copies - mq/qfold: repeated patching() (mostly correct, fragile) - rebase: repeated merges (mostly correct, fragile) - collapse: revert + tag rewriting wizardry, lose copies - histedit: repeated patching() (mostly correct, fragile) - amend: copies.pathcopies() + commitctx() + update + strip
2012-05-03 17:14:58 +04:00
Test collapsing in place
$ hg rebase --collapse -b . -d $X
rebasing 71cf332de4cf "Y"
rebasing c2a9a5beba1a "Collapsed revision" (tip)
$ hg st --change tip --copies
rebase: allow collapsing branches in place (issue3111) We allow rebase plus collapse, but not collapse only? I imagine people would rebase first then collapse once they are sure the rebase is correct and it is the right time to finish it. I was reluctant to submit this patch for reasons detailed below, but it improves rebase --collapse usefulness so much it is worth the ugliness. The fix is ugly because we should be fixing the collapse code path rather than the merge. Collapsing by merging changesets repeatedly is inefficient compared to what commit --amend does: commitctx(), update, strip. The problem with the latter is, to generate the synthetic changeset, copy records are gathered with copies.pathcopies(). copies.pathcopies() is still implemented with merging in mind and discards information like file replaced by the copy of another, criss-cross copies and so forth. I believe this information should not be lost, even if we decide not to interpret it fully later, at merge time. The second issue with improving rebase --collapse is the option should not be there to begin with. Rebasing and collapsing are orthogonal and a dedicated command would probably enable a better, simpler ui. We should avoid advertizing rebase --collapse, but with this fix it becomes the best shipped solution to collapse changesets. And for the record, available techniques are: - revert + commit + strip: lose copies - mq/qfold: repeated patching() (mostly correct, fragile) - rebase: repeated merges (mostly correct, fragile) - collapse: revert + tag rewriting wizardry, lose copies - histedit: repeated patching() (mostly correct, fragile) - amend: copies.pathcopies() + commitctx() + update + strip
2012-05-03 17:14:58 +04:00
M a
M c
A d
a
A g
b
R b
$ hg up tip -q
rebase: allow collapsing branches in place (issue3111) We allow rebase plus collapse, but not collapse only? I imagine people would rebase first then collapse once they are sure the rebase is correct and it is the right time to finish it. I was reluctant to submit this patch for reasons detailed below, but it improves rebase --collapse usefulness so much it is worth the ugliness. The fix is ugly because we should be fixing the collapse code path rather than the merge. Collapsing by merging changesets repeatedly is inefficient compared to what commit --amend does: commitctx(), update, strip. The problem with the latter is, to generate the synthetic changeset, copy records are gathered with copies.pathcopies(). copies.pathcopies() is still implemented with merging in mind and discards information like file replaced by the copy of another, criss-cross copies and so forth. I believe this information should not be lost, even if we decide not to interpret it fully later, at merge time. The second issue with improving rebase --collapse is the option should not be there to begin with. Rebasing and collapsing are orthogonal and a dedicated command would probably enable a better, simpler ui. We should avoid advertizing rebase --collapse, but with this fix it becomes the best shipped solution to collapse changesets. And for the record, available techniques are: - revert + commit + strip: lose copies - mq/qfold: repeated patching() (mostly correct, fragile) - rebase: repeated merges (mostly correct, fragile) - collapse: revert + tag rewriting wizardry, lose copies - histedit: repeated patching() (mostly correct, fragile) - amend: copies.pathcopies() + commitctx() + update + strip
2012-05-03 17:14:58 +04:00
$ cat a
a
a
$ cat c
c
c
$ cat d
a
a
$ cat g
b
b
$ cd $TESTTMP
Test collapsing changes that add then remove a file
$ hg init collapseaddremove
$ cd collapseaddremove
$ touch base
$ hg commit -Am base
adding base
$ touch a
$ hg commit -Am a
adding a
$ hg rm a
$ touch b
$ hg commit -Am b
adding b
$ hg book foo
$ hg rebase -d 0 -r "1::2" --collapse -m collapsed
rebasing 6d8d9f24eec3 "a"
rebasing 1cc73eca5ecc "b" (foo tip)
$ hg log -G --template "{rev}: '{desc}' {bookmarks}"
@ 3: 'collapsed' foo
|
o 0: 'base'
$ hg manifest --rev tip
b
base
$ cd $TESTTMP
Test that rebase --collapse will remember message after
running into merge conflict and invoking rebase --continue.
$ hg init collapse_remember_message
$ cd collapse_remember_message
$ touch a
$ hg add a
$ hg commit -m "a"
$ echo "a-default" > a
$ hg commit -m "a-default"
$ hg update -r 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo "a-dev" > a
$ hg commit -m "a-dev"
$ hg rebase --collapse -m "a-default-dev" -d 1
rebasing 1fb04abbc715 "a-dev" (tip)
merging a
warning: 1 conflicts while merging a! (edit, then use 'hg resolve --mark')
unresolved conflicts (see hg resolve, then hg rebase --continue)
[1]
$ rm a.orig
$ hg resolve --mark a
(no more unresolved files)
continue: hg rebase --continue
$ hg rebase --continue
rebasing 1fb04abbc715 "a-dev" (tip)
$ hg log
changeset: 3:3f6f2136305e
tag: tip
parent: 1:3c8db56a44bc
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: a-default-dev
changeset: 1:3c8db56a44bc
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: a-default
changeset: 0:3903775176ed
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: a
$ cd ..