# # patch "ChangeLog" # from [96dd65742310dcf51d37080a0823a32ac1474b4f] # to [c9f00ad8af9986dbd86124b169421e8c7d4145ac] # # patch "app_state.cc" # from [b07a5acad697fc9899d5a36ca5d41645175267ee] # to [bcf96fe6db7b0183e53718428f47af327fa7f321] # # patch "app_state.hh" # from [bb2b7351c3e150113223e8a5e2b14840d0381f0c] # to [fc53f363021e695db235d825daf4ae6506f7142b] # # patch "file_io.cc" # from [548d122b7de1dda7d5d0f45e9ae3ba0d82cb4d17] # to [68a03f78673d99799fbe6bb6aed82506f197453b] # # patch "file_io.hh" # from [eeb9bf17b3e142348bcacffee768fb75ee9a4241] # to [eab3db8560596948de644e9b8d94108ac5db39e7] # # patch "paths.cc" # from [aacb901db1e345dafc6e6426f4890710f6fb1650] # to [0053686b877a4ce73f9fddbbe86d6ae2752bf701] # ======================================================================== --- ChangeLog 96dd65742310dcf51d37080a0823a32ac1474b4f +++ ChangeLog c9f00ad8af9986dbd86124b169421e8c7d4145ac @@ -1,5 +1,12 @@ 2005-08-24 Nathaniel Smith + * paths.cc (find_and_go_to_working_copy): Implement. + * app_state.cc (allow_working_copy): Adjust accordingly. + (relative_directory): Remove. + * file_io.cc (find_working_copy): Remove. + +2005-08-24 Nathaniel Smith + * paths.cc (save_initial_path): Update for previous changes. 2005-08-24 Nathaniel Smith ======================================================================== --- app_state.cc b07a5acad697fc9899d5a36ca5d41645175267ee +++ app_state.cc bcf96fe6db7b0183e53718428f47af327fa7f321 @@ -48,18 +48,11 @@ void app_state::allow_working_copy() { - fs::path root = mkpath(search_root.as_external()); - fs::path working; - fs::path current; + found_working_copy = find_and_go_to_working_copy(root); - found_working_copy = find_working_copy(root, working, current); - if (found_working_copy) { L(F("initializing from directory %s\n") % fs::initial_path().string()); - L(F("found working copy directory %s\n") % working.string()); - N(chdir(working.native_directory_string().c_str()) != -1, - F("cannot change to directory to %s\n") % working.native_directory_string()); read_options(); @@ -70,12 +63,6 @@ L(F("branch name is '%s'\n") % branch_name()); internalize_rsa_keypair_id(options[key_option], signing_key); - if (!current.empty()) - { - relative_directory = file_path_internal(current.string()); - L(F("relative directory is '%s'\n") % relative_directory); - } - if (global_sanity.filename.empty()) { bookkeeping_path dump_path; @@ -123,8 +110,6 @@ % strerror(err.native_error())); } change_current_working_dir(new_dir); - - relative_directory = file_path(); } N(!directory_exists(bookkeeping_root), ======================================================================== --- app_state.hh bb2b7351c3e150113223e8a5e2b14840d0381f0c +++ app_state.hh fc53f363021e695db235d825daf4ae6506f7142b @@ -50,7 +50,6 @@ std::set exclude_patterns; std::vector extra_rcfiles; path_set restrictions; - file_path relative_directory; bool found_working_copy; long depth; long last; ======================================================================== --- file_io.cc 548d122b7de1dda7d5d0f45e9ae3ba0d82cb4d17 +++ file_io.cc 68a03f78673d99799fbe6bb6aed82506f197453b @@ -31,65 +31,6 @@ #endif #include -bool -find_working_copy(fs::path const & search_root, - fs::path & working_copy_root, - fs::path & working_copy_restriction) -{ - fs::path bookdir = mkpath(book_keeping_dir); - fs::path current = fs::initial_path(); - fs::path removed; - fs::path check = current / bookdir; - - L(F("searching for '%s' directory with root '%s'\n") - % bookdir.string() - % search_root.string()); - - // nb: boost 1.32.0 has added operations::equivalent(path1, path2) - // and ==, !=, ... on paths which are probably better than - // native_directory_string comparisons used here temporarily - - while ( current.native_directory_string() - != search_root.native_directory_string() && - current.has_branch_path() && - current.has_leaf() && - !fs::exists(check)) - { - L(F("'%s' not found in '%s' with '%s' removed\n") - % bookdir.string() % current.string() % removed.string()); - removed = mkpath(current.leaf()) / removed; - current = current.branch_path(); - check = current / bookdir; - } - - L(F("search for '%s' ended at '%s' with '%s' removed\n") - % book_keeping_dir % current.string() % removed.string()); - - if (!fs::exists(check)) - { - L(F("'%s' does not exist\n") % check.string()); - return false; - } - - if (!fs::is_directory(check)) - { - L(F("'%s' is not a directory\n") % check.string()); - return false; - } - - // check for MT/. and MT/.. to see if mt dir is readable - if (!fs::exists(check / ".") || !fs::exists(check / "..")) - { - L(F("problems with '%s' (missing '.' or '..')\n") % check.string()); - return false; - } - - working_copy_root = current; - working_copy_restriction = removed; - - return true; -} - string get_homedir() { ======================================================================== --- file_io.hh eeb9bf17b3e142348bcacffee768fb75ee9a4241 +++ file_io.hh eab3db8560596948de644e9b8d94108ac5db39e7 @@ -40,10 +40,6 @@ struct lua_hooks; -bool find_working_copy(fs::path const & search_root, - fs::path & working_copy_root, - fs::path & working_copy_restriction); - system_path get_homedir(); // use I() ======================================================================== --- paths.cc aacb901db1e345dafc6e6426f4890710f6fb1650 +++ paths.cc 0053686b877a4ce73f9fddbbe86d6ae2752bf701 @@ -31,7 +31,8 @@ { // FIXME: BUG: this only works if the current working dir is in utf8 initial_abs_path = system_path(get_current_working_dir()); - L(F("initial path is: %s") % initial_path); + fs::initial_path(); + L(F("initial abs path is: %s") % initial_path); } // path to prepend to external files, to convert them from pointing to the @@ -48,15 +49,58 @@ find_and_go_to_working_copy(system_path const & search_root) { // unimplemented - + fs::path bookdir = bookkeeping_root.as_external(); + fs::path current = fs::initial_path(); + fs::path removed; + fs::path check = current / bookdir; + L(F("searching for '%s' directory with root '%s'\n") + % bookdir.string() + % search_root.string()); - // should do what find_working_copy in file_io.cc does, and what - // allow_working_copy in app_state.cc does - // should use change_current_working_dir when it finds the root + while (current != search_root + && current.has_branch_path() + && current.has_leaf() + && !fs::exists(check)) + { + L(F("'%s' not found in '%s' with '%s' removed\n") + % bookdir.string() % current.string() % removed.string()); + removed = mkpath(current.leaf()) / removed; + current = current.branch_path(); + check = current / bookdir; + } - // should set initial_rel_path and working_root - I(false); + L(F("search for '%s' ended at '%s' with '%s' removed\n") + % book_keeping_dir % current.string() % removed.string()); + + if (!fs::exists(check)) + { + L(F("'%s' does not exist\n") % check.string()); + return false; + } + + if (!fs::is_directory(check)) + { + L(F("'%s' is not a directory\n") % check.string()); + return false; + } + + // check for MT/. and MT/.. to see if mt dir is readable + if (!fs::exists(check / ".") || !fs::exists(check / "..")) + { + L(F("problems with '%s' (missing '.' or '..')\n") % check.string()); + return false; + } + + working_root = current.as_native_path_string(); + initial_rel_path = file_path_internal(removed.string()); + + L(F("working root is '%s'") % working_root); + L(F("initial relative path is '%s'") % initial_rel_path); + + change_current_working_dir(working_root); + + return true; } static bool