# # # patch "tests/move_conflicting_unversioned/__driver__.lua" # from [b877f7323639fe334a59662bc82689004477d17d] # to [ca0616d6fa6d37d2d55bb3ea9273ce633714f9fd] # # patch "work.cc" # from [9404833cb99d1be51894d514e4ebe90ee25704fb] # to [6862807a01614c6ccbe156337ea740b4db4529be] # ============================================================ --- tests/move_conflicting_unversioned/__driver__.lua b877f7323639fe334a59662bc82689004477d17d +++ tests/move_conflicting_unversioned/__driver__.lua ca0616d6fa6d37d2d55bb3ea9273ce633714f9fd @@ -1,7 +1,25 @@ -- Demonstrate --move-conflicting-paths +-- +-- There are two 'update' use cases: +-- +-- 1) user has unknown files and/or directories with the same names as +-- added files or directories in a new revision. +-- +-- 2) user has unknown files in a directory that is dropped in a new +-- revision +-- +-- 3) user has known files with changes that are dropped in a new +-- revision +-- +-- --move-conflicting-paths handles cases 1, 2; but not 3. +-- +-- There are also 'checkout', 'pluck', and 'pivot_root' use cases. The +-- core machinery is the same as for the above, so we just do one test +-- for each of these. mtn_setup() +-- Use case 1. addfile("somefile", "somefile content") mkdir("somedir") addfile("somedir/anotherfile", "anotherfile content") @@ -11,6 +29,7 @@ commit("testbranch", "one") addfile("thirdfile", "thirdfile content") addfile("somedir/fourthfile", "fourthfile content") commit("testbranch", "one") +rev_one = base_revision() revert_to(base) writefile("thirdfile", "thirdfile content 2") @@ -23,5 +42,30 @@ check(qgrep("moved conflicting", "stderr -- moves them out of the way check(mtn("update", "--move-conflicting-paths"), 0, nil, true) check(qgrep("moved conflicting", "stderr")) +check(readfile("_MTN/resolutions/somedir/fourthfile")=="fourthfile content 2") +remove("_MTN/resolutions") + +-- Use case 2. +revert_to(rev_one) +check(mtn("drop", "somedir/fourthfile"), 0, nil, true) +check(mtn("drop", "somedir/anotherfile"), 0, nil, true) +check(mtn("drop", "somedir"), 0, nil, true) +commit("testbranch", "two") + +revert_to(rev_one) + +writefile("somedir/fifthfile", "fifthfile content 1") + +-- reports conflicts with unversioned files +check(mtn("update"), 1, nil, true) +check(qgrep("cannot drop non-empty directory", "stderr")) + +-- moves them out of the way +check(mtn("update", "--move-conflicting-paths"), 0, nil, true) +check(qgrep("moved conflicting", "stderr")) +check(readfile("_MTN/resolutions/somedir/fifthfile")=="fifthfile content 1") + +-- FIXME: do checkout, pluck, pivot_root + -- end of file ============================================================ --- work.cc 9404833cb99d1be51894d514e4ebe90ee25704fb +++ work.cc 6862807a01614c6ccbe156337ea740b4db4529be @@ -1308,8 +1308,11 @@ simulated_working_tree::commit() void simulated_working_tree::commit() { - E(conflicts == 0, origin::user, - F("%d workspace conflicts") % conflicts); + // This used to error out on any conflicts, but now some can be resolved + // (by --move-conflicting-paths), so we just warn. The non-resolved + // conflicts generate other errors downstream. + if (conflicts > 0) + F("%d workspace conflicts") % conflicts; } simulated_working_tree::~simulated_working_tree() @@ -1324,8 +1327,7 @@ move_conflicting_paths_into_bookkeeping( { I(leftover_paths.size() > 0); - string now = date_t::now().as_iso_8601_extended(); - bookkeeping_path leftover_path = bookkeeping_root / "conflicts" / now.data(); + bookkeeping_path leftover_path = bookkeeping_root / "resolutions"; require_path_is_nonexistent(leftover_path, F("cannot move conflicting paths - " "base path %s already exists") % leftover_path); @@ -1877,13 +1879,13 @@ workspace::perform_content_update(roster simulated_working_tree swt(test_roster, nis); update.apply_to(swt); - // if we have found paths during the test-run which will conflict with newly - // attached or to-be-dropped nodes, move these paths out of the way into - // _MTN/leftover while keeping the path to these paths intact in case the - // user wants them back + // if we have found paths during the test-run which will conflict with + // newly attached or to-be-dropped nodes, move these paths out of the way + // into _MTN while keeping the path to these paths intact in case the user + // wants them back if (swt.has_conflicting_paths()) { - E(move_conflicting_paths, + E(move_conflicting_paths, origin::user, F("re-run this command with --move-conflicting-paths to move " "conflicting paths out of the way.")); move_conflicting_paths_into_bookkeeping(swt.get_conflicting_paths());