# # # add_dir "tests/add_ignored" # # add_file "tests/add_ignored/__driver__.lua" # content [2253a018711c3dc0493a1cce7de2b8415ed5169b] # # add_file "tests/scanning_trees/manifest1" # content [19d525e263ef8f32a20c99c7f05f56e77d1cdb50] # # patch ".mtn-ignore" # from [e890240edc9b6bc26a3e4add55ed66356d13850f] # to [53ba0a32a8d3d257787d12f2e37b8c1329c664b4] # # patch "ChangeLog" # from [fe8a8cb76e9eaf3b17ed4dc96d67ab1a080d4c31] # to [f31997a1a28f67d23fb8ccf7abd3b9cb5e4c83c5] # # patch "cmd_ws_commit.cc" # from [6923f95283b8f0db1827cb888c24abf5787b0f07] # to [16de914170610c524d8a8ff2e80ddb7b488c7195] # # patch "options_list.hh" # from [afb8e9f4dd372b5a8ec4c686a84aa1624f104268] # to [00e4d40b9a6c6b0ddee6487ca89cd2967ff41dd1] # # patch "platform-wrapped.hh" # from [b6bb6d24005a53ef83cbfda0ab48a3b4a3ffaa7e] # to [956a90c22fb8ccc59e5e436b4882564caf8721c8] # # patch "tests/(minor)_drop_in_subdir/__driver__.lua" # from [e8ecb4d8e91781f0b0fcb0d184767e646b52d2d6] # to [787ecbc541ca640b3389be3c9335a96047b8c30f] # # patch "tests/add_in_subdir/__driver__.lua" # from [06668cf5a3942f2b2ee679947589fb9680c647ef] # to [6707dd3554af3db376f9539e0b90a02071e47a63] # # patch "tests/addition_of_files_and_directories/__driver__.lua" # from [918c1b3bd41fa3f9c4e67e64255221431e2481db] # to [91100a9f3896ff4baa703586ebba94ff2654f115] # # patch "tests/attr_command_in_subdirs/__driver__.lua" # from [20f2a5abb30a48aedff68354181c60a51da2fc09] # to [c5ad82d1ea7a87406263518dcf4f51f452d04acd] # # patch "tests/files_with_intermediate__MTN_path_elements/__driver__.lua" # from [8740ff57f33dadbd67b2f008dc84ef0f0b774497] # to [fbf8d22c807fdd6b80b3ab12c3d84dcf6cb3ec52] # # patch "tests/merge_rename_file_and_rename_dir/__driver__.lua" # from [0fd8b1102d55c8b335f0a20eac5abd485a35fa0b] # to [58481ed4e470ac7efa3a5956c5bd14be8ce687d9] # # patch "tests/mtn_add_dot/__driver__.lua" # from [2f0a63f81197480e78b298ad1bf74496afd2924c] # to [6858c894d4638b4b9c4dca9ed5e701a8a799918f] # # patch "tests/pivot_root/__driver__.lua" # from [6db1fd6434d76a4df4a2ecca9b739f0439616b7b] # to [c16c49bd7cca6d5b343151c9d87007431c4237ee] # # patch "tests/rename_in_subdir/__driver__.lua" # from [d9d851ec083f3270f258c477ee7eaef3c0e9530a] # to [45714670530104d697fc2ab8caf3f1f939ed6886] # # patch "tests/renaming_a_directory/__driver__.lua" # from [a33e62f4ff8c746c7a51fbaa19302ea76075c805] # to [f8d5fecc9166f44d54d382d249bd8157021b64c9] # # patch "tests/restricted_commands_are_consistent/__driver__.lua" # from [c8470461bc884c455d17aa91aa7adea564977ef7] # to [2859490ab866d2bcb418b6738123b58cf87dc760] # # patch "tests/revert_in_subdirs/__driver__.lua" # from [be726716d4ab49c14ce77b1d03abbcbe3e4ef76d] # to [dae577b10bdfc144b73620c7144f316f11480725] # # patch "tests/reverting_a_pivot_root/__driver__.lua" # from [d11e7f97a7d980f9443cd77a32ead852f4237ffb] # to [b2e210fb6d037e9acf9f46b92feb4c193db12c86] # # patch "tests/scanning_trees/__driver__.lua" # from [fffe11ecf6f43983efe1e29174a79ee028e31771] # to [3dcee6dd1957191d75ff729ceb5e09b157e50697] # # patch "tests/subdirectory_restrictions/__driver__.lua" # from [353202bac216de08ce38f9a86a6038d7f1277e99] # to [1e4ce8ba438a4d1fd2e5725bb77d51bd44b5f28f] # # patch "tests/updating_through_a_pivot_root/__driver__.lua" # from [2555334a28851c69f93f7b319bc4dde71ed44903] # to [0d9d824956af2a0247748a9f812dfaf09b84c775] # # patch "testsuite.lua" # from [beb872483893122e6550af48b3468bc4b1a6b455] # to [de8ad6d25786dfaccf5dcc363fea2b961569ebb2] # # patch "work.cc" # from [c6c7f67690fe5d7d7d5ae2bb8ff0e89ecae51341] # to [95c5685d05ca64884882a7653f75a0bbff65f587] # # patch "work.hh" # from [05eb8cafa4b73af5d107c495ef54398b410aa994] # to [f75890d7970c1c6f41d9956f19d0b22d8882d2e1] # ============================================================ --- tests/add_ignored/__driver__.lua 2253a018711c3dc0493a1cce7de2b8415ed5169b +++ tests/add_ignored/__driver__.lua 2253a018711c3dc0493a1cce7de2b8415ed5169b @@ -0,0 +1,9 @@ + +mtn_setup() + +check(mtn("add", "test_hooks.lua"), 0, false, false) +check(mtn("ls", "known"), 0, true, false) +check(not qgrep("test_hooks.lua", "stdout")) +check(mtn("add", "--no-respect-ignore", "test_hooks.lua"), 0, false, false) +check(mtn("ls", "known"), 0, true, false) +check(qgrep("test_hooks.lua", "stdout")) ============================================================ --- tests/scanning_trees/manifest1 19d525e263ef8f32a20c99c7f05f56e77d1cdb50 +++ tests/scanning_trees/manifest1 19d525e263ef8f32a20c99c7f05f56e77d1cdb50 @@ -0,0 +1,8 @@ +format_version "1" + +dir "" + +dir "foo" + + file "testfile0" +content [5c39de9ca49b3aa34fa21f5778954665d947476c] ============================================================ --- .mtn-ignore e890240edc9b6bc26a3e4add55ed66356d13850f +++ .mtn-ignore 53ba0a32a8d3d257787d12f2e37b8c1329c664b4 @@ -1,5 +1,7 @@ tester_dir testsuite\.dir tester_dir +^build$ +^build/ \.dirstamp ^txt2c$ ^unit_tests$ ============================================================ --- ChangeLog fe8a8cb76e9eaf3b17ed4dc96d67ab1a080d4c31 +++ ChangeLog f31997a1a28f67d23fb8ccf7abd3b9cb5e4c83c5 @@ -1,5 +1,10 @@ 2006-11-02 Timothy Brownawell + Make add non-recursive by default, and also give it a + --no-respect-ignore switch. + +2006-11-02 Timothy Brownawell + Allow commands with subcommands (such as automate) to take different options depending on which subcommand was called. Make AUTOMATE() specify what options are taken. Test (and ============================================================ --- cmd_ws_commit.cc 6923f95283b8f0db1827cb888c24abf5787b0f07 +++ cmd_ws_commit.cc 16de914170610c524d8a8ff2e80ddb7b488c7195 @@ -250,10 +250,16 @@ CMD(add, N_("workspace"), N_("[PATH]..." CMD(add, N_("workspace"), N_("[PATH]..."), - N_("add files to workspace"), options::opts::unknown) + N_("add files to workspace"), + options::opts::unknown | options::opts::no_ignore | + options::opts::recursive) { if (!app.opts.unknown && (args.size() < 1)) throw usage(name); + N(!app.opts.unknown || !app.opts.recursive, + F("cannot set unknown and recursive at the same time")); + N(!app.opts.unknown || !app.opts.no_ignore, + F("cannot set unknown and no-ignore at the same time")); app.require_workspace(); @@ -261,7 +267,8 @@ CMD(add, N_("workspace"), N_("[PATH]..." if (app.opts.unknown) { vector roots = args_to_paths(args); - path_restriction mask(roots, args_to_paths(app.opts.exclude_patterns), app.opts.depth, app); + path_restriction mask(roots, args_to_paths(app.opts.exclude_patterns), + app.opts.depth, app); path_set ignored; // if no starting paths have been specified use the workspace root @@ -279,8 +286,8 @@ CMD(add, N_("workspace"), N_("[PATH]..." paths.insert(sp); } - bool add_recursive = !app.opts.unknown; - app.work.perform_additions(paths, add_recursive); + bool add_recursive = app.opts.recursive; + app.work.perform_additions(paths, add_recursive, !app.opts.no_ignore); } CMD(drop, N_("workspace"), N_("[PATH]..."), ============================================================ --- options_list.hh afb8e9f4dd372b5a8ec4c686a84aa1624f104268 +++ options_list.hh 00e4d40b9a6c6b0ddee6487ca89cd2967ff41dd1 @@ -361,6 +361,14 @@ OPT(no_files, "no-files", bool, false, } #endif +OPT(no_ignore, "no-respect-ignore", bool, false, + gettext_noop("do not ignore any files")) +#ifdef option_bodies +{ + no_ignore = true; +} +#endif + OPT(no_merges, "no-merges", bool, false, gettext_noop("exclude merges when printing logs")) #ifdef option_bodies ============================================================ --- platform-wrapped.hh b6bb6d24005a53ef83cbfda0ab48a3b4a3ffaa7e +++ platform-wrapped.hh 956a90c22fb8ccc59e5e436b4882564caf8721c8 @@ -17,7 +17,8 @@ inline path::status get_path_status(any_ inline path::status get_path_status(any_path const & path) { - return get_path_status(path.as_external()); + std::string p(path.as_external()); + return get_path_status(p.empty()?".":p); } inline void rename_clobberingly(any_path const & from, any_path const & to) ============================================================ --- tests/(minor)_drop_in_subdir/__driver__.lua e8ecb4d8e91781f0b0fcb0d184767e646b52d2d6 +++ tests/(minor)_drop_in_subdir/__driver__.lua 787ecbc541ca640b3389be3c9335a96047b8c30f @@ -5,7 +5,7 @@ writefile("subdir/anotherdir/bar", "more mkdir("subdir/anotherdir") writefile("subdir/foo", "data data") writefile("subdir/anotherdir/bar", "more data") -check(mtn("add", "."), 0, false, false) +check(mtn("add", "-R", "."), 0, false, false) commit() rev = base_revision() ============================================================ --- tests/add_in_subdir/__driver__.lua 06668cf5a3942f2b2ee679947589fb9680c647ef +++ tests/add_in_subdir/__driver__.lua 6707dd3554af3db376f9539e0b90a02071e47a63 @@ -10,7 +10,7 @@ check(mtn("add", "foo"), 0, false, false chdir("subdir") check(mtn("add", "foo"), 0, false, false) -- Add a directory -check(mtn("add", "anotherdir"), 0, false, false) +check(mtn("add", "-R", "anotherdir"), 0, false, false) chdir("..") commit() ============================================================ --- tests/addition_of_files_and_directories/__driver__.lua 918c1b3bd41fa3f9c4e67e64255221431e2481db +++ tests/addition_of_files_and_directories/__driver__.lua 91100a9f3896ff4baa703586ebba94ff2654f115 @@ -16,6 +16,10 @@ check(mtn("add", "dir"), 0, false, true) check(qgrep("adding file0", "stderr")) check(mtn("add", "dir"), 0, false, true) +check(not qgrep("adding dir/file1", "stderr")) +check(not qgrep("adding dir/file2", "stderr")) + +check(mtn("add", "-R", "dir"), 0, false, true) check(qgrep("adding dir/file1", "stderr")) check(qgrep("adding dir/file2", "stderr")) @@ -32,7 +36,7 @@ check(qgrep("skipping file0", "stderr")) check(mtn("add", "file0"), 0, false, true) check(qgrep("skipping file0", "stderr")) -check(mtn("add", "dir"), 0, false, true) +check(mtn("add", "-R", "dir"), 0, false, true) check(qgrep("skipping dir/file1", "stderr")) check(qgrep("skipping dir/file2", "stderr")) ============================================================ --- tests/attr_command_in_subdirs/__driver__.lua 20f2a5abb30a48aedff68354181c60a51da2fc09 +++ tests/attr_command_in_subdirs/__driver__.lua c5ad82d1ea7a87406263518dcf4f51f452d04acd @@ -7,7 +7,7 @@ writefile("foo/bar/bardata", "foobar dat writefile("foo/foodata", "foo data") writefile("foo/bar/bardata", "foobar data") -check(mtn("add", "top", "foo"), 0, false, false) +check(mtn("add", "-R", "top", "foo"), 0, false, false) -- set attributes in directories ============================================================ --- tests/files_with_intermediate__MTN_path_elements/__driver__.lua 8740ff57f33dadbd67b2f008dc84ef0f0b774497 +++ tests/files_with_intermediate__MTN_path_elements/__driver__.lua fbf8d22c807fdd6b80b3ab12c3d84dcf6cb3ec52 @@ -9,8 +9,8 @@ writefile("dir2/_MTN", "_MTN file 1") -- Check both implicit recursive add... writefile("dir1/_MTN/testfile1", "testfile 1") writefile("dir2/_MTN", "_MTN file 1") -check(mtn("add", "dir1"), 0, false, false) -check(mtn("add", "dir2"), 0, false, false) +check(mtn("add", "-R", "dir1"), 0, false, false) +check(mtn("add", "-R", "dir2"), 0, false, false) commit() -- ...and explicit add. ============================================================ --- tests/merge_rename_file_and_rename_dir/__driver__.lua 0fd8b1102d55c8b335f0a20eac5abd485a35fa0b +++ tests/merge_rename_file_and_rename_dir/__driver__.lua 58481ed4e470ac7efa3a5956c5bd14be8ce687d9 @@ -6,7 +6,7 @@ writefile("foo/bar", "foo bar file") -- common ancestor -check(mtn("add", "foo"), 0, false, false) +check(mtn("add", "foo/bar"), 0, false, false) commit() base = base_revision() ============================================================ --- tests/mtn_add_dot/__driver__.lua 2f0a63f81197480e78b298ad1bf74496afd2924c +++ tests/mtn_add_dot/__driver__.lua 6858c894d4638b4b9c4dca9ed5e701a8a799918f @@ -13,7 +13,10 @@ chdir("subdir") -- Make sure that "add ." works, even at the root of the tree chdir("subdir") +-- Recursive and non-recursive may process things differently, check +-- that both return success check(mtn("add", "."), 0, false, false) +check(mtn("add", "-R", "."), 0, false, false) -- Make sure that it took check(mtn("commit", "--message=foo"), 0, false, false) ============================================================ --- tests/pivot_root/__driver__.lua 6db1fd6434d76a4df4a2ecca9b739f0439616b7b +++ tests/pivot_root/__driver__.lua c16c49bd7cca6d5b343151c9d87007431c4237ee @@ -19,7 +19,7 @@ mkdir("workspace/dir3/_MTN") writefile("workspace/dir1/file1", "blah blah") mkdir("workspace/dir3") mkdir("workspace/dir3/_MTN") -check(indir("workspace", mtn("add", ".")), 0, false, false) +check(indir("workspace", mtn("add", "-R", ".")), 0, false, false) check(indir("workspace", mtn("commit", "-m", "foo")), 0, false, false) ============================================================ --- tests/rename_in_subdir/__driver__.lua d9d851ec083f3270f258c477ee7eaef3c0e9530a +++ tests/rename_in_subdir/__driver__.lua 45714670530104d697fc2ab8caf3f1f939ed6886 @@ -5,7 +5,7 @@ writefile("subdir/anotherdir/bar", "more mkdir("subdir/anotherdir") writefile("subdir/foo", "data data") writefile("subdir/anotherdir/bar", "more data") -check(mtn("add", "."), 0, false, false) +check(mtn("add", "-R", "."), 0, false, false) commit() rev = base_revision() ============================================================ --- tests/renaming_a_directory/__driver__.lua a33e62f4ff8c746c7a51fbaa19302ea76075c805 +++ tests/renaming_a_directory/__driver__.lua f8d5fecc9166f44d54d382d249bd8157021b64c9 @@ -7,7 +7,7 @@ writefile("bleh", "bleh file") writefile("bleh", "bleh file") -- produce root -check(mtn("add", "foo"), 0, false, false) +check(mtn("add", "-R", "foo"), 0, false, false) commit() root_r_sha = base_revision() root_f_sha = sha1("foo/foo") ============================================================ --- tests/restricted_commands_are_consistent/__driver__.lua c8470461bc884c455d17aa91aa7adea564977ef7 +++ tests/restricted_commands_are_consistent/__driver__.lua 2859490ab866d2bcb418b6738123b58cf87dc760 @@ -89,7 +89,7 @@ patch_files("initial addition of files") mkdir("foo") mkdir("foo/bar") patch_files("initial addition of files") -check(mtn("add", "file1", "file2", "foo"), 0, false, false) +check(mtn("add", "-R", "file1", "file2", "foo"), 0, false, false) commit() -- check that ls unknown/ignored/missing/known, status, diff, revert and commit ============================================================ --- tests/revert_in_subdirs/__driver__.lua be726716d4ab49c14ce77b1d03abbcbe3e4ef76d +++ tests/revert_in_subdirs/__driver__.lua dae577b10bdfc144b73620c7144f316f11480725 @@ -5,7 +5,7 @@ writefile("subdir/anotherdir/bar", "more mkdir("subdir/anotherdir") writefile("subdir/foo", "data data") writefile("subdir/anotherdir/bar", "more data") -check(mtn("add", "."), 0, false, false) +check(mtn("add", "-R", "."), 0, false, false) commit() rev = base_revision() ============================================================ --- tests/reverting_a_pivot_root/__driver__.lua d11e7f97a7d980f9443cd77a32ead852f4237ffb +++ tests/reverting_a_pivot_root/__driver__.lua b2e210fb6d037e9acf9f46b92feb4c193db12c86 @@ -13,7 +13,7 @@ mkdir("workspace/dir3/_MTN") writefile("workspace/dir1/file1", "blah blah") mkdir("workspace/dir3") mkdir("workspace/dir3/_MTN") -check(indir("workspace", mtn("add", ".")), 0, false, false) +check(indir("workspace", mtn("add", "-R", ".")), 0, false, false) check(indir("workspace", mtn("commit", "-m", "foo")), 0, false, false) ============================================================ --- tests/scanning_trees/__driver__.lua fffe11ecf6f43983efe1e29174a79ee028e31771 +++ tests/scanning_trees/__driver__.lua 3dcee6dd1957191d75ff729ceb5e09b157e50697 @@ -11,6 +11,8 @@ commit() check(mtn("add", "testfile0", "foo"), 0, false, false) commit() +check(mtn("add", "-R", "foo"), 0, false, false) +commit() check(mtn("automate", "get_manifest_of"), 0, true) canonicalize("stdout") check(samefile("stdout", "manifest")) ============================================================ --- tests/subdirectory_restrictions/__driver__.lua 353202bac216de08ce38f9a86a6038d7f1277e99 +++ tests/subdirectory_restrictions/__driver__.lua 1e4ce8ba438a4d1fd2e5725bb77d51bd44b5f28f @@ -7,8 +7,8 @@ writefile("bar/bar.txt", "file bar.txt i writefile("foo/foo.txt", "file foo.txt in dir foo") writefile("bar/bar.txt", "file bar.txt in dir bar") -check(mtn("add", "foo"), 0, false, false) -check(mtn("add", "bar"), 0, false, false) +check(mtn("add", "-R", "foo"), 0, false, false) +check(mtn("add", "-R", "bar"), 0, false, false) commit() ============================================================ --- tests/updating_through_a_pivot_root/__driver__.lua 2555334a28851c69f93f7b319bc4dde71ed44903 +++ tests/updating_through_a_pivot_root/__driver__.lua 0d9d824956af2a0247748a9f812dfaf09b84c775 @@ -7,7 +7,7 @@ writefile("workspace/dir1/new_root_file" mkdir("workspace/dir1") writefile("workspace/old_root_file", "I'm in the root to start off with!") writefile("workspace/dir1/new_root_file", "I'm in the subdir to start off with.") -check(indir("workspace", mtn("add", ".")), 0, false, false) +check(indir("workspace", mtn("add", "-R", ".")), 0, false, false) check(indir("workspace", mtn("commit", "-m", "foo")), 0, false, false) base = indir("workspace", {base_revision})[1]() ============================================================ --- testsuite.lua beb872483893122e6550af48b3468bc4b1a6b455 +++ testsuite.lua de8ad6d25786dfaccf5dcc363fea2b961569ebb2 @@ -685,3 +685,4 @@ table.insert(tests, "disapproving_with_m table.insert(tests, "multiple_message_commit") table.insert(tests, "netsync_epoch_refinement") table.insert(tests, "disapproving_with_message") +table.insert(tests, "add_ignored") ============================================================ --- work.cc c6c7f67690fe5d7d7d5ae2bb8ff0e89ecae51341 +++ work.cc 95c5685d05ca64884882a7653f75a0bbff65f587 @@ -479,10 +479,12 @@ addition_builder lua_hooks & lua; roster_t & ros; editable_roster_base & er; + bool respect_ignore; public: addition_builder(database & db, lua_hooks & lua, - roster_t & r, editable_roster_base & e) - : db(db), lua(lua), ros(r), er(e) + roster_t & r, editable_roster_base & e, + bool i = true) + : db(db), lua(lua), ros(r), er(e), respect_ignore(i) {} virtual void visit_dir(file_path const & path); virtual void visit_file(file_path const & path); @@ -534,7 +536,7 @@ addition_builder::visit_file(file_path c void addition_builder::visit_file(file_path const & path) { - if (lua.hook_ignore_file(path) || db.is_dbfile(path)) + if ((respect_ignore && lua.hook_ignore_file(path)) || db.is_dbfile(path)) { P(F("skipping ignorable file %s") % path); return; @@ -736,8 +738,11 @@ editable_working_tree::attach_node(node_ // middle of an update to avoid clobbering a file, we just end up leaving // the working copy in an inconsistent state instead. so for now, we leave // this check down here. - require_path_is_nonexistent(dst_pth, - F("path '%s' already exists, cannot create") % dst_pth); + if (!workspace_root(dst)) + { + require_path_is_nonexistent(dst_pth, + F("path '%s' already exists, cannot create") % dst_pth); + } // If we get here, we're doing a file/dir rename, or a dir-create. map::const_iterator i @@ -1032,7 +1037,8 @@ void } void -workspace::perform_additions(path_set const & paths, bool recursive) +workspace::perform_additions(path_set const & paths, + bool recursive, bool respect_ignore) { if (paths.empty()) return; @@ -1053,7 +1059,7 @@ workspace::perform_additions(path_set co } I(new_roster.has_root()); - addition_builder build(db, lua, new_roster, er); + addition_builder build(db, lua, new_roster, er, respect_ignore); for (path_set::const_iterator i = paths.begin(); i != paths.end(); ++i) { @@ -1066,7 +1072,19 @@ workspace::perform_additions(path_set co { // in the case where we're just handled a set of paths, we use the builder // in this strange way. - build.visit_file(file_path(*i)); + file_path path(*i); + switch (get_path_status(path)) + { + case path::nonexistent: + N(false, F("no such file or directory: '%s'") % path); + break; + case path::file: + build.visit_file(path); + break; + case path::directory: + build.visit_dir(path); + break; + } } } ============================================================ --- work.hh 05eb8cafa4b73af5d107c495ef54398b410aa994 +++ work.hh f75890d7970c1c6f41d9956f19d0b22d8882d2e1 @@ -77,7 +77,9 @@ struct workspace std::vector const & roots, path_set & unknown, path_set & ignored); - void perform_additions(path_set const & targets, bool recursive = true); + void perform_additions(path_set const & targets, + bool recursive = false, + bool respect_ignore = true); void perform_deletions(path_set const & targets, bool recursive, bool execute);