1mtn_setup() 2 3mkdir("importdir") 4 5------------------------------------------------------------------------------ 6-- First attempt, import something completely fresh. 7writefile("importdir/importmefirst", "version 0 of first test file\n") 8writefile("importdir/.mtn-ignore", "CVS\n") 9 10check(mtn("import", "importdir", 11 "--message", "Import one, fresh start", 12 "--branch", "importbranch"), 0, false, false) 13 14check(exists("importdir/_MTN")) 15 16check(mtn("checkout", "exportdir1", "--branch", "importbranch"), 17 0, false, false) 18 19check(samefile("importdir/importmefirst", "exportdir1/importmefirst")) 20 21remove("importdir/_MTN") 22 23------------------------------------------------------------------------------ 24-- Second attempt, import something with a changed file. 25writefile("importdir/importmefirst", "version 1 of first test file\n") 26writefile("importdir/importmeignored", "version 0 of first ignored file\n") 27 28check(mtn("import", "importdir", 29 "--no-respect-ignore", 30 "--exclude", "importmeignored", 31 "--message", "Import two, a changed file", 32 "--branch", "importbranch"), 0, false, false) 33 34remove("importdir/importmeignored") 35 36check(mtn("checkout", "exportdir2", "--branch", "importbranch"), 37 0, false, false) 38 39check(not exists("exportdir2/importmeignored")) 40check(samefile("importdir/importmefirst", "exportdir2/importmefirst")) 41 42remove("importdir/_MTN") 43 44------------------------------------------------------------------------------ 45-- Third attempt, import something with an added file. 46writefile("importdir/importmesecond", "version 0 of second test file\n") 47writefile("message", "Import three, an added file") 48 49check(mtn("import", "importdir", 50 "--message-file", "message", 51 "--branch", "importbranch"), 0, false, false) 52 53check(mtn("checkout", "exportdir3", "--branch", "importbranch"), 54 0, false, false) 55check(mtn("automate", "heads", "importbranch"), 0, true, false) 56rsha1 = trim(readfile("stdout")) 57 58check(samefile("importdir/importmefirst", "exportdir3/importmefirst")) 59check(samefile("importdir/importmesecond", "exportdir3/importmesecond")) 60 61remove("importdir/_MTN") 62 63------------------------------------------------------------------------------ 64-- Fourth attempt, import something with a changed and a dropped file. 65remove("importdir/importmefirst") 66writefile("importdir/importmesecond", "version 1 of second test file\n") 67 68check(mtn("import", "importdir", 69 "--message", "Import four, a changed and a dropped file", 70 "--branch", "importbranch"), 0, false, false) 71 72check(mtn("checkout", "exportdir4", "--branch", "importbranch"), 73 0, false, false) 74 75check(not exists("exportdir4/importmefirst")) 76check(samefile("importdir/importmesecond", "exportdir4/importmesecond")) 77 78remove("importdir/_MTN") 79 80------------------------------------------------------------------------------ 81-- Fifth attempt, this time adding a third file and importing relative to 82-- an earlier revision 83writefile("importdir/importmethird", "version 0 of third test file\n") 84 85check(mtn("import", "importdir", 86 "--message", "Import five, an added file and relative to a specific revision", 87 "--revision", rsha1), 0, false, true) 88rsha2 = string.gsub(readfile("stderr"), 89 "^.*committed revision ([0-9a-f]+).*$", "%1") 90 91check(mtn("checkout", "exportdir5", "--revision", rsha2), 92 0, false, false) 93 94check(not exists("exportdir5/importmefirst")) 95check(samefile("importdir/importmesecond", "exportdir5/importmesecond")) 96check(samefile("importdir/importmethird", "exportdir5/importmethird")) 97 98remove("importdir/_MTN") 99 100------------------------------------------------------------------------------ 101-- Sixth attempt, dropping a file and. 102-- Trying again against the head of the branch. Since there's a fork, 103-- this attempt is expected to FAIL. 104remove("importdir/importmesecond") 105 106check(mtn("import", "importdir", 107 "--message", "Import six, an dropped file and relative to the heads", 108 "--branch", "importbranch"), 1, false, false) 109 110-- Let's do a merge and try again. 111check(mtn("merge", "--branch", "importbranch"), 0, false, false) 112 113check(mtn("import", "importdir", 114 "--message", "Import six, an dropped file and relative to the heads", 115 "--branch", "importbranch"), 0, false, false) 116 117check(mtn("checkout", "exportdir6", "--branch", "importbranch"), 118 0, false, false) 119 120check(not exists("exportdir6/importmefirst")) 121check(not exists("exportdir6/importmesecond")) 122check(samefile("importdir/importmethird", "exportdir6/importmethird")) 123 124remove("importdir/_MTN") 125 126------------------------------------------------------------------------------ 127-- Seventh attempt, importing from one of the export checkouts. 128-- This attempt is expected to FAIL, because import should refuse to 129-- import from a workspace, but it should keep the original's workspace intact 130check(mtn("import", "exportdir2", 131 "--message", "Import seven, trying to import a workspace", 132 "--branch", "importbranch"), 1, false, false) 133check(exists("exportdir2/_MTN")) 134 135------------------------------------------------------------------------------ 136-- Eight attempt, this time just doing a dry run. 137remove("importdir/importmethird") 138check(mtn("import", "importdir", 139 "--dry-run", 140 "--message", "Import eight, dry run so shouldn't commit", 141 "--branch", "importbranch"), 0, false, true) 142check(not exists("importdir/_MTN")) 143check(not qgrep("committed revision ", "stderr")) 144 145------------------------------------------------------------------------------ 146-- Ninth attempt, fail and remove the temporary _MTN 147-- This attempt is expected to FAIL, because we gave it a non-existing key. 148check(mtn("import", "importdir", 149 "--message", "Import nine, trying to import a workspace", 150 "--branch", "importbranch", 151 "--key", "bozo@bozoland.com"), 1, false, false) 152check(not exists("importdir/_MTN")) 153 154------------------------------------------------------------------------------ 155-- Tenth attempt, importing with an added subdirectory 156mkdir("importdir/subdir10") 157writefile("importdir/subdir10/importmesubdir", "version 0 of subdir file\n") 158 159check(mtn("import", "importdir", 160 "--message", "Import ten, trying to import a workspace subdirectory", 161 "--branch", "importbranch"), 0, false, false) 162 163check(mtn("checkout", "exportdir10", "--branch", "importbranch"), 164 0, false, false) 165 166check(exists("exportdir10/subdir10/importmesubdir")) 167 168remove("importdir/_MTN") 169 170------------------------------------------------------------------------------ 171-- Eleventh attempt, checking that ignorable files aren't normally imported 172mkdir("importdir/subdir11") 173writefile("importdir/fake_test_hooks.lua", "version 0 of ignored file\n") 174writefile("importdir/subdir11/fake_test_hooks.lua", "version 0 of subdir fake ignored file\n") 175 176check(mtn("import", "importdir", 177 "--message", "Import eleven, trying to import a normally ignored file", 178 "--branch", "importbranch"), 0, false, false) 179 180check(mtn("checkout", "exportdir11", "--branch", "importbranch"), 181 0, false, false) 182 183check(not exists("exportdir11/fake_test_hooks.lua")) 184check(not exists("exportdir11/subdir11/fake_test_hooks.lua")) 185 186remove("importdir/_MTN") 187 188------------------------------------------------------------------------------ 189-- twelth attempt, now trying again, without ignoring. 190mkdir("importdir/subdir12") 191writefile("importdir/fake_test_hooks.lua", "version 0 of ignored file\n") 192writefile("importdir/subdir12/fake_test_hooks.lua", "version 0 of subdir fake ignored file\n") 193 194check(mtn("import", "importdir", "--no-respect-ignore", 195 "--message", "Import twelve, trying to import a normally ignored file", 196 "--branch", "importbranch"), 0, false, false) 197 198check(mtn("checkout", "exportdir12", "--branch", "importbranch"), 199 0, false, false) 200 201check(exists("exportdir12/fake_test_hooks.lua")) 202check(exists("exportdir12/subdir12/fake_test_hooks.lua")) 203