# # # add_dir "tests/two_parent_workspace_list" # # add_file "tests/two_parent_workspace_list/__driver__.lua" # content [d4da0e9696dc1a16eeaab81f20da7cee9fae3a46] # # patch "ChangeLog" # from [c32062e828dd79e18a65d1a37dfadaae944ce996] # to [f56bc8da0290bce97607b0b319b87ea2e3a53976] # # patch "cmd_list.cc" # from [c60282e394cfd3e7d362663fb7dc29bcf2a80da5] # to [f7c5a9b2e25b2844298957bed0e3fe8cdaf2618f] # # patch "testsuite.lua" # from [6ba9c5da69a1e547e724616fecebdc09cf2cba72] # to [91eac711680d9b88fc710bc0cfde4653597ebafe] # ============================================================ --- tests/two_parent_workspace_list/__driver__.lua d4da0e9696dc1a16eeaab81f20da7cee9fae3a46 +++ tests/two_parent_workspace_list/__driver__.lua d4da0e9696dc1a16eeaab81f20da7cee9fae3a46 @@ -0,0 +1,43 @@ +mtn_setup() + +addfile("file1", "ancestor\nancestor") +addfile("file2", "quack quack") +addfile("file3", "t-rex says today is a beautiful day ".. + "to be stomping on things") +addfile("file4", "don't you see, we're actually all muppets!") +commit() +anc = base_revision() + +writefile("file1", "left\nancestor") +writefile("file2", "brawwk brawwk") +commit() +left = base_revision() + +revert_to(anc) +writefile("file1", "ancestor\nright") +writefile("file3", "utahraptor asks, is stomping really ".. + "the answer to your problem(s)?") +commit() +right = base_revision() + +check(mtn("merge_into_workspace", left), 0, false, false) + +check(mtn("ls", "changed"), 0, "file1\nfile2\nfile3\n", nil) +check(mtn("ls", "known"), 0, "file1\nfile2\nfile3\nfile4\n", nil) + +-- these rely on the precise set of junk files that the test suite +-- dumps into the current directory, and on the fact that it doesn't +-- ignore them all. if the test suite is ever fixed to use a +-- subdirectory for the workspace (and therefore to keep it cleaner) +-- or to ignore them all properly, this will have to change. +check(mtn("ls", "ignored"), 0, "keys\ntest.db\ntest_hooks.lua\nts-stderr\nts-stdin\nts-stdout\n", nil) +check(mtn("ls", "unknown"), 0, "_MTN.old\nmin_hooks.lua\ntester.log\n", nil) + +-- we do this after the other tests so it doesn't interfere with them. +remove("file4") +check(mtn("ls", "missing"), 0, "file4\n", nil) + +-- this is drop because revert doesn't work in a 2-parent workspace yet, +-- and all that matters is we get commit to be happy +check(mtn("drop", "--missing"), 0, false, false) +commit() ============================================================ --- ChangeLog c32062e828dd79e18a65d1a37dfadaae944ce996 +++ ChangeLog f56bc8da0290bce97607b0b319b87ea2e3a53976 @@ -1,5 +1,9 @@ 2007-02-09 Zack Weinberg + * cmd_list.cc (ls_known, ls_changed): Work in a two-parent workspace. + * tests/two_parent_workspace_list: New test. + * testsuite.lua: Add it. + * automate.cc (attributes): Fail gracefully in a two-parent workspace. * tests/two_parent_workspace_commands_that_fail: Add test for automate attributes. ============================================================ --- cmd_list.cc c60282e394cfd3e7d362663fb7dc29bcf2a80da5 +++ cmd_list.cc f7c5a9b2e25b2844298957bed0e3fe8cdaf2618f @@ -333,11 +333,11 @@ ls_known(app_state & app, vector c static void ls_known(app_state & app, vector const & args) { - roster_t old_roster, new_roster; + roster_t new_roster; temp_node_id_source nis; app.require_workspace(); - app.work.get_base_and_current_roster_shape(old_roster, new_roster, nis); + app.work.get_current_roster_shape(new_roster, nis); node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), @@ -422,44 +422,51 @@ ls_changed(app_state & app, vector static void ls_changed(app_state & app, vector const & args) { - roster_t old_roster, new_roster; - cset included, excluded; - set files; + parent_map parents; + roster_t new_roster; temp_node_id_source nis; app.require_workspace(); - app.work.get_base_and_current_roster_shape(old_roster, new_roster, nis); + app.work.get_current_roster_shape(new_roster, nis); + app.work.update_current_roster_from_filesystem(new_roster); + app.work.get_parent_rosters(parents); + node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, - old_roster, new_roster, app); + parents, new_roster, app); - app.work.update_current_roster_from_filesystem(new_roster, mask); - make_restricted_csets(old_roster, new_roster, - included, excluded, mask); - check_restricted_cset(old_roster, included); + revision_t rrev; + cset dummy; + make_restricted_revision(parents, new_roster, mask, rrev, dummy); - set nodes; - select_nodes_modified_by_cset(included, old_roster, new_roster, nodes); + // to be printed sorted, with duplicates removed + set print_paths; - // to be printed sorted - vector print_paths; + for (edge_map::const_iterator i = rrev.edges.begin(); + i != rrev.edges.end(); i++) + { + set nodes; + roster_t const & old_roster + = *safe_get(parents, edge_old_revision(i)).first; + select_nodes_modified_by_cset(edge_changes(i), + old_roster, new_roster, nodes); - for (set::const_iterator i = nodes.begin(); i != nodes.end(); - ++i) - { - split_path sp; - if (old_roster.has_node(*i)) - old_roster.get_name(*i, sp); - else - new_roster.get_name(*i, sp); - print_paths.push_back(sp); + for (set::const_iterator i = nodes.begin(); i != nodes.end(); + ++i) + { + split_path sp; + if (old_roster.has_node(*i)) + old_roster.get_name(*i, sp); + else + new_roster.get_name(*i, sp); + print_paths.insert(sp); + } } - sort(print_paths.begin(), print_paths.end()); - for (vector::const_iterator sp = print_paths.begin(); + for (set::const_iterator sp = print_paths.begin(); sp != print_paths.end(); sp++) { cout << *sp << endl; ============================================================ --- testsuite.lua 6ba9c5da69a1e547e724616fecebdc09cf2cba72 +++ testsuite.lua 91eac711680d9b88fc710bc0cfde4653597ebafe @@ -716,3 +716,4 @@ table.insert(tests, "two_parent_workspac table.insert(tests, "two_parent_workspace_attrs") table.insert(tests, "two_parent_workspace_pivot_root") table.insert(tests, "two_parent_workspace_annotate") +table.insert(tests, "two_parent_workspace_list")