# # # patch "cmd_db.cc" # from [bae93d0020005d845ef331479b4fd2bc1e38f155] # to [8ccf7ff8b005e6f97ed40633430d5d0c92715b85] # # patch "tests/db_kill_rev_locally_workspace/__driver__.lua" # from [54ac3511d65d20e1a91138c515cb5a361896a536] # to [fad650f812bafc5a6c8e563470cb314212a4b4f5] # ============================================================ --- cmd_db.cc bae93d0020005d845ef331479b4fd2bc1e38f155 +++ cmd_db.cc 8ccf7ff8b005e6f97ed40633430d5d0c92715b85 @@ -150,17 +150,20 @@ CMD(db_kill_rev_locally, "kill_rev_local temp_node_id_source nis; app.work.get_work_state_shape_only(parents, curr_roster, nis); - if (parents.size() == 1 && parent_id(parents.begin()) == revid) + if (parents.size() == 1) { - W(F("This workspace is a child of the revision you are killing.\n" - "Pushing it back to be a child of its parents instead\n" - "(all changes will be preserved).")); - - revision_t oldrev; - app.db.get_revision(revid, oldrev); - parent_map new_parents; - app.db.get_parent_map(oldrev, new_parents); - app.work.set_work_state(new_parents, curr_roster); + if (parent_id(parents.begin()) == revid) + { + W(F("This workspace is a child of the revision you are killing.\n" + "Pushing it back to be a child of its parents instead\n" + "(all changes will be preserved).")); + + revision_t oldrev; + app.db.get_revision(revid, oldrev); + parent_map new_parents; + app.db.get_parent_map(oldrev, new_parents); + app.work.set_work_state(new_parents, curr_roster); + } } else if (parents.size() == 2) { ============================================================ --- tests/db_kill_rev_locally_workspace/__driver__.lua 54ac3511d65d20e1a91138c515cb5a361896a536 +++ tests/db_kill_rev_locally_workspace/__driver__.lua fad650f812bafc5a6c8e563470cb314212a4b4f5 @@ -9,20 +9,12 @@ first = base_revision() commit() first = base_revision() +check(mtn("rename", "first", "first-renamed"), 0, false, false) addfile("second", "second") commit() second = base_revision() --- ensure that the revision cannot be removed if there are changes... -addfile("third", "third") -check(mtn("db", "kill_rev_locally", second), 1, false, false) -check(mtn("drop", "third"), 0, false, false) --- ...or missing files in the workspace -remove("second") -check(mtn("db", "kill_rev_locally", second), 1, false, false) -check(mtn("revert", "."), 0, false, false) - --- now check that the revision is properly recreated if the revision +-- check that the revision is properly recreated if the revision -- is killed for real... check(mtn("db", "kill_rev_locally", second), 0, false, false) check(base_revision() == first) @@ -30,10 +22,32 @@ check(base_revision() == second) commit() check(base_revision() == second) +-- make sure it works if there are local changes, too +addfile("third", "third") +check(mtn("db", "kill_rev_locally", second), 0, false, false) +check(base_revision() == first) +check(mtn("automate", "get_revision"), 0, true) +check(qgrep("add_file \"second\"", "stdout")) +check(qgrep("add_file \"third\"", "stdout")) +commit() +third = base_revision() --- finally ensure that the workspace is not touched if we kill +-- ensure that the workspace is not touched if we kill -- a revision which is not the base of the current workspace check(mtn("update", "-r", first), 0, false, false) addfile("fourth", "fourth") -check(mtn("db", "kill_rev_locally", second), 0, false, false) +check(mtn("db", "kill_rev_locally", third), 0, false, false) +check(base_revision() == first) +commit() +fourth = base_revision() +-- ensure that kill_rev_locally errors out if the current workspace is +-- a merge of the rev-to-be-killed with something else +revert_to(first) +addfile("fifth", "fifth") +commit() +fifth = base_revision() +check(mtn("merge_into_workspace", fourth), 0, false, false) + +check(mtn("db", "kill_rev_locally", fourth), 1, false, false) +check(mtn("db", "kill_rev_locally", fifth), 1, false, false)