# # patch "ChangeLog" # from [008ede6e8563b4eb5a49cc9bbb31e79d6471674d] # to [5b9df326a0e2ac3a7134c69b343b8d11fa6fc46f] # # patch "change_set.cc" # from [cf191c5853014ae777ac96699fff4c7af62ff6ed] # to [bada5f463160416ae9d699d8b13439ee525fb9cf] # # patch "database.cc" # from [7109cafc0dfce162176738368f269e18cb5cb4e6] # to [4d7dd8ca20b92ba5cb698e7243253680b11361f8] # # patch "file_io.cc" # from [94d9dfc17ae1f1b7a6218d25c24321635a57b236] # to [1becb609e61b68d6d725f5a11c63b2c4458bd982] # # patch "file_io.hh" # from [e64e0d786937f6cc2a4c1fff6f16bc1285bec0b0] # to [ab9e06dc35f05faf745e614c449c14a540e82f68] # # patch "work.cc" # from [92c6e4b39c6d2074307a9292f87ec686a1d9be0a] # to [6fb35059bed115c419e249065b4d662109d89118] # ======================================================================== --- ChangeLog 008ede6e8563b4eb5a49cc9bbb31e79d6471674d +++ ChangeLog 5b9df326a0e2ac3a7134c69b343b8d11fa6fc46f @@ -1,5 +1,18 @@ 2005-08-26 Nathaniel Smith + * change_set.cc (move_files_from_tmp_top_down): Typo. + + * file_io.cc (move_path): New function. + (move_file, move_dir): Minor cleanup -- use + require_path_is_nonexistent. + + * work.cc (build_deletions): Use delete_file, rather than unlink. + If file is already non-existent, do nothing. + (build_rename): Use move_path, rather than rename. If file + already appears to have been renamed, do nothing. + +2005-08-26 Nathaniel Smith + * app_state.cc (allow_working_copy): Make logging more sensible. 2005-08-26 Nathaniel Smith ======================================================================== --- change_set.cc cf191c5853014ae777ac96699fff4c7af62ff6ed +++ change_set.cc bada5f463160416ae9d699d8b13439ee525fb9cf @@ -2494,7 +2494,7 @@ { P(F("moving file %s -> %s\n") % src % dst); make_dir_for(dst); - move_file(src, dist); + move_file(src, dst); } break; case ptype_directory: ======================================================================== --- database.cc 7109cafc0dfce162176738368f269e18cb5cb4e6 +++ database.cc 4d7dd8ca20b92ba5cb698e7243253680b11361f8 @@ -193,8 +193,6 @@ if (! init) { - N(fs::exists(filename), - N(!fs::is_directory(filename), require_path_is_file(filename, F("database %s does not exist") % filename, F("database %s is a directory") % filename); ======================================================================== --- file_io.cc 94d9dfc17ae1f1b7a6218d25c24321635a57b236 +++ file_io.cc 1becb609e61b68d6d725f5a11c63b2c4458bd982 @@ -182,8 +182,8 @@ F("rename source file '%s' does not exist") % old_path, F("rename source file '%s' is a directory " "-- bug in monotone?") % old_path); - N(!path_exists(new_path), - F("rename target '%s' already exists") % new_path); + require_path_is_nonexistent(new_path, + F("rename target '%s' already exists") % new_path); fs::rename(mkdir(old_path), mkdir(new_path)); } @@ -195,11 +195,29 @@ F("rename source dir '%s' does not exist") % old_path, F("rename source dir '%s' is a file " "-- bug in monotone?") % old_path); - N(!path_exists(new_path), - F("rename target '%s' already exists") % new_path); + require_path_is_nonexistent(new_path, + F("rename target '%s' already exists") % new_path); fs::rename(mkdir(old_path), mkdir(new_path)); } +void +move_path(any_path const & old_path, + any_path const & new_path) +{ + switch (get_path_status(old_path)) + { + case path::nonexistent: + N(false, F("rename source path '%s' does not exist") % old_path); + break; + case path::file: + move_file(old_path, new_path); + break; + case path::directory: + move_dir(old_path, new_path); + break; + } +} + void read_data(any_path const & p, data & dat) { ======================================================================== --- file_io.hh e64e0d786937f6cc2a4c1fff6f16bc1285bec0b0 +++ file_io.hh ab9e06dc35f05faf745e614c449c14a540e82f68 @@ -81,6 +81,10 @@ void move_dir(any_path const & old_path, any_path const & new_path); +// calls move_file or move_dir as appropriate +void move_path(any_path const & old_path, + any_path const & new_path); + void read_data(any_path const & path, data & data); void read_localized_data(file_path const & path, data & dat, ======================================================================== --- work.cc 92c6e4b39c6d2074307a9292f87ec686a1d9be0a +++ work.cc 6fb35059bed115c419e249065b4d662109d89118 @@ -226,11 +226,8 @@ updated_attr_map = true; P(F("dropped attributes for file %s from %s\n") % (*i) % attr_file_name); } - if (app.execute) - { - N(unlink((*i)().c_str()) == 0, - F("Can't remove %s: %s\n") % (*i) % strerror(errno)); - } + if (app.execute && path_exists(*i)) + delete_file(*i); } } @@ -276,11 +273,8 @@ else pr_new.renamed_files.insert(std::make_pair(src, dst)); - if (app.execute) - { - N(rename(src().c_str(), dst().c_str()) == 0, - F("Can't rename %s to %s: %s\n") % src % dst % strerror(errno)); - } + if (app.execute && (path_exists(src) || !path_exists(dst))) + move_path(src, dst); // read attribute map if available file_path attr_path;