# # # add_dir "tests/two_parent_workspace_pivot_root" # # add_file "tests/two_parent_workspace_pivot_root/__driver__.lua" # content [4648648d122fa1ecdbfe277c214c002594767656] # # patch "ChangeLog" # from [e59002b36e85226cd0ad1f3fb0a011210d399b34] # to [f8a7477a5565d0a2ae1f442776fefbf57c84eac7] # # patch "testsuite.lua" # from [10d8ffa9ed36634db9af6840f03d950c321aa484] # to [f92a7dcff9079237855ae6c1f0c385a217b0873b] # # patch "work.cc" # from [a4d1f557c83a4a163641bc3519db36359538fb64] # to [20cc76bbc742cd22f37cf5043f55a46c2cef2f94] # ============================================================ --- tests/two_parent_workspace_pivot_root/__driver__.lua 4648648d122fa1ecdbfe277c214c002594767656 +++ tests/two_parent_workspace_pivot_root/__driver__.lua 4648648d122fa1ecdbfe277c214c002594767656 @@ -0,0 +1,39 @@ +mtn_setup() + +mkdir("w1") + +check(indir("w1", mtn("setup", ".", "-b", "testbranch")), 0, false, false) + +writefile("w1/testfile", "ancestor\nancestor") +mkdir("w1/newroot") +writefile("w1/newroot/fileinroot", + "ordinals are bluejays, cardinals are cardinals") + +check(indir("w1", mtn("add", "-R", ".")), 0, false, false) +check(indir("w1", mtn("commit", "--message", "blah-blah")), 0, false, false) +anc = indir("w1", {base_revision})[1]() + +check(mtn("co", "-r", anc, "w2"), 0, false, false) +writefile("w2/testfile", "left\nancestor") +check(indir("w2", mtn("commit", "--message", "blah-blah")), 0, false, false) +left = indir("w2", {base_revision})[1]() + +check(mtn("co", "-r", anc, "w3"), 0, false, false) +writefile("w3/testfile", "ancestor\nright") +check(indir("w3", mtn("commit", "--message", "blah-blah")), 0, false, false) +right = indir("w3", {base_revision})[1]() + +check(indir("w3", mtn("merge_into_workspace", left)), 0, false, false) +check(qgrep("left", "w3/testfile")) +check(qgrep("right", "w3/testfile")) +check(not qgrep("ancestor", "w3/testfile")) + +check(indir("w3", mtn("pivot_root", "-e", "newroot", "oldroot")), + 0, nil, false) + +check(exists("w3/fileinroot")) +check(not exists("w3/testfile")) +check(exists("w3/oldroot/testfile")) +check(not exists("w3/oldroot/fileinroot")) + +check(indir("w3", mtn("commit", "--message", "blah-blah")), 0, false, false) ============================================================ --- ChangeLog e59002b36e85226cd0ad1f3fb0a011210d399b34 +++ ChangeLog f8a7477a5565d0a2ae1f442776fefbf57c84eac7 @@ -1,9 +1,11 @@ 2007-02-07 Zack Weinberg * work.cc (perform_rename): Work in a two-parent workspace. + (perform_pivot_root): Likewise. * tests/two_parent_workspace_add_drop: Rename to... * tests/two_parent_workspace_add_drop_rename: ... this. Add testing of renames. + * tests/two_parent_workspace_pivot_root: New test. * testsuite.lua: Update. 2007-02-07 Matthew Gregan ============================================================ --- testsuite.lua 10d8ffa9ed36634db9af6840f03d950c321aa484 +++ testsuite.lua f92a7dcff9079237855ae6c1f0c385a217b0873b @@ -714,3 +714,4 @@ table.insert(tests, "two_parent_workspac table.insert(tests, "two_parent_workspace_pluck") table.insert(tests, "two_parent_workspace_add_drop_rename") table.insert(tests, "two_parent_workspace_attrs") +table.insert(tests, "two_parent_workspace_pivot_root") ============================================================ --- work.cc a4d1f557c83a4a163641bc3519db36359538fb64 +++ work.cc 20cc76bbc742cd22f37cf5043f55a46c2cef2f94 @@ -1546,10 +1546,9 @@ workspace::perform_pivot_root(file_path file_path().split(root_sp); temp_node_id_source nis; - roster_t base_roster, new_roster; - MM(base_roster); + roster_t new_roster; MM(new_roster); - get_base_and_current_roster_shape(base_roster, new_roster, nis); + get_current_roster_shape(new_roster, nis); I(new_roster.has_root()); N(new_roster.has_node(new_root_sp), @@ -1589,11 +1588,11 @@ workspace::perform_pivot_root(file_path } { - revision_id base_rev; - get_revision_id(base_rev); + parent_map parents; + get_parent_rosters(parents); revision_t new_work; - make_revision_for_workspace(base_rev, base_roster, new_roster, new_work); + make_revision_for_workspace(parents, new_roster, new_work); put_work_rev(new_work); } if (execute)