# # patch "ChangeLog" # from [c9f00ad8af9986dbd86124b169421e8c7d4145ac] # to [4ddcd1baf4e3f7be5e2e1d991c79c0d7248dfec5] # # patch "app_state.cc" # from [bcf96fe6db7b0183e53718428f47af327fa7f321] # to [213f36c8fef19703e626abf320c071df7f11279f] # # patch "app_state.hh" # from [fc53f363021e695db235d825daf4ae6506f7142b] # to [65fc91f19523f82ddbfa7128bd05d4a6dbc670c9] # # patch "paths.cc" # from [0053686b877a4ce73f9fddbbe86d6ae2752bf701] # to [06bd666d0e0db5b0cfdfa78983e61e3a1a3e4da7] # # patch "paths.hh" # from [a3e798a2c2c69a8d12c98374973d0ac4f6a91b84] # to [65fe38f882aa870f80172d5ca3deb33ffa1613a4] # ======================================================================== --- ChangeLog c9f00ad8af9986dbd86124b169421e8c7d4145ac +++ ChangeLog 4ddcd1baf4e3f7be5e2e1d991c79c0d7248dfec5 @@ -1,5 +1,10 @@ 2005-08-24 Nathaniel Smith + * paths.cc (go_to_working_copy): New function. Implement. + * app_state.cc (create_working_copy): Adjust accordingly. + +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. ======================================================================== --- app_state.cc bcf96fe6db7b0183e53718428f47af327fa7f321 +++ app_state.cc 213f36c8fef19703e626abf320c071df7f11279f @@ -48,7 +48,7 @@ void app_state::allow_working_copy() { - found_working_copy = find_and_go_to_working_copy(root); + found_working_copy = find_and_go_to_working_copy(search_root); if (found_working_copy) { @@ -57,7 +57,7 @@ read_options(); system_path dbname = system_path(options[database_option]); - if (!dbname.empty()) db.set_filename(mkpath(dbname)); + if (!dbname.empty()) db.set_filename(dbname); if (branch_name().empty()) branch_name = options[branch_option]; L(F("branch name is '%s'\n") % branch_name()); @@ -84,20 +84,13 @@ } void -app_state::create_working_copy(std::string const & dir) +app_state::create_working_copy(system_path const & new_dir) { - N(dir.size(), F("invalid directory ''")); + N(!new_dir.empty(), F("invalid directory ''")); - // cd back to where we started from - N(chdir(fs::initial_path().native_directory_string().c_str()) != -1, - F("cannot change to initial directory %s\n") - % fs::initial_path().native_directory_string()); - - string target = absolutify(dir); - L(F("create working copy in %s\n") % target); + L(F("creating working copy in %s\n") % new_dir); { - system_path new_dir(target); try { mkdir_p(new_dir); @@ -109,15 +102,15 @@ % err.path1().native_directory_string() % strerror(err.native_error())); } - change_current_working_dir(new_dir); } + go_to_working_copy(new_dir); N(!directory_exists(bookkeeping_root), - F("monotone book-keeping directory '%s' already exists in '%s'\n") - % bookkeeping_root % target); + F("monotone bookkeeping directory '%s' already exists in '%s'\n") + % bookkeeping_root % new_dir); - L(F("creating book-keeping directory '%s' for working copy in '%s'\n") - % bookkeeping_root % target); + L(F("creating bookkeeping directory '%s' for working copy in '%s'\n") + % bookkeeping_root % new_dir); mkdir_p(bookkeeping_root); ======================================================================== --- app_state.hh fc53f363021e695db235d825daf4ae6506f7142b +++ app_state.hh 65fc91f19523f82ddbfa7128bd05d4a6dbc670c9 @@ -73,7 +73,7 @@ void allow_working_copy(); void require_working_copy(std::string const & explanation = ""); - void create_working_copy(std::string const & dir); + void create_working_copy(system_path const & dir); void app_state::set_restriction(path_set const & valid_paths, std::vector const & paths, ======================================================================== --- paths.cc 0053686b877a4ce73f9fddbbe86d6ae2752bf701 +++ paths.cc 06bd666d0e0db5b0cfdfa78983e61e3a1a3e4da7 @@ -103,6 +103,14 @@ return true; } +void +go_to_working_copy(system_path const & new_working_copy) +{ + working_root = new_working_copy; + initial_rel_path = file_dir(); + change_current_working_dir(new_working_copy); +} + static bool is_absolute(std::string const & path) { ======================================================================== --- paths.hh a3e798a2c2c69a8d12c98374973d0ac4f6a91b84 +++ paths.hh 65fe38f882aa870f80172d5ca3deb33ffa1613a4 @@ -130,4 +130,9 @@ bool find_and_go_to_working_copy(system_path const & search_root); +// this is like change_current_working_dir, but also initializes the various +// root paths that are needed to interpret paths +void +go_to_working_copy(system_path const & new_working_copy); + #endif