# # # patch "file_io.cc" # from [75b7e2bb594f959afb17378d571088ed11d588ee] # to [81e0e4bc3067116550da064c132e2d8b8b940851] # # patch "platform.hh" # from [0e346b8659597da7289519e5df1f0a886776b99d] # to [40f6b29812eafb8b7232263ccfabd4796b67a354] # # patch "po/de.po" # from [4cc17d78cc9617d92f9a61d95fba2acf7681a0f6] # to [cc00e7698c764398331f3c3f678257f66a804599] # # patch "po/es.po" # from [aaafe7152fd3108571de28db6774031fb5fcbe71] # to [f7729728e21b132d249d8195978435a3c287903b] # # patch "po/fr.po" # from [a187c12095cacad2ad77b889e11f566c6e52b654] # to [fe603c27155c0a9113d6ae77b47113021d45e4ed] # # patch "po/it.po" # from [f839f2c34f741a306acc8c0ed9be4d00dbb32a29] # to [cc886147cd271ef32e3212545f3991a6fecd5d13] # # patch "po/ja.po" # from [b2d342cfdad23bc57acf7f51d5344e2cbd4068cd] # to [526b63d8f7d9731e577862a72d25e2c88d465d56] # # patch "po/pt_BR.po" # from [bb5e047e34a97fcddd965177827af75ef3cbc559] # to [ca16df9443f2191f87dbd37e414897edf81865ca] # # patch "po/sv.po" # from [8f31e4853dd350d025abf6c1fd934ce23a1f3439] # to [62c7595d3bd714b0833aeac8a9d5b963271ce111] # # patch "unix/fs.cc" # from [01f02a8c225f793ed279763ae048ad3d7cec4782] # to [50d2d4f37eb345a3f0a3ace3a00ec8adc3eda4d5] # # patch "win32/fs.cc" # from [5db737615ca0b21af0f2d62d3c05dc96783d4901] # to [0217f9579af7c234408ac3749be7f59308983a2c] # ============================================================ --- file_io.cc 75b7e2bb594f959afb17378d571088ed11d588ee +++ file_io.cc 81e0e4bc3067116550da064c132e2d8b8b940851 @@ -223,29 +223,13 @@ make_dir_for(any_path const & p) } } -static void -do_shallow_deletion_with_sane_error_message(any_path const & p) -{ - fs::path fp = mkdir(p); - try - { - fs::remove(fp); - } - catch (FS_ERROR & err) - { - E(false, F("could not remove '%s'\n%s") - % err.path1().native_directory_string() - % os_strerror(err.FS_ERROR_SYSTEM())); - } -} - void delete_file(any_path const & p) { require_path_is_file(p, F("file to delete '%s' does not exist") % p, F("file to delete, '%s', is not a file but a directory") % p); - do_shallow_deletion_with_sane_error_message(p); + do_remove(p.as_external()); } void @@ -254,14 +238,14 @@ delete_dir_shallow(any_path const & p) require_path_is_directory(p, F("directory to delete '%s' does not exist") % p, F("directory to delete, '%s', is not a directory but a file") % p); - do_shallow_deletion_with_sane_error_message(p); + do_remove(p.as_external()); } void delete_file_or_dir_shallow(any_path const & p) { N(path_exists(p), F("object to delete, '%s', does not exist") % p); - do_shallow_deletion_with_sane_error_message(p); + do_remove(p.as_external()); } void @@ -282,8 +266,9 @@ move_file(any_path const & old_path, F("rename source file '%s' is a directory " "-- bug in monotone?") % old_path); require_path_is_nonexistent(new_path, - F("rename target '%s' already exists") % new_path); - fs::rename(mkdir(old_path), mkdir(new_path)); + F("rename target '%s' already exists") + % new_path); + rename_clobberingly(old_path.as_external(), new_path.as_external()); } void @@ -291,30 +276,26 @@ move_dir(any_path const & old_path, any_path const & new_path) { require_path_is_directory(old_path, - F("rename source dir '%s' does not exist") % old_path, + F("rename source dir '%s' does not exist") + % old_path, F("rename source dir '%s' is a file " "-- bug in monotone?") % old_path); require_path_is_nonexistent(new_path, - F("rename target '%s' already exists") % new_path); - fs::rename(mkdir(old_path), mkdir(new_path)); + F("rename target '%s' already exists") + % new_path); + rename_clobberingly(old_path.as_external(), new_path.as_external()); } 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; - } + N(path_exists(old_path), + F("rename source path '%s' does not exist") % old_path); + require_path_is_nonexistent(new_path, + F("rename target '%s' already exists") + % new_path); + rename_clobberingly(old_path.as_external(), new_path.as_external()); } void ============================================================ --- platform.hh 0e346b8659597da7289519e5df1f0a886776b99d +++ platform.hh 40f6b29812eafb8b7232263ccfabd4796b67a354 @@ -119,6 +119,8 @@ void rename_clobberingly(std::string con path::status get_path_status(std::string const & path); void rename_clobberingly(std::string const & from, std::string const & to); +void do_remove(std::string const & path); + void write_data_worker(std::string const & p, std::string const & dat, std::string const & tmpdir, ============================================================ --- po/de.po 4cc17d78cc9617d92f9a61d95fba2acf7681a0f6 +++ po/de.po cc00e7698c764398331f3c3f678257f66a804599 @@ -3093,14 +3093,10 @@ msgstr "konnte Verzeichnis '%s' für '%s msgid "failed to create directory '%s' for '%s'" msgstr "konnte Verzeichnis '%s' für '%s' nicht erstellen" -#: file_io.cc:235 +#: unix/fs.cc:135 win32/fs.cc:164 #, c-format -msgid "" -"could not remove '%s'\n" -"%s" -msgstr "" -"konnte '%s' nicht entfernen\n" -"%s" +msgid "could not remove '%s': %s" +msgstr "konnte '%s' nicht entfernen: %s" #: file_io.cc:245 #, c-format ============================================================ --- po/es.po aaafe7152fd3108571de28db6774031fb5fcbe71 +++ po/es.po f7729728e21b132d249d8195978435a3c287903b @@ -3084,14 +3084,10 @@ msgstr "creación de directorio '%s' par msgid "failed to create directory '%s' for '%s'" msgstr "creación de directorio '%s' para '%s' falló" -#: file_io.cc:235 +#: unix/fs.cc:135 win32/fs.cc:164 #, c-format -msgid "" -"could not remove '%s'\n" -"%s" -msgstr "" -"no se pudo remover '%s'\n" -"%s" +msgid "could not remove '%s': %s" +msgstr "no se pudo remover '%s': %s" #: file_io.cc:245 #, c-format ============================================================ --- po/fr.po a187c12095cacad2ad77b889e11f566c6e52b654 +++ po/fr.po fe603c27155c0a9113d6ae77b47113021d45e4ed @@ -3862,14 +3862,10 @@ msgstr "impossible de créer le dossier msgid "failed to create directory '%s' for '%s'" msgstr "impossible de créer le dossier « %s » pour « %s »" -#: ../file_io.cc:238 +#: unix/fs.cc:135 win32/fs.cc:164 #, c-format -msgid "" -"could not remove '%s'\n" -"%s" -msgstr "" -"impossible de supprimer « %s »\n" -"%s" +msgid "could not remove '%s': %s" +msgstr "impossible de supprimer « %s »: %s" #: ../file_io.cc:248 #, c-format ============================================================ --- po/it.po f839f2c34f741a306acc8c0ed9be4d00dbb32a29 +++ po/it.po cc886147cd271ef32e3212545f3991a6fecd5d13 @@ -2658,14 +2658,10 @@ msgstr "fallita la creazione della direc msgid "failed to create directory '%s' for '%s'" msgstr "fallita la creazione della directory‘%s’ per ‘%s’" -#: file_io.cc:238 +#: unix/fs.cc:135 win32/fs.cc:164 #, c-format -msgid "" -"could not remove '%s'\n" -"%s" -msgstr "" -"non posso cancellare ‘%s’\n" -"%s" +msgid "could not remove '%s': %s" +msgstr "non posso cancellare ‘%s’: %s" #: file_io.cc:248 #, c-format ============================================================ --- po/ja.po b2d342cfdad23bc57acf7f51d5344e2cbd4068cd +++ po/ja.po 526b63d8f7d9731e577862a72d25e2c88d465d56 @@ -2295,14 +2295,10 @@ msgstr "ディレクトリ '%s' ('%s' だmsgid "failed to create directory '%s' for '%s'" msgstr "ディレクトリ '%s' ('%s' のための)の作成に失敗しました" -#: file_io.cc:227 +#: unix/fs.cc:135 win32/fs.cc:164 #, c-format -msgid "" -"could not remove '%s'\n" -"%s" -msgstr "" -"'%s' を削除できませんでした\n" -"%s" +msgid "could not remove '%s': %s" +msgstr "'%s' を削除できませんでした: %s" #: file_io.cc:237 #, c-format ============================================================ --- po/pt_BR.po bb5e047e34a97fcddd965177827af75ef3cbc559 +++ po/pt_BR.po ca16df9443f2191f87dbd37e414897edf81865ca @@ -3050,14 +3050,10 @@ msgstr "falha criando diretório '%s' pa msgid "failed to create directory '%s' for '%s'" msgstr "falha criando diretório '%s' para '%s'" -#: file_io.cc:235 +#: unix/fs.cc:135 win32/fs.cc:164 #, c-format -msgid "" -"could not remove '%s'\n" -"%s" -msgstr "" -"impossível remover '%s'\n" -"%s" +msgid "could not remove '%s': %s" +msgstr "impossível remover '%s': %s" #: file_io.cc:245 #, c-format ============================================================ --- po/sv.po 8f31e4853dd350d025abf6c1fd934ce23a1f3439 +++ po/sv.po 62c7595d3bd714b0833aeac8a9d5b963271ce111 @@ -3129,14 +3129,10 @@ msgstr "misslyckades med att skapa katal msgid "failed to create directory '%s' for '%s'" msgstr "misslyckades med att skapa katalogen '%s' för '%s'" -#: file_io.cc:236 +#: unix/fs.cc:135 win32/fs.cc:164 #, c-format -msgid "" -"could not remove '%s'\n" -"%s" -msgstr "" -"kunde inte ta bort '%s'\n" -"%s" +msgid "could not remove '%s': %s" +msgstr "kunde inte ta bort '%s': %s" #: file_io.cc:246 #, c-format ============================================================ --- unix/fs.cc 01f02a8c225f793ed279763ae048ad3d7cec4782 +++ unix/fs.cc 50d2d4f37eb345a3f0a3ace3a00ec8adc3eda4d5 @@ -126,6 +126,15 @@ rename_clobberingly(string const & from, F("renaming '%s' to '%s' failed: %s") % from % to % os_strerror(errno)); } +// the C90 remove() function is guaranteed to work for both files and +// directories +void +do_remove(string const & path) +{ + E(!remove(path.c_str()), + F("could not remove '%s': %s") % path % os_strerror(errno)); +} + // Create a temporary file in directory DIR, writing its name to NAME and // returning a read-write file descriptor for it. If unable to create // the file, throws an E(). ============================================================ --- win32/fs.cc 5db737615ca0b21af0f2d62d3c05dc96783d4901 +++ win32/fs.cc 0217f9579af7c234408ac3749be7f59308983a2c @@ -141,6 +141,29 @@ get_path_status(std::string const & path return path::file; } +void +do_remove(std::string const & path) +{ + switch (get_path_status(path)) + { + case path::directory: + if (RemoveDirectoryA(path.c_str())) + return; + break; + case path::file: + if (DeleteFileA(path.c_str())) + return; + break; + case path::nonexistent: + // conveniently, GetLastError() will report the error code from + // the GetFileAttributes() call in get_path_status() that told us + // the path doesn't exist. + break; + } + E(false, + F("could not remove '%s': %s") % path % os_strerror(GetLastError())); +} + static bool rename_clobberingly_impl(const char * from, const char * to) {