# # # delete "tests/automate_inventory/inventory_hooks.lua" # # delete "tests/manifest_restrictions/ignored.lua" # # delete "tests/mkdir/ignore_hook.lua" # # delete "tests/restricted_commands_are_consistent/ignore.lua" # # delete "tests/revert_ignored_files/ignore.lua" # # delete "tests/revert_works_with_restrictions/ignore_hook.lua" # # delete "tests/syntax_errors_in_.mtn-ignore/ignore.lua" # # rename "tests/spawn_redirected_hook_helper/testhooks" # to "tests/spawn_redirected_hook_helper/testhooks.lua" # # rename "tests/test_some_hook_helper_functions/testhooks" # to "tests/test_some_hook_helper_functions/testhooks.lua" # # patch "ChangeLog" # from [2a759016cabfd22e924c7d2d7ccad848da766a0a] # to [ff5e3f7396057cf55685e78c8f0479391f5b76a9] # # patch "annotate.cc" # from [dc5051843ce6406acbf2fadf151e9e9d52a36946] # to [7e5a4a4c768197dd53f236810b1a661a4a557125] # # patch "cmd_ws_commit.cc" # from [7dc23e7fa867951dbc82b5bd2da8a3560f2e4fc6] # to [369879d22a0c948672ec69143a441e56c6e70733] # # patch "lua_hooks.cc" # from [2ba09f87d8dc16a1957cad5abc98565a7c87cc7c] # to [9f6086677ce5eaf8a00d7213af7ff7fad2c6febf] # # patch "lua_hooks.hh" # from [7442504bf6a1fff7e6afe120d6883198f5303842] # to [4c4cf2633131c9de5b5ee26a7a12bee0e2dd6014] # # patch "pcrewrap.cc" # from [dd081644cde0233e19d86e37323b14ff6daf4594] # to [a924e9ddb82895ed65efc23daeced38fd3eba67d] # # patch "pcrewrap.hh" # from [5b3070b3642cc669273a7347bf6feb938f465215] # to [244cc638f7a9676d3981974a70bb274f3be06e84] # # patch "restrictions.cc" # from [474dbc86c29a1f8ce0abb1f27ebde4849c2042dc] # to [dc91cbcec3bb7d6a70f084b675cb78ca19c89c92] # # patch "restrictions.hh" # from [5b16498cc58ffea38a6e98f4b32efda724dc7ef3] # to [a92fb8592600abc74bf22c96fbae73268511737e] # # patch "std_hooks.lua" # from [8174984c17963cd5aa57748cb3abd90a1be7b8ce] # to [2cce6d4e4574dd3225364bbb734a8839df87bcac] # # patch "tests/addition_of_files_and_directories/__driver__.lua" # from [91100a9f3896ff4baa703586ebba94ff2654f115] # to [c2b0ac39219d138ccf22fb0d6f69e3e84bedc19d] # # patch "tests/automate_inventory/__driver__.lua" # from [21d9c672d0dc7c25066da114ac100a25060e6838] # to [06b203ca291c9ee93f28cdbf13a775cdf66635cb] # # patch "tests/manifest_restrictions/__driver__.lua" # from [0eea8a13102d0725bfb212125b29c6e33c945119] # to [9a54979b3b7cb6f1aaab4ba4a9923c0ae66fb9c8] # # patch "tests/mkdir/__driver__.lua" # from [33e48a4f90a4fc32c8031389366479e634619fe1] # to [d8ac9fa990499b9a7e1692cf3ea85aa55fde6a93] # # patch "tests/mtn_add_dot/__driver__.lua" # from [6858c894d4638b4b9c4dca9ed5e701a8a799918f] # to [11d25f15c1174862121c8cc4bba914e0c80ec817] # # patch "tests/restricted_commands_are_consistent/__driver__.lua" # from [2859490ab866d2bcb418b6738123b58cf87dc760] # to [f8d3c49b5417f5d078aac5225e690d9c69cd9d73] # # patch "tests/revert_ignored_files/__driver__.lua" # from [d853be95ada1e10faef3b5e56873054b108fd24d] # to [35e9149005ae38d0bf2a4d9d946e8aeb4b3aafb6] # # patch "tests/revert_works_with_restrictions/__driver__.lua" # from [0c1cd59c222d501aa739fb0a2caa4d450bba0a2b] # to [66ebe57ad06990aa60bed705f6146c5988a72726] # # patch "tests/spawn_redirected_hook_helper/__driver__.lua" # from [7510e5e9d34dc9e063bbc33018ce2ea8e86f3c2a] # to [875dc3cc89a24f7e6cd1b5352eeb216699bd1649] # # patch "tests/spawn_redirected_hook_helper/testhooks.lua" # from [ca2591f01fbf45e890056734ef35209852b6d2fd] # to [ddaa35c3568350c21994aa3c3851cbe70a341aba] # # patch "tests/syntax_errors_in_.mtn-ignore/__driver__.lua" # from [40ae692978a4b62a47ad35468cc2e52656a68643] # to [c5de9634b9f83a6d76e6cac44a524153dfef1c4d] # # patch "tests/syntax_errors_in_.mtn-ignore/stderr-ref" # from [6f474b55e26298e81d8a9365fa5bfd99e580e417] # to [8f8b4d47d427005b67ce140fa324982ee26a118b] # # patch "tests/test_hooks.lua" # from [731fd61c7d9490548d9eed744629a6950748890b] # to [8bafb1d7da871ac202a12f3745d6a6273a2fdbb6] # # patch "tests/test_some_hook_helper_functions/__driver__.lua" # from [0452cea0d5129e7c27bd16e191a210a1c3e7864b] # to [c894af66f29df3dbd1ff99e8acf7c856558e1094] # # patch "tests/test_some_hook_helper_functions/testhooks.lua" # from [4c344db8109d494ac0b3bac8789ef97f4fc25ecf] # to [3bf31c743cd781a151963f0b1b1e93de2d5127d5] # # patch "tests/things_in_.mtn-ignore_get_ignored/__driver__.lua" # from [135078855fd8b9826fa1b15314ad3ced48850d45] # to [716760c01df74827ba80f177f94f41adf0da623b] # # patch "testsuite.lua" # from [d8002514928ca3bdfd74d4d3fa8e21534175ee1c] # to [273fdf6f8b1125dabb6d661c1ef85c4525dfcab1] # # patch "work.cc" # from [6d3bd354fb938e901952cc38599415dbb056e3c8] # to [9d75ba94d10f4f8f10c84477eace793dc4b9a993] # ============================================================ --- ChangeLog 2a759016cabfd22e924c7d2d7ccad848da766a0a +++ ChangeLog ff5e3f7396057cf55685e78c8f0479391f5b76a9 @@ -1,3 +1,41 @@ +2007-01-03 Zack Weinberg + + * annotate.cc: Add a #define to suppress boost.serialization + (which we do not use). + * pcrewrap.hh (basic_regex, regex): Don't disallow the default + copy constructor or operator=, so that these objects can be put + into STL containers. + * pcrewrap.cc (adjrefcount): New function to access a pcre_t's + internal reference count conveniently. + (regex): Bump the reference count in all constructors. + Add definitions of the copy constructor and operator=. + Call pcre_free in destructor only if refcount is zero after + decrement. + + * restrictions.cc: Transplant all logic for ignoring files here. + (ignore_file): New export. + (validate_roster_paths, validate_workspace_paths): Use + ignore_file. Remove app_state argument. All callers changed. + * restrictions.hh: Declare ignore_file. + * lua_hooks.cc, lua_hooks.hh (hook_ignore_file): Delete. + * std_hooks.lua (dir_matches, ignore_file): Delete. + * tests/test_hooks.lua (ignore_file): Delete. + * testsuite.lua (mtn_setup): Provide a sane .mtn-ignore. + + * work.cc: Use ignore_file not hook_ignore_file; remove lua_hooks + references everywhere they are no longer necessary. + * cmd_ws_commit.cc (CMD(mkdir)): Use ignore_file. + + * tests/addition_of_files_and_directories, tests/automate_inventory + * tests/manifest_restrictions, tests/mkdir, tests/mtn_add_dot + * tests/restricted_commands_are_consistent + * tests/revert_ignored_files, tests/revert_works_with_restrictions + * tests/spawn_redirected_hook_helper + * tests/syntax_errors_in_.mtn-ignore + * tests/test_some_hook_helper_functions + * tests/things_in_.mtn-ignore_get_ignored: + Rejigger for ignore no longer being a hook. + 2006-12-29 Zack Weinberg * pcrewrap.cc (pcre_match_error): Remove "subject" parameter. @@ -76,14 +114,14 @@ 2006-12-21 Thomas Keller * NEWS: refined some sections and added notes about - fixes in automate inventory and the localization code + fixes in automate inventory and the localization code 2006-12-19 Thomas Keller @@ -164,11 +202,11 @@ 2006-12-14 Thomas Keller - * work.cc: handle missing directories properly in - classify_roster_paths - * automate.cc: trailing slash also for missing directories - * tests/...: adapted automate_inventory test which now tests - for unknown, added (but missing) and dropped (uncommitted) dirs + * work.cc: handle missing directories properly in + classify_roster_paths + * automate.cc: trailing slash also for missing directories + * tests/...: adapted automate_inventory test which now tests + for unknown, added (but missing) and dropped (uncommitted) dirs 2006-12-14 Thomas Keller @@ -192,26 +230,26 @@ 2006-12-12 Ben Walton - - * cmd_ws_cc: Added mtn mkdir - * testsuite.lua: added mtn mkdir test - * included tests/mkdir as unit testing for mtn mkdir - * added documentation to monotone.texi + * cmd_ws_cc: Added mtn mkdir + * testsuite.lua: added mtn mkdir test + * included tests/mkdir as unit testing for mtn mkdir + * added documentation to monotone.texi + 2006-12-12 Thomas Moschny * HACKING: Updated "Patch submission guidelines" section. 2006-12-11 Ben Walton - - * cmd_ws_commit.cc, - tests/commit_using__MTN_log/commit_log_modified_return.lua, - tests/commit_using__MTN_log/__driver__.lua: - Added the requirement that when _MTN/log is pre-specified by - the user, that the user remove a 'magic' line prior to the - commit being accepted. Modified the units tests to verify this. - Updated texinfo to match this new behaviour. + * cmd_ws_commit.cc, + tests/commit_using__MTN_log/commit_log_modified_return.lua, + tests/commit_using__MTN_log/__driver__.lua: + Added the requirement that when _MTN/log is pre-specified by + the user, that the user remove a 'magic' line prior to the + commit being accepted. Modified the units tests to verify this. + Updated texinfo to match this new behaviour. + 2006-12-10 Timothy Brownawell Implement a "mtn log --to ", that doesn't log the @@ -1520,7 +1558,7 @@ 2006-09-02 Matt Johnston - + * botan/: import of Botan 1.5 2006-08-31 Nathaniel Smith ============================================================ --- annotate.cc dc5051843ce6406acbf2fadf151e9e9d52a36946 +++ annotate.cc 7e5a4a4c768197dd53f236810b1a661a4a557125 @@ -10,6 +10,7 @@ #include #include +#define BOOST_MULTI_INDEX_DISABLE_SERIALIZATION #include #include #include ============================================================ --- cmd_ws_commit.cc 7dc23e7fa867951dbc82b5bd2da8a3560f2e4fc6 +++ cmd_ws_commit.cc 369879d22a0c948672ec69143a441e56c6e70733 @@ -288,7 +288,7 @@ CMD(mkdir, N_("workspace"), N_("[DIRECTO //wouldn't make sense to add a dir to .mtn-ignore and then //try to add it to the project with a mkdir statement, but //one never can tell... - N(app.opts.no_ignore || !app.lua.hook_ignore_file(fp), + N(app.opts.no_ignore || !ignore_file(fp), F("ignoring directory '%s' [see .mtn-ignore]") % fp); paths.insert(sp); ============================================================ --- lua_hooks.cc 2ba09f87d8dc16a1957cad5abc98565a7c87cc7c +++ lua_hooks.cc 9f6086677ce5eaf8a00d7213af7ff7fad2c6febf @@ -298,19 +298,6 @@ bool } bool -lua_hooks::hook_ignore_file(file_path const & p) -{ - bool ignore_it = false; - bool exec_ok = Lua(st) - .func("ignore_file") - .push_str(p.as_external()) - .call(1,1) - .extract_bool(ignore_it) - .ok(); - return exec_ok && ignore_it; -} - -bool lua_hooks::hook_ignore_branch(string const & branch) { bool ignore_it = false; ============================================================ --- lua_hooks.hh 7442504bf6a1fff7e6afe120d6883198f5303842 +++ lua_hooks.hh 4c4cf2633131c9de5b5ee26a7a12bee0e2dd6014 @@ -77,7 +77,6 @@ public: bool hook_get_netsync_write_permitted(rsa_keypair_id const & identity); // local repo hooks - bool hook_ignore_file(file_path const & p); bool hook_ignore_branch(std::string const & branch); bool hook_merge3(file_path const & anc_path, file_path const & left_path, ============================================================ --- pcrewrap.cc dd081644cde0233e19d86e37323b14ff6daf4594 +++ pcrewrap.cc a924e9ddb82895ed65efc23daeced38fd3eba67d @@ -67,22 +67,49 @@ get_capturecount(void const * bd) return cc; } +// We do occasionally need to copy regex objects around, so we make use of +// the PCRE refcount machinery to ensure the underlying data blocks are +// freed only once. Encapsulate the pointer diddling needed for this. +inline unsigned short adjrefcount(void const * bd, short n) +{ + return pcre_refcount(static_cast(const_cast(bd)), n); +} + namespace pcre { regex::regex(char const * pattern, flags options) : basic_regex(compile(pattern, options)) - {} + { + I(adjrefcount(basedat, 1) == 1); + } regex::regex(string const & pattern, flags options) : basic_regex(compile(pattern.c_str(), options)) - {} + { + I(adjrefcount(basedat, 1) == 1); + } + regex::regex(regex const & other) + : basic_regex(other) + { + I(adjrefcount(basedat, 1) < 65535); + } + + regex & regex::operator=(regex const & other) + { + *(static_cast(this)) = static_cast(other); + I(adjrefcount(basedat, 1) < 65535); + return *this; + } + regex::~regex() { - if (basedat) - pcre_free(const_cast(basedat)); - if (extradat) - pcre_free(const_cast(extradat)); + if (adjrefcount(basedat, -1) == 0) + { + pcre_free(const_cast(basedat)); + if (extradat) + pcre_free(const_cast(extradat)); + } } bool ============================================================ --- pcrewrap.hh 5b3070b3642cc669273a7347bf6feb938f465215 +++ pcrewrap.hh 244cc638f7a9676d3981974a70bb274f3be06e84 @@ -74,14 +74,13 @@ namespace pcre struct basic_regex { private: - // disable the default and copy constructors + // disable the default constructor; the default copy constructor and + // operator= are fine. basic_regex(); - basic_regex(basic_regex const &); - basic_regex & operator=(basic_regex const &); protected: - void const * const basedat; - void const * const extradat; + void const * basedat; + void const * extradat; // for use only by subclass constructors basic_regex(std::pair p) @@ -119,6 +118,10 @@ namespace pcre regex(char const * pattern, pcre::flags options = DEFAULT); regex(std::string const & pattern, pcre::flags options = DEFAULT); ~regex(); + + // the default copy constructor and operator= are not fine. + regex(regex const &); + regex & operator=(regex const &); }; // exceptions thrown for errors from PCRE APIs ============================================================ --- restrictions.cc 474dbc86c29a1f8ce0abb1f27ebde4849c2042dc +++ restrictions.cc dc91cbcec3bb7d6a70f084b675cb78ca19c89c92 @@ -10,15 +10,17 @@ #include #include #include +#include +#include #include "restrictions.hh" #include "revision.hh" #include "safe_map.hh" #include "transforms.hh" +#include "pcrewrap.hh" using std::make_pair; using std::map; -using std::set; using std::vector; // TODO: add check for relevant rosters to be used by log @@ -80,11 +82,130 @@ map_paths(map regex_set; + +static regex_set ignore_set; + +// Read the table above, and the .mtn-ignore file, and establish a set of +// regexes from them. To consider: +// 1. There's an implicit dependency on the current directory here. +// Read the .mtn-ignore file from the database instead? +// (Which revision's version of that file?) +// 2. Merge all the regexes together into one mega-regex? +// 3. Have some way for .mtn-ignore to kick entries out of the default set? +// 4. Change to globs? +// 5. Use a more CVS-like model with one ignore file per directory? +// 5a.Or a more SVN-like model using directory attributes? +// (Could then establish the default ignore set using attr init hooks, +// thus making it natural for users to kick entries back out?) + static void +initialize_ignore_set() +{ + for (size_t i = 0; i < (sizeof(default_ignore_pats) + / sizeof(default_ignore_pats[0])); i++) + ignore_set.push_back(pcre::regex(default_ignore_pats[i])); + + std::ifstream f(".mtn-ignore"); + int line = 0; + if (f) + // Please someone tell me there is a better way to read lines from + // an ifstream. + while (!f.eof()) + { + std::stringbuf sb; + char newline; + f.get(sb); + // An empty line is ignored; so is a line that provokes a syntax + // error. + if (f.good()) + try + { + line++; + ignore_set.push_back(pcre::regex(sb.str())); + } + catch (pcre::compile_error & e) + { + W(F(".mtn-ignore:%d: %s\n\t- skipping this regex.") + % line % e.what()); + } + f.clear(f.rdstate() & ~std::ios::failbit); + f.get(newline); + } +} + +bool +ignore_file(file_path const & fp) +{ + if (ignore_set.size() == 0) + initialize_ignore_set(); + + for (regex_set::const_iterator p = ignore_set.begin(); + p != ignore_set.end(); p++) + try + { + if (p->match(fp.as_external())) + return true; + } + catch (pcre::match_error & e) + { + W(F("while deciding whether to ignore '%s': %s") + % fp.as_external() % e.what()); + // PCRE match errors don't necessarily mean the regex is no good, + // so leave it in the set. + } + return false; +} + +static void validate_roster_paths(path_set const & included_paths, path_set const & excluded_paths, - path_set const & known_paths, - app_state & app) + path_set const & known_paths) { int bad = 0; @@ -97,7 +218,7 @@ validate_roster_paths(path_set const & i if (known_paths.find(*i) == known_paths.end()) { file_path fp(*i); - if (!app.lua.hook_ignore_file(fp)) + if (!ignore_file(fp)) { bad++; W(F("restriction includes unknown path '%s'") % *i); @@ -120,8 +241,7 @@ validate_workspace_paths(path_set const void validate_workspace_paths(path_set const & included_paths, - path_set const & excluded_paths, - app_state & app) + path_set const & excluded_paths) { int bad = 0; @@ -135,7 +255,7 @@ validate_workspace_paths(path_set const // considered invalid if they are found in none of the restriction's // rosters file_path fp(*i); - if (!path_exists(fp) && !app.lua.hook_ignore_file(fp)) + if (!path_exists(fp) && !ignore_file(fp)) { bad++; W(F("restriction includes unknown path '%s'") % *i); @@ -172,7 +292,7 @@ node_restriction::node_restriction(std:: std::vector const & excludes, long depth, roster_t const & roster, - app_state & a) : + app_state &) : restriction(includes, excludes, depth) { map_nodes(node_map, roster, included_paths, known_paths, @@ -180,7 +300,7 @@ node_restriction::node_restriction(std:: map_nodes(node_map, roster, excluded_paths, known_paths, restricted_path::excluded); - validate_roster_paths(included_paths, excluded_paths, known_paths, a); + validate_roster_paths(included_paths, excluded_paths, known_paths); } node_restriction::node_restriction(std::vector const & includes, @@ -188,7 +308,7 @@ node_restriction::node_restriction(std:: long depth, roster_t const & roster1, roster_t const & roster2, - app_state & a) : + app_state &) : restriction(includes, excludes, depth) { map_nodes(node_map, roster1, included_paths, known_paths, @@ -201,19 +321,19 @@ node_restriction::node_restriction(std:: map_nodes(node_map, roster2, excluded_paths, known_paths, restricted_path::excluded); - validate_roster_paths(included_paths, excluded_paths, known_paths, a); + validate_roster_paths(included_paths, excluded_paths, known_paths); } path_restriction::path_restriction(std::vector const & includes, std::vector const & excludes, long depth, - app_state & a) : + app_state &) : restriction(includes, excludes, depth) { map_paths(path_map, included_paths, restricted_path::included); map_paths(path_map, excluded_paths, restricted_path::excluded); - validate_workspace_paths(included_paths, excluded_paths, a); + validate_workspace_paths(included_paths, excluded_paths); } bool ============================================================ --- restrictions.hh 5b16498cc58ffea38a6e98f4b32efda724dc7ef3 +++ restrictions.hh a92fb8592600abc74bf22c96fbae73268511737e @@ -123,6 +123,11 @@ class path_restriction : public restrict std::map path_map; }; +// Call this function to see whether a file should be ignored by most +// operations. +extern bool ignore_file(file_path const &); + + // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- std_hooks.lua 8174984c17963cd5aa57748cb3abd90a1be7b8ce +++ std_hooks.lua 2cce6d4e4574dd3225364bbb734a8839df87bcac @@ -83,97 +83,7 @@ attr_functions["mtn:execute"] = end end -function dir_matches(name, dir) - -- helper for ignore_file, matching files within dir, or dir itself. - -- eg for dir of 'CVS', matches CVS/, CVS/*, */CVS/ and */CVS/* - if (string.find(name, "^" .. dir .. "/")) then return true end - if (string.find(name, "^" .. dir .. "$")) then return true end - if (string.find(name, "/" .. dir .. "/")) then return true end - if (string.find(name, "/" .. dir .. "$")) then return true end - return false -end -function ignore_file(name) - -- project specific - if (ignored_files == nil) then - ignored_files = {} - local ignfile = io.open(".mtn-ignore", "r") - if (ignfile ~= nil) then - for l in ignfile:lines() do table.insert(ignored_files, l) end - end - end - - local warn_reported_file = false - for i, line in pairs(ignored_files) - do - if (line ~= nil) then - local pcallstatus, result = pcall(function() - return regex.search(line, name) - end) - if pcallstatus == true then - -- no error from the regex.search call - if result == true then return true end - else - -- regex.search had a problem, warn the user their - -- .mtn-ignore file syntax is wrong - if not warn_reported_file then - io.stderr:write("mtn: warning: while matching file '" - .. name .. "':\n") - warn_reported_file = true - end - io.stderr:write(".mtn-ignore:" .. i .. ": warning: " .. result - .. "\n\t- skipping this regex for " - .. "all remaining files.\n") - ignored_files[i] = nil - end - end - end - - local file_pats = { - -- c/c++ - "%.a$", "%.so$", "%.o$", "%.la$", "%.lo$", "^core$", - "/core$", "/core%.%d+$", - -- java - "%.class$", - -- python - "%.pyc$", "%.pyo$", - -- gettext - "%.g?mo$", - -- intltool - "%.intltool%-merge%-cache$", - -- TeX - "%.aux$", - -- backup files - "%.bak$", "%.orig$", "%.rej$", "%~$", - -- vim creates .foo.swp files - "%.[^/]*%.swp$", - -- emacs creates #foo# files - "%#[^/]*%#$", - -- other VCSes (where metadata is stored in named files): - "%.scc$", - -- desktop/directory configuration metadata - "^%.DS_Store$", "/%.DS_Store$", "^desktop%.ini$", "/desktop%.ini$" - } - - local dir_pats = { - -- autotools detritus: - "autom4te%.cache", "%.deps", "%.libs", - -- Cons/SCons detritus: - "%.consign", "%.sconsign", - -- other VCSes (where metadata is stored in named dirs): - "CVS", "%.svn", "SCCS", "_darcs", "%.cdv", "%.git", "%.bzr", "%.hg" - } - - for _, pat in ipairs(file_pats) do - if string.find(name, pat) then return true end - end - for _, pat in ipairs(dir_pats) do - if dir_matches(name, pat) then return true end - end - - return false; -end - -- return true means "binary", false means "text", -- nil means "unknown, try to guess" function binary_file(name) ============================================================ --- tests/addition_of_files_and_directories/__driver__.lua 91100a9f3896ff4baa703586ebba94ff2654f115 +++ tests/addition_of_files_and_directories/__driver__.lua c2b0ac39219d138ccf22fb0d6f69e3e84bedc19d @@ -48,20 +48,20 @@ writefile("file3", "file 3\n") -- add --unknown should add any files that ls unknown shows you and not ignored writefile("file3", "file 3\n") ---writefile("file4.ignore", "file 4 ignore\n") +writefile("file4.ignore", "file 4 ignore\n") writefile("dir/file5", "file 5\n") writefile("dir/file6.ignore", "file 6\n") mkdir("dir2") writefile("dir2/file7", "file 7\n") ---writefile(".mtn-ignore", ".*\\.ignore$\n") +append(".mtn-ignore", "\\.ignore$\n") ---check(raw_mtn("ls", "unkown"), 0, true, false) +check(mtn("ls", "unknown"), 0, true, false) check(mtn("add", "--unknown"), 0, false, true) check(qgrep('adding file3', "stderr")) ---check(not qgrep('adding file4.ignore', "stderr")) +check(not qgrep('adding file4.ignore', "stderr")) check(qgrep('adding dir/file5', "stderr")) ---check(not qgrep('adding dir/file6.ignore', "stderr")) +check(not qgrep('adding dir/file6.ignore', "stderr")) check(qgrep('adding dir2', "stderr")) check(qgrep('adding dir2/file7', "stderr")) check(not qgrep('skipping dir2/file7', "stderr")) @@ -72,9 +72,9 @@ check(qgrep("file3", "stdout")) check(not qgrep("file1", "stdout")) check(not qgrep("file2", "stdout")) check(qgrep("file3", "stdout")) ---check(not qgrep("file4", "stdout")) +check(not qgrep("file4", "stdout")) check(qgrep("file5", "stdout")) ---check(not qgrep("file6", "stdout")) +check(not qgrep("file6", "stdout")) commit() @@ -83,6 +83,6 @@ check(not qgrep("file3", "stdout")) check(not qgrep("file1", "stdout")) check(not qgrep("file2", "stdout")) check(not qgrep("file3", "stdout")) ---check(not qgrep("file4", "stdout")) +check(not qgrep("file4", "stdout")) check(not qgrep("file5", "stdout")) +check(not qgrep("file6", "stdout")) ---check(not qgrep("file6", "stdout")) ============================================================ --- tests/automate_inventory/__driver__.lua 21d9c672d0dc7c25066da114ac100a25060e6838 +++ tests/automate_inventory/__driver__.lua 06b203ca291c9ee93f28cdbf13a775cdf66635cb @@ -1,8 +1,6 @@ mtn_setup() mtn_setup() -check(get("inventory_hooks.lua")) - addfile("missing", "missing") addfile("dropped", "dropped") addfile("original", "original") @@ -25,7 +23,7 @@ check(mtn("drop", "dropped"), 0, false, check(mtn("rename", "original", "renamed"), 0, false, false) check(mtn("drop", "dropped"), 0, false, false) -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^ M 0 0 missing$', "stdout"), 0, false, false) check(grep('^ AP 0 0 added$', "stdout"), 0, false, false) check(grep('^D 0 0 dropped$', "stdout"), 0, false, false) @@ -44,7 +42,7 @@ check(mtn("rename", "temporary", "origin check(mtn("rename", "original", "unchanged"), 0, false, false) check(mtn("rename", "temporary", "original"), 0, false, false) -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^RRP 1 2 original$', "stdout"), 0, false, false) check(grep('^RRP 2 1 unchanged$', "stdout"), 0, false, false) @@ -54,7 +52,7 @@ rename("temporary", "original") rename("original", "unchanged") rename("temporary", "original") -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^RR 1 2 original$', "stdout"), 0, false, false) check(grep('^RR 2 1 unchanged$', "stdout"), 0, false, false) @@ -65,7 +63,7 @@ check(mtn("add", "original"), 0, false, check(mtn("rename", "original", "renamed"), 0, false, false) check(mtn("add", "original"), 0, false, false) -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^RAP 1 0 original$', "stdout"), 0, false, false) check(grep('^ R 0 1 renamed$', "stdout"), 0, false, false) @@ -80,7 +78,7 @@ check(mtn("rename", "temporary", "droppe check(mtn("rename", "dropped", "missing"), 0, false, false) check(mtn("rename", "temporary", "dropped"), 0, false, false) -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^RRP 1 3 dropped$', "stdout"), 0, false, false) check(grep('^RRP 2 1 missing$', "stdout"), 0, false, false) check(grep('^RRP 3 2 original$', "stdout"), 0, false, false) @@ -92,7 +90,7 @@ rename("temporary", "dropped") rename("dropped", "missing") rename("temporary", "dropped") -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^RR 1 3 dropped$', "stdout"), 0, false, false) check(grep('^RR 2 1 missing$', "stdout"), 0, false, false) check(grep('^RR 3 2 original$', "stdout"), 0, false, false) @@ -103,7 +101,7 @@ check(mtn("drop", "dropped"), 0, false, check(mtn("drop", "dropped"), 0, false, false) -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^D U 0 0 dropped$', "stdout"), 0, false, false) -- added but removed and thus missing @@ -113,7 +111,7 @@ remove("added") check(mtn("add", "added"), 0, false, false) remove("added") -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^ AM 0 0 added$', "stdout"), 0, false, false) -- renamed but not moved and thus unknown source and missing target @@ -123,7 +121,7 @@ check(mtn("rename", "original", "renamed remove("renamed") check(mtn("rename", "original", "renamed"), 0, false, false) -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(qgrep('^R U 1 0 original$', "stdout")) check(qgrep('^ RM 0 1 renamed$', "stdout")) @@ -133,7 +131,7 @@ rename("original", "renamed") rename("original", "renamed") -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^ M 0 0 original$', "stdout"), 0, false, false) check(grep('^ U 0 0 renamed$', "stdout"), 0, false, false) @@ -145,7 +143,7 @@ check(mtn("rename", "original", "renamed remove("original") check(mtn("rename", "original", "renamed"), 0, false, false) -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^R 1 0 original$', "stdout"), 0, false, false) check(grep('^ RP 0 1 renamed$', "stdout"), 0, false, false) @@ -153,25 +151,25 @@ mkdir("new_dir") -- check if unknown/missing/dropped directories are recognized as such mkdir("new_dir") -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^ U 0 0 new_dir\/$', "stdout"), 0, false, false) check(mtn("add", "new_dir"), 0, false, false) remove("new_dir"); -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^ AM 0 0 new_dir\/$', "stdout"), 0, false, false) mkdir("new_dir") commit() -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^ 0 0 new_dir\/$', "stdout"), 0, false, false) remove("new_dir") check(mtn("drop", "new_dir"), 0, false, false) -check(mtn("automate", "inventory", "--rcfile=inventory_hooks.lua"), 0, true, false) +check(mtn("automate", "inventory"), 0, true, false) check(grep('^D 0 0 new_dir\/$', "stdout"), 0, false, false) -- some tests for renaming directories are still missing here! ============================================================ --- tests/manifest_restrictions/__driver__.lua 0eea8a13102d0725bfb212125b29c6e33c945119 +++ tests/manifest_restrictions/__driver__.lua 9a54979b3b7cb6f1aaab4ba4a9923c0ae66fb9c8 @@ -1,8 +1,6 @@ mtn_setup() mtn_setup() -check(get("ignored.lua")) - mkdir("work") mkdir("work/A") mkdir("work/A/B") @@ -58,10 +56,10 @@ rename("work/filex2", "work/file2") rename("work/filex2", "work/file2") -check(mtn("ls", "ignored", "--rcfile=ignored.lua"), 0, true, false) +check(mtn("ls", "ignored"), 0, true, false) check(qgrep("work/foo.o", "stdout")) -check(mtn("ls", "ignored", "--rcfile=ignored.lua", "work"), 0, true, false) +check(mtn("ls", "ignored", "work"), 0, true, false) check(qgrep("work/foo.o", "stdout")) -- create moved, dropped, and changed work to test status, diff, commit ============================================================ --- tests/mkdir/__driver__.lua 33e48a4f90a4fc32c8031389366479e634619fe1 +++ tests/mkdir/__driver__.lua d8ac9fa990499b9a7e1692cf3ea85aa55fde6a93 @@ -1,9 +1,7 @@ mtn_setup() skip_if(not existsonpath("test")) mtn_setup() -check(get("ignore_hook.lua")) - --no args check(mtn("mkdir"), 2, false, false) @@ -42,14 +40,16 @@ check({"test", "-d", "test3"}, 1, false, check({"test", "-d", "test3"}, 1, false, false) --ignore feature -check(mtn("--rcfile=ignore_hook.lua", "mkdir", "testing4"), 1, false, false) +append(".mtn-ignore", "testing4\n") + +check(mtn("mkdir", "testing4"), 1, false, false) check({"test", "-d", "testing4"}, 1, false, false) --multiple with some ignored (all should fail, workspace should be unchanged) -check(mtn("--rcfile=ignore_hook.lua", "mkdir", "testing4", "testing5"), 1, false, false) +check(mtn("mkdir", "testing4", "testing5"), 1, false, false) check({"test", "-d", "testing4"}, 1, false, false) check({"test", "-d", "testing5"}, 1, false, false) --not respecting ignore -check(mtn("--no-respect-ignore", "--rcfile=ignore_hook.lua", "mkdir", "testing4"), 0, false, false) +check(mtn("--no-respect-ignore", "mkdir", "testing4"), 0, false, false) check({"test", "-d", "testing4"}) ============================================================ --- tests/mtn_add_dot/__driver__.lua 6858c894d4638b4b9c4dca9ed5e701a8a799918f +++ tests/mtn_add_dot/__driver__.lua 11d25f15c1174862121c8cc4bba914e0c80ec817 @@ -13,6 +13,7 @@ chdir("subdir") -- Make sure that "add ." works, even at the root of the tree chdir("subdir") +copy("../.mtn-ignore", ".mtn-ignore") -- Recursive and non-recursive may process things differently, check -- that both return success check(mtn("add", "."), 0, false, false) ============================================================ --- tests/restricted_commands_are_consistent/__driver__.lua 2859490ab866d2bcb418b6738123b58cf87dc760 +++ tests/restricted_commands_are_consistent/__driver__.lua f8d3c49b5417f5d078aac5225e690d9c69cd9d73 @@ -102,11 +102,14 @@ check(mtn("revert", "."), 0, false, fals check(mtn("revert", "."), 0, false, false) -- ls ignored -check(get("ignore.lua")) +copy(".mtn-ignore", "saved-mtn-ignore") +append(".mtn-ignore", "1$\n2$\n") + -- only unknown files are considered by ls ignored check(mtn("drop", unpack(allfiles)), 0, false, false) -checkall({"ls", "ignored", "--rcfile=ignore.lua"}, "stdout") +checkall({"ls", "ignored"}, "stdout") check(mtn("revert", "."), 0, false, false) +rename("saved-mtn-ignore", ".mtn-ignore") -- ls missing for _,x in pairs(allfiles) do remove(x) end ============================================================ --- tests/revert_ignored_files/__driver__.lua d853be95ada1e10faef3b5e56873054b108fd24d +++ tests/revert_ignored_files/__driver__.lua 35e9149005ae38d0bf2a4d9d946e8aeb4b3aafb6 @@ -12,29 +12,29 @@ writefile("baz.ignored", "baz.ignored") writefile("bar.ignored", "bar.ignored") writefile("baz.ignored", "baz.ignored") -check(get("ignore.lua")) - commit() writefile("foo", "foofoo") writefile("bar", "barbar") writefile("baz", "bazbaz") -check(mtn("status", "--rcfile=ignore.lua"), 0, true, false) +append(".mtn-ignore", "\\.ignored$\n") + +check(mtn("status"), 0, true, false) check(qgrep("foo", "stdout")) check(qgrep("bar", "stdout")) check(qgrep("baz", "stdout")) -check(mtn("status", "--rcfile=ignore.lua", "foo.ignored", "bar.ignored", "baz.ignored"), 0, true, false) +check(mtn("status", "foo.ignored", "bar.ignored", "baz.ignored"), 0, true, false) check(not qgrep("foo", "stdout")) check(not qgrep("bar", "stdout")) check(not qgrep("baz", "stdout")) -- revert with nothing but ignored files should do nothing -check(mtn("revert", "--rcfile=ignore.lua", "foo.ignored", "bar.ignored", "baz.ignored")) +check(mtn("revert", "foo.ignored", "bar.ignored", "baz.ignored")) -check(mtn("status", "--rcfile=ignore.lua"), 0, true, false) +check(mtn("status"), 0, true, false) check(qgrep("foo", "stdout")) check(qgrep("bar", "stdout")) check(qgrep("baz", "stdout")) ============================================================ --- tests/revert_works_with_restrictions/__driver__.lua 0c1cd59c222d501aa739fb0a2caa4d450bba0a2b +++ tests/revert_works_with_restrictions/__driver__.lua 66ebe57ad06990aa60bed705f6146c5988a72726 @@ -8,8 +8,6 @@ writefile("modified3", "this is differen writefile("modified2", "this is different 2") writefile("modified3", "this is different 3") -check(get("ignore_hook.lua")) - copy("origfile", "testfile") copy("orig.ignore", "file.ignore") copy("orig2", "file2") @@ -20,8 +18,11 @@ copy("modified2", "file.ignore") copy("modified1", "testfile") copy("modified2", "file.ignore") -check(mtn("--rcfile=ignore_hook.lua", "revert", "file.ignore"), 0, false, false) +-- start ignoring the 'ignored' files +append(".mtn-ignore", "\\.ignore$\n") +check(mtn("revert", "file.ignore"), 0, false, false) + -- check that only the 'ignored' file was reverted check(samefile("testfile", "modified1")) check(samefile("file.ignore", "orig.ignore")) @@ -32,7 +33,7 @@ copy("modified3", "file2") copy("modified2", "file.ignore") copy("modified3", "file2") -check(mtn("--rcfile=ignore_hook.lua", "revert", "file.ignore", "testfile"), 0, false, false) +check(mtn("revert", "file.ignore", "testfile"), 0, false, false) -- check that the files are correct check(samefile("testfile", "origfile")) @@ -46,7 +47,7 @@ remove("file2") copy("modified2", "file.ignore") remove("file2") -check(mtn("--rcfile=ignore_hook.lua", "revert", "--missing", ".", "--debug"), 0, false, false) +check(mtn("revert", "--missing", "."), 0, false, false) check(samefile("testfile", "modified1")) check(samefile("file.ignore", "modified2")) @@ -60,7 +61,7 @@ copy("orig2", "file2") copy("orig.ignore", "file.ignore") copy("orig2", "file2") -check(mtn("--rcfile=ignore_hook.lua", "revert", "--missing", ".", "--debug"), 0, false, false) +check(mtn("revert", "--missing", "."), 0, false, false) check(samefile("testfile", "modified1")) check(samefile("file.ignore", "orig.ignore")) ============================================================ --- tests/spawn_redirected_hook_helper/__driver__.lua 7510e5e9d34dc9e063bbc33018ce2ea8e86f3c2a +++ tests/spawn_redirected_hook_helper/__driver__.lua 875dc3cc89a24f7e6cd1b5352eeb216699bd1649 @@ -1,8 +1,9 @@ mtn_setup() mtn_setup() -check(get("testhooks")) +check(get("testhooks.lua")) -check(raw_mtn("--rcfile=testhooks", "ls", "unknown"), 0, false, false) +writefile("dummy") +check(mtn("--rcfile=testhooks.lua", "--debug", "add", "dummy"), 0, false, false) skip_if(exists("skipfile")) check(exists("outfile")) ============================================================ --- tests/spawn_redirected_hook_helper/testhooks ca2591f01fbf45e890056734ef35209852b6d2fd +++ tests/spawn_redirected_hook_helper/testhooks.lua ddaa35c3568350c21994aa3c3851cbe70a341aba @@ -1,24 +1,20 @@ -function ignore_file (name) - ok = true - - if ok then - if existsonpath("touch") == 0 then +attr_init_functions["magic"] = function (name) + ok = true + if existsonpath("touch") == 0 then pid = spawn_redirected ("", "", "xyzzy", "touch", "foofile") if pid == -1 then ok = false end - elseif existsonpath("xcopy") == 0 then + elseif existsonpath("xcopy") == 0 then pid = spawn_redirected ("", "", "xyzzy", "xcopy") if pid == -1 then ok = false end - else + else x = io.open("skipfile", "w") x:close() - end - end - + end + if ok then x = io.open("outfile", "w") x:close() end - ignore_file = function (name) return true end -return true + return nil end ============================================================ --- tests/syntax_errors_in_.mtn-ignore/__driver__.lua 40ae692978a4b62a47ad35468cc2e52656a68643 +++ tests/syntax_errors_in_.mtn-ignore/__driver__.lua c5de9634b9f83a6d76e6cac44a524153dfef1c4d @@ -8,7 +8,7 @@ check(get("mtn-ignore", ".mtn-ignore")) writefile("dontignoreme") check(get("mtn-ignore", ".mtn-ignore")) -check(raw_mtn("ls", "unknown"), 0, true, true) +check(mtn("ls", "unknown"), 0, true, true) check(get("stdout-ref")) check(get("stderr-ref")) ============================================================ --- tests/syntax_errors_in_.mtn-ignore/stderr-ref 6f474b55e26298e81d8a9365fa5bfd99e580e417 +++ tests/syntax_errors_in_.mtn-ignore/stderr-ref 8f8b4d47d427005b67ce140fa324982ee26a118b @@ -1,63 +1,62 @@ -mtn: warning: while matching file 'tester.log': -.mtn-ignore:1: warning: error near char 2 of regex "\": \ at end of pattern - - skipping this regex for all remaining files. -.mtn-ignore:2: warning: error near char 1 of regex "\c": \c at end of pattern - - skipping this regex for all remaining files. -.mtn-ignore:3: warning: error near char 6 of regex "x{3,1}": numbers out of order in {} quantifier - - skipping this regex for all remaining files. -.mtn-ignore:4: warning: error near char 8 of regex "x{99999}": number too big in {} quantifier - - skipping this regex for all remaining files. -.mtn-ignore:5: warning: error near char 5 of regex "[abc": missing terminating ] for character class - - skipping this regex for all remaining files. -.mtn-ignore:6: warning: error near char 4 of regex "[z-a]": range out of order in character class - - skipping this regex for all remaining files. -.mtn-ignore:7: warning: error near char 1 of regex "*": nothing to repeat - - skipping this regex for all remaining files. -.mtn-ignore:8: warning: error near char 3 of regex "(?h)": unrecognized character after (? - - skipping this regex for all remaining files. -.mtn-ignore:9: warning: error near char 1 of regex "[:alpha:]": POSIX named classes are supported only within a class - - skipping this regex for all remaining files. -.mtn-ignore:10: warning: error near char 5 of regex "(abc": missing ) - - skipping this regex for all remaining files. -.mtn-ignore:11: warning: error near char 6 of regex "abc\3": reference to non-existent subpattern - - skipping this regex for all remaining files. -.mtn-ignore:12: warning: error near char 7 of regex "(?#abc": missing ) after comment - - skipping this regex for all remaining files. -.mtn-ignore:13: warning: error near char 1 of regex ")": unmatched parentheses - - skipping this regex for all remaining files. -.mtn-ignore:14: warning: error near char 4 of regex "(? 255 - - skipping this regex for all remaining files. -.mtn-ignore:26: warning: error near char 5 of regex "(?C1": closing ) for (?C expected - - skipping this regex for all remaining files. -.mtn-ignore:27: warning: error near char 4 of regex "(?R)": recursive call could loop indefinitely - - skipping this regex for all remaining files. -.mtn-ignore:28: warning: error near char 4 of regex "(?P*)": unrecognized character after (?P - - skipping this regex for all remaining files. -.mtn-ignore:29: warning: error near char 5 of regex "(?P<*>x)": syntax error after (?P - - skipping this regex for all remaining files. -.mtn-ignore:30: warning: error near char 38 of regex "(?P)": subpattern name is too long (maximum 32 characters) - - skipping this regex for all remaining files. -.mtn-ignore:31: warning: error near char 4 of regex "\777": octal value is greater than \377 (not in UTF-8 mode) - - skipping this regex for all remaining files. +mtn: warning: .mtn-ignore:1: error near char 2 of regex "\": \ at end of pattern +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:2: error near char 1 of regex "\c": \c at end of pattern +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:3: error near char 6 of regex "x{3,1}": numbers out of order in {} quantifier +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:4: error near char 8 of regex "x{99999}": number too big in {} quantifier +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:5: error near char 5 of regex "[abc": missing terminating ] for character class +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:6: error near char 4 of regex "[z-a]": range out of order in character class +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:7: error near char 1 of regex "*": nothing to repeat +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:8: error near char 3 of regex "(?h)": unrecognized character after (? +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:9: error near char 1 of regex "[:alpha:]": POSIX named classes are supported only within a class +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:10: error near char 5 of regex "(abc": missing ) +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:11: error near char 6 of regex "abc\3": reference to non-existent subpattern +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:12: error near char 7 of regex "(?#abc": missing ) after comment +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:13: error near char 1 of regex ")": unmatched parentheses +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:14: error near char 4 of regex "(? 255 +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:26: error near char 5 of regex "(?C1": closing ) for (?C expected +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:27: error near char 4 of regex "(?R)": recursive call could loop indefinitely +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:28: error near char 4 of regex "(?P*)": unrecognized character after (?P +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:29: error near char 5 of regex "(?P<*>x)": syntax error after (?P +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:30: error near char 38 of regex "(?P)": subpattern name is too long (maximum 32 characters) +mtn: warning: - skipping this regex. +mtn: warning: .mtn-ignore:31: error near char 4 of regex "\777": octal value is greater than \377 (not in UTF-8 mode) +mtn: warning: - skipping this regex. ============================================================ --- tests/test_hooks.lua 731fd61c7d9490548d9eed744629a6950748890b +++ tests/test_hooks.lua 8bafb1d7da871ac202a12f3745d6a6273a2fdbb6 @@ -49,14 +49,6 @@ end return "address@hidden" end -function ignore_file(name) - if (string.find(name, "ts-std", 1, true)) then return true end - if (string.find(name, "testsuite.log")) then return true end - if (string.find(name, "test_hooks.lua")) then return true end - if (string.find(name, "keys")) then return true end - return false -end - function merge2(left_path, right_path, merged_path, left, right) io.write("running merge2 hook\n") return left ============================================================ --- tests/test_some_hook_helper_functions/__driver__.lua 0452cea0d5129e7c27bd16e191a210a1c3e7864b +++ tests/test_some_hook_helper_functions/__driver__.lua c894af66f29df3dbd1ff99e8acf7c856558e1094 @@ -1,7 +1,8 @@ mtn_setup() mtn_setup() -check(get("testhooks")) +check(get("testhooks.lua")) +writefile("dummy") -check(raw_mtn("--rcfile=testhooks", "ls", "unknown"), 0, false, false) +check(mtn("--rcfile=testhooks.lua", "add", "dummy"), 0, false, false) check(exists("outfile")) ============================================================ --- tests/test_some_hook_helper_functions/testhooks 4c344db8109d494ac0b3bac8789ef97f4fc25ecf +++ tests/test_some_hook_helper_functions/testhooks.lua 3bf31c743cd781a151963f0b1b1e93de2d5127d5 @@ -1,4 +1,4 @@ -function ignore_file (name) +attr_init_functions["magic"] = function(name) ok = true filename = write_to_temporary_file("foo") @@ -18,6 +18,5 @@ function ignore_file (name) end end - ignore_file = function (name) return true end -return true + return nil end ============================================================ --- tests/things_in_.mtn-ignore_get_ignored/__driver__.lua 135078855fd8b9826fa1b15314ad3ced48850d45 +++ tests/things_in_.mtn-ignore_get_ignored/__driver__.lua 716760c01df74827ba80f177f94f41adf0da623b @@ -8,7 +8,7 @@ writefile(".mtn-ignore", "bar\nbaz\n*.d\ writefile(".mtn-ignore", "bar\nbaz\n*.d\n") -check(raw_mtn("ls", "unknown"), 0, true, true) +check(mtn("ls", "unknown"), 0, true, true) copy("stdout", "unknown") copy("stderr", "unknownerr") @@ -18,7 +18,7 @@ check(qgrep("warning", "unknownerr")) check(qgrep("warning", "unknownerr")) -check(raw_mtn("ls", "ignored"), 0, true, true) +check(mtn("ls", "ignored"), 0, true, true) copy("stdout", "ignored") copy("stderr", "ignorederr") @@ -29,7 +29,7 @@ remove(".mtn-ignore") check(grep("-qv", "warning|skipping", "ignorederr"), 1) remove(".mtn-ignore") -check(raw_mtn("ls", "ignored"), 0, true, true) +check(mtn("ls", "ignored"), 0, true, true) check(qgrep("test.db", "stdout")) check(not qgrep("warning", "stderr")) check(grep("-qv", "warning|skipping", "ignorederr"), 1) ============================================================ --- testsuite.lua d8002514928ca3bdfd74d4d3fa8e21534175ee1c +++ testsuite.lua 273fdf6f8b1125dabb6d661c1ef85c4525dfcab1 @@ -131,11 +131,18 @@ function mtn_setup() check(getstd("test_keys")) check(getstd("test_hooks.lua")) check(getstd("min_hooks.lua")) - + check(mtn("db", "init"), 0, false, false) check(mtn("read", "test_keys"), 0, false, false) check(mtn("setup", "--branch=testbranch", "."), 0, false, false) remove("test_keys") + writefile(".mtn-ignore", + "^ts-std\n" .. + "^testsuite\\.log$\n" .. + "^test_hooks\\.lua$\n" .. + "^min_hooks\\.lua$\n" .. + "^test.db$\n" .. + "^keys/\n") end function base_revision() ============================================================ --- work.cc 6d3bd354fb938e901952cc38599415dbb056e3c8 +++ work.cc 9d75ba94d10f4f8f10c84477eace793dc4b9a993 @@ -435,15 +435,14 @@ struct file_itemizer : public tree_walke struct file_itemizer : public tree_walker { database & db; - lua_hooks & lua; path_set & known; path_set & unknown; path_set & ignored; path_restriction const & mask; - file_itemizer(database & db, lua_hooks & lua, + file_itemizer(database & db, path_set & k, path_set & u, path_set & i, path_restriction const & r) - : db(db), lua(lua), known(k), unknown(u), ignored(i), mask(r) {} + : db(db), known(k), unknown(u), ignored(i), mask(r) {} virtual void visit_dir(file_path const & path); virtual void visit_file(file_path const & path); }; @@ -462,7 +461,7 @@ file_itemizer::visit_file(file_path cons if (mask.includes(sp) && known.find(sp) == known.end()) { - if (lua.hook_ignore_file(path) || db.is_dbfile(path)) + if (ignore_file(path) || db.is_dbfile(path)) ignored.insert(sp); else unknown.insert(sp); @@ -534,7 +533,7 @@ addition_builder::visit_file(file_path c void addition_builder::visit_file(file_path const & path) { - if ((respect_ignore && lua.hook_ignore_file(path)) || db.is_dbfile(path)) + if ((respect_ignore && ignore_file(path)) || db.is_dbfile(path)) { P(F("skipping ignorable file %s") % path); return; @@ -1029,7 +1028,7 @@ workspace::find_unknown_and_ignored(path new_roster.extract_path_set(known); - file_itemizer u(db, lua, known, unknown, ignored, mask); + file_itemizer u(db, known, unknown, ignored, mask); for (vector::const_iterator i = roots.begin(); i != roots.end(); ++i) {