#
# Tests for merging with renames
#
#
proc commit_id {version} {
regexp -line {^artifact:\s+(\S+)} [fossil whatis $version] - id
return $id
}
require_no_open_checkout
######################################
# Test 1 #
# Reported: Ticket [554f44ee74e3d] #
######################################
test_setup
write_file f1 "line"
fossil add f1
fossil commit -m "c1"
fossil tag add pivot current
write_file f1 "line2"
fossil commit -m "c2"
write_file f1 "line3"
fossil commit -m "c3"
write_file f1 "line4"
fossil commit -m "c4"
write_file f1 "line5"
fossil commit -m "c4"
write_file f1 "line6"
fossil commit -m "c4"
fossil update pivot
fossil mv --hard f1 f2
fossil commit -b rename -m "c5"
fossil merge trunk
fossil commit -m "trunk merged"
fossil update pivot
write_file f3 "someline"
fossil add f3
fossil commit -b branch2 -m "newbranch"
fossil merge trunk
test_status_list merge_renames-1 $RESULT {UPDATE f1}
######################################
# Test 2 #
# Reported: Ticket [74413366fe5067] #
######################################
test_setup
write_file f1 "line"
fossil add f1
fossil commit -m "base file"
fossil tag add pivot current
write_file f2 "line2"
fossil add f2
fossil commit -m "newfile"
fossil mv --hard f2 f2new
fossil commit -m "rename"
fossil update pivot
write_file f1 "line3"
fossil commit -b branch -m "change"
fossil merge trunk
fossil commit -m "trunk merged"
fossil update trunk
fossil merge branch
test_status_list merge_renames-2 $RESULT {UPDATE f1}
######################################
# Test 3 #
# Reported: Ticket [30b28cf351] #
######################################
test_setup
write_file f1 "line"
fossil add f1
fossil commit -m "base file"
fossil tag add pivot current
write_file f2 "line2"
fossil add f2
fossil commit -m "newfile"
fossil mv --hard f2 f2new
fossil commit -m "rename"
fossil update pivot
write_file f1 "line3"
fossil commit -b branch -m "change"
fossil merge trunk
fossil commit -m "trunk merged"
fossil update trunk
fossil merge branch
test_status_list merge_renames-3 $RESULT {UPDATE f1}
######################################
# Test 4 #
# Reported: Ticket [67176c3aa4] #
######################################
test_setup
write_file f1 "f1"
fossil add f1
fossil commit -m "add f1"
write_file f1 "f1.1"
fossil commit --branch b -m "change f1"
fossil update trunk
fossil mv --hard f1 f2
fossil commit -m "f1 -> f2"
fossil merge b
test_status_list merge_renames-4-1 $RESULT {UPDATE f2}
test_file_contents merge_renames-4-2 f2 "f1.1"
######################################
# Test 5 #
# Handle Rename/Add via Merge #
######################################
test_setup
write_file f1 "old f1 line"
fossil add f1
fossil commit -m "base file"
write_file f3 "f3 line"
fossil add f3
fossil commit -m "branch file" -b branch_for_f3
fossil update trunk
fossil mv --hard f1 f2
write_file f1 "new f1 line"
fossil add f1
fossil commit -m "rename and add file with old name"
fossil update branch_for_f3
fossil merge trunk
test_status_list merge_renames-5-1 $RESULT {
RENAME f1 -> f2
ADDED f1
}
fossil commit -m "trunk merged, should have 3 files"
fossil ls
test merge_renames-5-2 {[normalize_result] eq {f1
f2
f3}}
#####################################
# Test 6 #
# Merging a branch multiple times #
#####################################
test_setup
write_file f1 "f1"
fossil add f1
fossil commit -m "add f1"
fossil mv --hard f1 f2
fossil commit -b b -m "f1 -> f2"
fossil update trunk
write_file f3 "f3"
write_file f4 "f4"
fossil add f3 f4
fossil ci -m "add f3, f4"
fossil mv --hard f3 f3-old
fossil mv --hard f4 f3
fossil mv --hard f3-old f4
fossil ci -m "swap f3 and f4"
write_file f1 "f1.1"
fossil commit -m "edit f1"
fossil update b
fossil merge trunk
fossil commit -m "merge trunk"
fossil update trunk
write_file f1 "f1.2"
write_file f3 "f3.1"
write_file f4 "f4.1"
fossil commit -m "edit f1, f4"
fossil update b
fossil merge trunk
test_status_list merge_renames-6-1 $RESULT {
UPDATE f2
UPDATE f3
UPDATE f4
}
test_file_contents merge_renames-6-2 f2 "f1.2"
test_file_contents merge_renames-6-3 f3 "f3.1"
test_file_contents merge_renames-6-4 f4 "f4.1"
########################################################################
# Test 7 #
# Merging with an uncommitted rename of a file that has been renamed #
# in the merged branch and adding a new file with the original name #
########################################################################
test_setup
write_file f1 "f1"
fossil add f1
fossil commit -m "add f1"
fossil mv --hard f1 f2
write_file f2 "f2"
fossil commit -b b -m "f1 -> f2, edit f2"
fossil update trunk
fossil mv --hard f1 f3
write_file f1 "f1.1"
fossil add f1
fossil merge b
test_status_list merge_renames-7-1 $RESULT {UPDATE f3}
test_file_contents merge_renames-7-2 f1 "f1.1"
test_file_contents merge_renames-7-3 f3 "f2"
######################################################
# Test 8 #
# Merging two branches that both add the same file #
######################################################
test_setup
write_file f1 "f1"
fossil commit -m "add f1"
fossil update trunk
write_file f2 "f2.1"
fossil add f2
fossil commit -b b1 -m "add f2"
fossil update trunk
write_file f2 "f2.2"
fossil add f2
fossil commit -b b2 -m "add f2"
fossil update trunk
fossil merge b1
fossil merge b2
test_status_list merge_renames-8-1 $RESULT {
WARNING: no common ancestor for f2
}
fossil revert
fossil merge --integrate b1
fossil merge b2
test_status_list merge_renames-8-2 $RESULT {
WARNING: no common ancestor for f2
}
#############################################
# Test 9 #
# Merging a delete/rename/add combination #
#############################################
test_setup
write_file f1 "f1"
write_file f2 "f2"
fossil add f1 f2
fossil commit -m "add files"
fossil rm --hard f2
fossil commit -b b -m "delete f2"
fossil mv --hard f1 f2
fossil commit -m "f1 -> f2"
write_file f1 "f1.1"
fossil add f1
fossil commit -m "add new f1"
fossil update trunk
fossil merge b
set expectedMerge {
DELETE f2
RENAME f1 -> f2
ADDED f1
}
test_status_list merge_renames-9-1 $RESULT $expectedMerge
fossil changes
test_status_list merge_renames-9-2 $RESULT "
MERGED_WITH [commit_id b]
ADDED_BY_MERGE f1
RENAMED f2
DELETED f2 (overwritten by rename)
"
test_file_contents merge_renames-9-3 f1 "f1.1"
test_file_contents merge_renames-9-4 f2 "f1"
# Undo and ensure a dry run merge results in no changes
fossil undo
test_status_list merge_renames-9-5 $RESULT {
UNDO f1
UNDO f2
}
fossil merge -n b
test_status_list merge_renames-9-6 $RESULT "
$expectedMerge
REMINDER: this was a dry run - no files were actually changed.
"
test merge_renames-9-7 {[fossil changes] eq ""}
######################################
#
# Tests for troubles not specifically linked with renames but that I'd like to
# write:
# [c26c63eb1b] - 'merge --backout' does not handle conflicts properly
# [953031915f] - Lack of warning when overwriting extra files
# [4df5f38f1e] - Troubles merging a file delete with a file change
###############################################################################
test_cleanup