1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
-- Test that typical user errors with 'conflicts' give good error messages.
mtn_setup()
----------
-- Conflict that is not supported; attribute
addfile("simple_file", "simple\none\ntwo\nthree\n")
commit("testbranch", "base")
base = base_revision()
check(mtn("attr", "set", "simple_file", "foo", "1"), 0, nil, nil)
commit("testbranch", "left 1")
left_1 = base_revision()
revert_to(base)
check(mtn("attr", "set", "simple_file", "foo", "2"), 0, nil, nil)
commit("testbranch", "right 1")
right_1 = base_revision()
-- invalid number of parameters for 'store'
check(mtn("conflicts", "store", left_1), 1, nil, true)
check(mtn("conflicts", "store", left_1, right_1, right_1), 1, nil, true)
-- success
check(mtn("conflicts", "store", left_1, right_1), 0, nil, true)
canonicalize("stderr")
check(samefilestd("conflicts-attr-store-1", "stderr"))
check(mtn("conflicts", "show_remaining", "foo"), 1, nil, true)
check(qgrep("wrong number of arguments", "stderr"))
check(mtn("conflicts", "show_remaining"), 0, nil, true)
canonicalize("stderr")
check(samefilestd("conflicts-attr-show-1", "stderr"))
check(mtn("conflicts", "show_first", "foo"), 1, nil, true)
check(qgrep("wrong number of arguments", "stderr"))
check(mtn("conflicts", "show_first"), 0, nil, true)
canonicalize("stderr")
check(samefilestd("conflicts-attr-show-2", "stderr"))
----------
-- specify conflicts file not in bookkeeping dir
check(mtn("conflicts", "--conflicts-file", "conflicts", "store", left_1, right_1), 1, nil, true)
check(grep("-v", "detected at", "stderr"), 0, true)
canonicalize("stdout")
check(samefilestd("conflicts-attr-store-2", "stdout"))
----------
-- use old conflicts file for new merge
-- get rid of attr conflict, add half of file content conflict
check(mtn("attr", "set", "simple_file", "foo", "1"), 0, nil, nil)
writefile("simple_file", "simple\ntwo\nthree\nfour\n")
commit("testbranch", "right 2")
right_2 = base_revision()
-- attempt merge with old conflict file
check(mtn("merge", "--resolve-conflicts"), 1, nil, true)
check(grep("-v", "detected at", "stderr"), 0, true)
canonicalize("stdout")
check(samefilestd("merge-old-conflicts-file", "stdout"))
----------
-- 'resolve_first' without resolution (issue 202)
-- other half of file content conflict
revert_to(left_1)
writefile("simple_file", "simple\none\nthree\nfour\n")
commit("testbranch", "left 2")
left_2 = base_revision()
check(mtn("conflicts", "store", left_2, right_2), 0, nil, true)
check(mtn("conflicts", "resolve_first"), 1, nil, true)
check(qgrep("wrong number of arguments", "stderr"))
----------
-- specify inconsistent left and right resolutions for duplicate_name
addfile("checkout.sh", "checkout.sh left 1")
commit("testbranch", "left 3")
revert_to(right_2)
addfile("checkout.sh", "checkout.sh right 1")
commit("testbranch", "right 3")
check(mtn("conflicts", "store"), 0, nil, true)
check(samelines("stderr", {"mtn: 2 conflicts with supported resolutions.",
"mtn: stored in '_MTN/conflicts'"}))
-- invalid number of params
check(mtn("conflicts", "resolve_first_left", "user"), 1, nil, true)
check(qgrep("wrong number of arguments", "stderr"))
check(mtn("conflicts", "resolve_first_left", "user", "checkout.sh", "foo"), 1, nil, true)
check(qgrep("wrong number of arguments", "stderr"))
check(mtn("conflicts", "resolve_first_right", "user"), 1, nil, true)
check(qgrep("wrong number of arguments", "stderr"))
check(mtn("conflicts", "resolve_first_right", "user", "checkout.sh", "foo"), 1, nil, true)
check(qgrep("wrong number of arguments", "stderr"))
-- both sides specify user file
check(mtn("conflicts", "resolve_first_left", "user", "checkout.sh"), 0, nil, nil)
check(mtn("conflicts", "resolve_first_right", "user", "checkout.sh"), 1, nil, true)
check(grep("-v", "detected at", "stderr"), 0, true)
canonicalize("stdout")
check(samelines("stdout",
{"mtn: misuse: other resolution is content_user; specify 'drop', 'rename', or 'user_rename'"}))
-- not in workspace; report nice error; conflicts file must be under
-- _MTN, so need workspace. Fixes bug 30473
check(indir("..", mtn("conflicts", "store", "--db", "resolve_conflicts_errors/test.db", "--branch=testbranch")), 1, nil, true)
check(grep("workspace required but not found", "stderr"), 0, true)
check(grep("conflicts file must be under '_MTN'", "stderr"), 0, true)
-- end of file
|