# # add_file "tests/t_rcfile_stdin.at" # # patch "ChangeLog" # from [815f95249e316367dfffa702b77184c8e8d1c2e9] # to [306c0b47f022191f4a805ad94bb1cac8c8f631eb] # # patch "app_state.cc" # from [40ba59f4b01affeed917ff52866c25852ad2efda] # to [da30ae47064dd3743fd31e7ce99dcb9c7fdf7813] # # patch "file_io.cc" # from [ea97ee017c1ce25bec7d6ca2fa7e3117da36de3b] # to [c845a1adfff9ce37788124ef8e5c1b75869b0157] # # patch "file_io.hh" # from [7438900771d9c148c4c929639705e679409561fa] # to [d2865f7695f667b872b858b276edcec5d7cf1605] # # patch "lua.cc" # from [5de641d9087116c595d594d37d9e5f9b5e07e7b7] # to [42373a056c2983c5f3d6303eb33c8c8ed88b2aae] # # patch "lua.hh" # from [5e22c1d5555fc59e29b639fdec14696f3804feca] # to [5840b51a224c1bf2e25d448b00c2a3c48e2fd1dc] # # patch "monotone.cc" # from [1429a7b309e9d10dbdca8ec3b70f69a48e7293f7] # to [7001aaae35d22a6d78dbda8638d3635ca8d1081e] # # patch "tests/t_rcfile_stdin.at" # from [] # to [aea482a47a5493616df5dcf06972f174071b3f3a] # # patch "testsuite.at" # from [e5a04b69fb145cb6a1ec88b3af59c4b5e920f443] # to [a62d0f8215b1359408ce4621cbd50bae9a9c1c94] # --- ChangeLog +++ ChangeLog @@ -1,5 +1,15 @@ 2005-05-03 Nathaniel Smith + * lua.cc (load_rcfile): Make a version that takes utf8 strings, + and understands -. + * app_state.cc (load_rcfiles): Use it. + * file_io.{cc,hh} (absolutify_for_command_line): New function. + * monotone.cc (cpp_main): Use it. + * tests/t_rcfile_stdin.at: New test. + * testsuite.at: Include it. + +2005-05-03 Nathaniel Smith + * netsync.cc (load_epoch): Remove unused function. 2005-05-03 Matthew Gregan --- app_state.cc +++ app_state.cc @@ -347,7 +347,7 @@ for (vector::const_iterator i = extra_rcfiles.begin(); i != extra_rcfiles.end(); ++i) { - lua.load_rcfile(*i, true); + lua.load_rcfile(*i); } } --- file_io.cc +++ file_io.cc @@ -170,12 +170,19 @@ if (! tmp.has_root_path()) tmp = fs::current_path() / tmp; I(tmp.has_root_path()); -#if BOOST_VERSION >= 103100 - tmp = tmp.normalize(); -#endif + tmp = tmp.normalize(); return tmp.string(); } +string +absolutify_for_command_line(string const & path) +{ + if (path == "-") + return path; + else + return absolutify(path); +} + string tilde_expand(string const & path) { --- file_io.hh +++ file_io.hh @@ -46,6 +46,7 @@ std::string get_homedir(); std::string absolutify(std::string const & path); +std::string absolutify_for_command_line(std::string const & path); std::string tilde_expand(std::string const & path); extern std::string const book_keeping_dir; --- lua.cc +++ lua.cc @@ -553,9 +553,15 @@ void -lua_hooks::load_rcfile(utf8 const & rc, bool required) +lua_hooks::load_rcfile(utf8 const & rc) { - + I(st); + data dat; + L(F("opening rcfile '%s' ...\n") % rc); + read_data_for_command_line(rc, dat); + N(run_string(st, dat()), + F("lua error while loading rcfile '%s'") % rc); + L(F("'%s' is ok\n") % rc); } void --- lua.hh +++ lua.hh @@ -34,6 +34,7 @@ void add_std_hooks(); void working_copy_rcfilename(fs::path & file); void default_rcfilename(fs::path & file); + void load_rcfile(utf8 const & file); void load_rcfile(fs::path const & file, bool required); // cert hooks --- monotone.cc +++ monotone.cc @@ -284,7 +284,7 @@ break; case OPT_RCFILE: - app.add_rcfile(absolutify(tilde_expand(string(argstr)))); + app.add_rcfile(absolutify_for_command_line(tilde_expand(string(argstr)))); break; case OPT_DUMP: --- tests/t_rcfile_stdin.at +++ tests/t_rcfile_stdin.at @@ -0,0 +1,15 @@ +AT_SETUP([--rcfile=-]) +MONOTONE_SETUP + +AT_DATA(foo.rc, [function note_commit(new_id, certs) + io.write("BOOGA BOOGA\n") +end +]) + +ADD_FILE(testfile, [blah blah +]) +AT_CHECK(