# # # add_dir "tests/publish" # # add_file "tests/publish/__driver__.lua" # content [6a30a6e59827316789c2a8fab4b7991987ab620d] # # patch "cmd_ws_commit.cc" # from [11f7828e55ab3370e5818bebcb023976f3492cf2] # to [fad7244081d40204af5e832e5037447fe1160f54] # # patch "testsuite.lua" # from [21be0891770807a4e8dce87e9d5869bd11cf259d] # to [4eb6a85cd96f7001105d94c1623b2def71a388fa] # ============================================================ --- tests/publish/__driver__.lua 6a30a6e59827316789c2a8fab4b7991987ab620d +++ tests/publish/__driver__.lua 6a30a6e59827316789c2a8fab4b7991987ab620d @@ -0,0 +1,42 @@ +skip_if(not existsonpath("test")) +mtn_setup() + +addfile("readme.txt", "nothing to see here\n") +check(mtn("ci", "--message=test", "--branch=testbranch"), 0, false, false) + +check({"touch", "test_publish"}, 0, false, false) +--no args +check(mtn("publish"), 2, false, false) + +--db, but no revision +check(mtn("publish", "--db=test.db"), 2, false, false) + +--db and revision, but no dest dir +check(mtn("publish", "--db=test.db", "--branch=testbranch"), 2, false, false) + +--proper args, but checkout to . should fail +check(mtn("publish", "--db=test.db", "--branch=testbranch", "."), 1, false, false) + +--db and revision, but test_publish is a file! +check(mtn("publish", "--db=test.db", "--branch=testbranch", "test_publish"), 1, false, false) + +--proper args, should work +check({"rm", "test_publish"}, 0, false, false) +check(mtn("publish", "--db=test.db", "--branch=testbranch", "test_publish"), 0, false, false) +check({"test", "-d", "test_publish"}, 0, false, false) +check({"test", "-f", "test_publish/readme.txt"}, 0, false, false) + +--now, the dest exists but is a directory. fail still +check(mtn("publish", "--db=test.db", "-r h:testbranch", "test_publish"), 1, false, false) +--there shouldn't be a backup in this case +check({"ls", "-1d", "test_publish*bak*"}, 2, false, false) + +--verify that the backup directory doesn't exist yet... +check({"ls"}, 0, true, false) +check(not qgrep("test_publish.bak", "stdout")) + +--do my bidding! (--force) +check(mtn("publish", "--db=test.db", "--branch=testbranch", "--force", "test_publish"), 0, false, false) +--verify that the backup directory was created. +check({"ls"}, 0, true, false) +check(qgrep("test_publish.bak", "stdout")) ============================================================ --- cmd_ws_commit.cc 11f7828e55ab3370e5818bebcb023976f3492cf2 +++ cmd_ws_commit.cc fad7244081d40204af5e832e5037447fe1160f54 @@ -505,6 +505,11 @@ CMD_NO_WORKSPACE(publish, N_("tree"), N_ throw usage(name); utf8 dest(idx(args, 0)); + + //not sure if this is really necessary as a precaution, + //but we'll leave it for now. + N(dest() != ".", F("we won't publish to the cwd")); + system_path dest_path(dest); //we'll trample an existing path, but only with --force ============================================================ --- testsuite.lua 21be0891770807a4e8dce87e9d5869bd11cf259d +++ testsuite.lua 4eb6a85cd96f7001105d94c1623b2def71a388fa @@ -696,4 +696,4 @@ table.insert(tests, "fail_cleanly_when__ table.insert(tests, "log_--to") table.insert(tests, "mkdir") table.insert(tests, "fail_cleanly_when__MTN_format_corrupt") +table.insert(tests, "publish") -