# # patch "lua.cc" # from [42373a056c2983c5f3d6303eb33c8c8ed88b2aae] # to [f4eebc463e2ceb11a5b39e09e64b70018709c13f] # # patch "std_hooks.lua" # from [598cbe38dd953fe9133e5151caeae60e0d07ea95] # to [fab68a03718ff24159000c76c13c3f7c5888f5ef] # --- lua.cc +++ lua.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -155,6 +156,17 @@ lua_pushnumber(L, process_sleep(seconds)); return 1; } + + static int + monotone_regex_search_for_lua(lua_State *L) + { + const char *re = lua_tostring(L, -2); + const char *str = lua_tostring(L, -1); + boost::cmatch what; + + lua_pushboolean(L, boost::regex_search(str, what, boost::regex(re))); + return 1; + } } @@ -182,6 +194,18 @@ lua_register(st, "wait", monotone_wait_for_lua); lua_register(st, "kill", monotone_kill_for_lua); lua_register(st, "sleep", monotone_sleep_for_lua); + + // add regex functions: + lua_newtable(st); + lua_pushstring(st, "regex"); + lua_pushvalue(st, -2); + lua_settable(st, LUA_GLOBALSINDEX); + + lua_pushstring(st, "search"); + lua_pushcfunction(st, monotone_regex_search_for_lua); + lua_settable(st, -3); + + lua_pop(st, 1); } lua_hooks::~lua_hooks() --- std_hooks.lua +++ std_hooks.lua @@ -74,7 +74,25 @@ if (string.find(name, "/SCCS/")) then return true end if (string.find(name, "%.pyc$")) then return true end if (string.find(name, "%.pyo$")) then return true end - return false; + + -- read the '.mt-ignore' file: + if (ignored_files == nil) then + ignored_files = {} + local i = 1 + for line in io.lines(".mt-ignore") do + ignored_files[i] = line + i = i + 1 + end + end + + for i = 1,table.getn(ignored_files) do + local line = ignored_files[i] + if (regex.search(line, name)) then + return true + end + end + + return false end