# # # add_dir "tests/pluck_restricted" # # add_file "tests/pluck_restricted/__driver__.lua" # content [ba192bc4981a40610ac4914a7eea58527bed66d9] # # patch "ChangeLog" # from [0cffe0da4b27cfcf1e6edc26647609fedc1f055b] # to [616c245fe5ff551f6d76b33eee8cc82b752518ba] # # patch "cmd_merging.cc" # from [1ddeea2f8c738677ecb9a3e256e215b1822416be] # to [aac57b6436dec206d4c167d0ecae2d24a6a1fb50] # # patch "testsuite.lua" # from [b73b21df2b53fe0f868d462de1e8ead6672b9561] # to [43bf94ebb89497ee35438d70e56316e0b0867685] # ============================================================ --- tests/pluck_restricted/__driver__.lua ba192bc4981a40610ac4914a7eea58527bed66d9 +++ tests/pluck_restricted/__driver__.lua ba192bc4981a40610ac4914a7eea58527bed66d9 @@ -0,0 +1,34 @@ +mtn_setup() + +function C(str) + return (string.gsub(str, "(.)", "%1\n")) +end + +addfile("testfile", C("abc")) +addfile("otherfile", C("123")) +commit() +root_rev = base_revision() + +writefile("testfile", C("1bc")) +writefile("otherfile", C("a23")) +commit() +first_rev = base_revision() + +writefile("testfile", C("1b3")) +writefile("otherfile", C("a2c")) +commit() +second_rev = base_revision() + +revert_to(root_rev) +check(readfile("testfile") == C("abc")) +check(readfile("otherfile") == C("123")) +check(mtn("pluck", "-r", second_rev, "testfile"), 0, false, false) +check(readfile("testfile") == C("ab3")) +check(readfile("otherfile") == C("123")) + +revert_to(root_rev) +check(readfile("testfile") == C("abc")) +check(readfile("otherfile") == C("123")) +check(mtn("pluck", "-r", second_rev, "--exclude", "testfile"), 0, false, false) +check(readfile("testfile") == C("abc")) +check(readfile("otherfile") == C("12c")) ============================================================ --- ChangeLog 0cffe0da4b27cfcf1e6edc26647609fedc1f055b +++ ChangeLog 616c245fe5ff551f6d76b33eee8cc82b752518ba @@ -1,5 +1,10 @@ 2006-07-09 Nathaniel Smith + * cmd_merging.cc (pluck): Restrictions support. + * tests/pluck_restricted/__driver__.lua: New test. + +2006-07-09 Nathaniel Smith + * roster.cc (check_sane_against): Take a temp_nodes_ok arg. (mark_roster_with_one_parent): Pass it. ============================================================ --- cmd_merging.cc 1ddeea2f8c738677ecb9a3e256e215b1822416be +++ cmd_merging.cc aac57b6436dec206d4c167d0ecae2d24a6a1fb50 @@ -608,7 +608,7 @@ % result.directory_loop_conflicts.size()); } -CMD(pluck, N_("workspace"), N_("[-r FROM] -r TO"), +CMD(pluck, N_("workspace"), N_("[-r FROM] -r TO [PATH...]"), N_("Apply changes made at arbitrary places in history to current workspace.\n" "This command takes changes made at any point in history, and\n" "edits your current workspace to include those changes. The end result\n" @@ -621,11 +621,8 @@ "\n" "If two revisions are given, applies the changes made to get from the\n" "first revision to the second."), - OPT_REVISION) + OPT_REVISION % OPT_DEPTH % OPT_EXCLUDE) { - if (args.size() > 0) - throw usage(name); - // Work out our arguments revision_id from_rid, to_rid; @@ -689,7 +686,7 @@ // The node id source we'll use for the 'working' and 'to' rosters. temp_node_id_source nis; - // Get the FROM roster and markings + // Get the FROM roster shared_ptr from_roster = shared_ptr(new roster_t()); MM(*from_roster); app.db.get_roster(from_rid, *from_roster); @@ -703,10 +700,15 @@ // Get the FROM->TO cset cset from_to_to; MM(from_to_to); + cset from_to_to_excluded; MM(from_to_to_excluded); { roster_t to_true_roster; app.db.get_roster(to_rid, to_true_roster); - make_cset(*from_roster, to_true_roster, from_to_to); + node_restriction mask(args, app.exclude_patterns, + *from_roster, to_true_roster, app); + make_restricted_csets(*from_roster, to_true_roster, + from_to_to, from_to_to_excluded, + mask); } // Use a fake rid @@ -777,9 +779,14 @@ std::string log_str = log(); if (!log_str.empty()) log_str += "\n"; - log_str += (FL("applied changes from %s\n" - " through %s\n") - % from_rid % to_rid).str(); + if (from_to_to_excluded.empty()) + log_str += (FL("applied changes from %s\n" + " through %s\n") + % from_rid % to_rid).str(); + else + log_str += (FL("applied partial changes from %s\n" + " through %s\n") + % from_rid % to_rid).str(); write_user_log(data(log_str)); } } ============================================================ --- testsuite.lua b73b21df2b53fe0f868d462de1e8ead6672b9561 +++ testsuite.lua 43bf94ebb89497ee35438d70e56316e0b0867685 @@ -647,3 +647,4 @@ table.insert(tests, "pluck_basics") table.insert(tests, "diff_output_formats") table.insert(tests, "pluck_lifecycle") +table.insert(tests, "pluck_restricted")