# # patch "ChangeLog" # from [e9ef2840f22898dc2fc42b734e3df6bcf9259657] # to [365395983fc17703a6f4f3099953334e9b40c072] # # patch "commands.cc" # from [94f4c9c04cf33f1d331b529ab7461d892b09dab2] # to [1a13b18406cd0813aca1644fba757b591ff6df5f] # # patch "lua.cc" # from [df6be5cd73a13e0917cc79b8df30144a10422e1c] # to [7d6ce6d0a923bfe263b82b0254d0379a21c354a9] # # patch "paths.cc" # from [f2fe69f3895760212a53333be292da4e6cef92c4] # to [f756d2d0e4a70ba64f23a652923df12db757c501] # # patch "paths.hh" # from [e3af3c34d2cf32e279d86a64e1ce33e7093cd90f] # to [94f4c5abfbd54d869aec02f69e9824108e119972] # # patch "work.cc" # from [cb95e0b012a5aa1f95fc1d3b4a3b8c95e5e913fe] # to [6aad7b52e0799c32f82169a1d7546c09a4444a4e] # ======================================================================== --- ChangeLog e9ef2840f22898dc2fc42b734e3df6bcf9259657 +++ ChangeLog 365395983fc17703a6f4f3099953334e9b40c072 @@ -1,5 +1,13 @@ 2005-08-23 Nathaniel Smith + * paths.{cc,hh}: Add / operators. Make that the usual way to use + bookkeeping_path's. + * work.cc: Adjust accordingly. + * lua.cc (working_copy_rcfilename): Likewise. + * commands.cc (update): Likewise. + +2005-08-23 Nathaniel Smith + * paths.{cc,hh} (operator <<): Implement for any_paths. * paths.hh (class bookkeeping_path): Note that current design is bogus to remind myself to fix it tomorrow... ======================================================================== --- commands.cc 94f4c9c04cf33f1d331b529ab7461d892b09dab2 +++ commands.cc 1a13b18406cd0813aca1644fba757b591ff6df5f @@ -2908,7 +2908,7 @@ remaining = chosen_to_merged; } - bookkeeping_path tmp_root("tmp"); + bookkeeping_path tmp_root = bookkeeping_root / "tmp"; if (directory_exists(tmp_root)) delete_dir_recursive(tmp_root); ======================================================================== --- lua.cc df6be5cd73a13e0917cc79b8df30144a10422e1c +++ lua.cc 7d6ce6d0a923bfe263b82b0254d0379a21c354a9 @@ -659,7 +659,7 @@ void lua_hooks::working_copy_rcfilename(bookkeeping_path & file) { - file = bookkeeping_path("monotonerc"); + file = bookkeeping_root / "monotonerc"; } ======================================================================== --- paths.cc f2fe69f3895760212a53333be292da4e6cef92c4 +++ paths.cc f756d2d0e4a70ba64f23a652923df12db757c501 @@ -448,7 +448,7 @@ static void check_bk_normalizes_to(char * before, char * after) { - BOOST_CHECK(book_keeping_file(before).as_external() == after); + BOOST_CHECK((bookkeeping_root / before).as_external() == after); } static void test_bookkeeping_path() @@ -457,7 +457,6 @@ "foo//bar", "foo/../bar", "../bar", - "MT/blah", "foo/bar/", "foo/./bar", "./foo", @@ -469,7 +468,10 @@ 0 }; for (char const ** c = baddies; *c; ++c) - BOOST_CHECK_THROW(book_keeping_path(internal, *c), logic_error); + { + BOOST_CHECK_THROW(bookkeeping_path(*c), logic_error); + BOOST_CHECK_THROW(bookkeeping_root / *c, logic_error); + } check_bk_normalizes_to("", "MT"); check_bk_normalizes_to("foo", "MT/foo"); ======================================================================== --- paths.hh e3af3c34d2cf32e279d86a64e1ce33e7093cd90f +++ paths.hh 94f4c5abfbd54d869aec02f69e9824108e119972 @@ -62,6 +62,8 @@ // join a file_path out of pieces file_path(std::vector const & pieces); + file_path operator /(std::string const & to_append); + // returns raw normalized path string // the string is always stored in normalized etc. form; so the generated // copy constructor and assignment operator are fine. @@ -83,15 +85,16 @@ class bookkeeping_path : public any_path { public: - // path should _not_ contain the leading MT/ + // path _should_ contain the leading MT/ // and _should_ look like an internal path - // FIXME: this^^ is bogus - // you can't poke around at subdirs of a tree! given MT/foo, you can't - // generate the path MT/foo/bar... + // usually you should just use the / operator as a constructor! bookkeeping_path(std::string const & path); std::string as_external() const; + bookkeeping_path operator /(std::string const & to_append); }; +extern bookkeeping_path const bookkeeping_root; + // this will always be an absolute path class system_path : public any_path { @@ -101,6 +104,7 @@ // monotone started in. it should be in utf8. system_path(std::string const & path); bool empty() const; + system_path operator /(std::string const & to_append); }; ======================================================================== --- work.cc cb95e0b012a5aa1f95fc1d3b4a3b8c95e5e913fe +++ work.cc 6aad7b52e0799c32f82169a1d7546c09a4444a4e @@ -312,7 +312,7 @@ static void get_work_path(bookkeeping_path & w_path) { - w_path = bookkeeping_path(work_file_name); + w_path = bookkeeping_root / work_file_name; L(F("work path is %s\n") % w_path); } @@ -366,7 +366,7 @@ static void get_revision_path(bookkeeping_path & m_path) { - m_path = bookkeeping_path(revision_file_name); + m_path = bookkeeping_root / revision_file_name; L(F("revision path is %s\n") % m_path); } @@ -446,7 +446,7 @@ void get_user_log_path(bookkeeping_path & ul_path) { - ul_path = bookkeeping_path(user_log_file_name); + ul_path = bookkeeping_root / user_log_file_name; L(F("user log path is %s\n") % ul_path); } @@ -495,7 +495,7 @@ void get_options_path(bookkeeping_path & o_path) { - o_path = bookkeeping_path(options_file_name); + o_path = bookkeeping_root / options_file_name; L(F("options path is %s\n") % o_path); } @@ -542,7 +542,7 @@ void get_local_dump_path(bookkeeping_path & d_path) { - d_path = bookkeeping_path(local_dump_file_name); + d_path = bookkeeping_root / local_dump_file_name; L(F("local dump path is %s\n") % d_path); } @@ -553,7 +553,7 @@ void get_inodeprints_path(bookkeeping_path & ip_path) { - ip_path = bookkeeping_path(inodeprints_file_name); + ip_path = bookkeeping_root / inodeprints_file_name; } bool