#
# add_file "tests/t_setup_existing_path.at"
#
# patch "ChangeLog"
# from [582662f010ba6296805e042d56073dee74f2157d]
# to [cc41b9fb9a5fe98fb1b9337fe913a75d760a89d8]
#
# patch "commands.cc"
# from [2ecf17e9af453dfeefb1373b837142e57a3479a7]
# to [96ab0962d109727273cf22e001dae3f65df3b9bb]
#
# patch "file_io.cc"
# from [1becb609e61b68d6d725f5a11c63b2c4458bd982]
# to [a887c87104212bab175b54ec1ceb1fa5153024e5]
#
# patch "tests/t_checkout_dir.at"
# from [1b35d4f082c692506c02ccf8fa79e5bac95805a5]
# to [98e7c88da741590079b68cbbf44041a628315739]
#
# patch "tests/t_setup_existing_path.at"
# from []
# to [65ed903effa04ed5e70989bf0bfd4b1938e6878f]
#
# patch "testsuite.at"
# from [6793ac5be3d28a0c6c3f1d3c616dc38ae01db618]
# to [3069578e5268491a6c837912613346860e6f7ea5]
#
========================================================================
--- ChangeLog 582662f010ba6296805e042d56073dee74f2157d
+++ ChangeLog cc41b9fb9a5fe98fb1b9337fe913a75d760a89d8
@@ -1,5 +1,13 @@
2005-08-26 Nathaniel Smith
+ * file_io.cc (mkdir_p, make_dir_for): Increase error checking.
+ * commands.cc (checkout): Make sure that checkout target directory
+ does not already exist. Also use system_path more uniformly.
+ * tests/t_checkout_dir.at: Test.
+ * tests/t_setup_existing_path.at: New test.
+
+2005-08-26 Nathaniel Smith
+
* commands.cc (read): Optionally take files on command line.
* tests/t_read_from_file.at, testsuite.at: New test.
* monotone.texi (Network Service): Show Jim using this.
========================================================================
--- commands.cc 2ecf17e9af453dfeefb1373b837142e57a3479a7
+++ commands.cc 96ab0962d109727273cf22e001dae3f65df3b9bb
@@ -1415,7 +1415,7 @@
OPT_BRANCH_NAME % OPT_REVISION)
{
revision_id ident;
- string dir;
+ system_path dir;
if (args.size() > 1 || app.revision_selectors.size() > 1)
throw usage(name);
@@ -1424,12 +1424,12 @@
{
// no checkout dir specified, use branch name for dir
N(!app.branch_name().empty(), F("need --branch argument for branch-based checkout"));
- dir = app.branch_name();
+ dir = system_path(app.branch_name());
}
else
{
// checkout to specified dir
- dir = idx(args, 0)();
+ dir = system_path(idx(args, 0));
}
if (app.revision_selectors.size() == 0)
@@ -1469,6 +1469,9 @@
% ident % app.branch_name);
}
+ require_path_is_nonexistent(dir,
+ F("checkout directory '%s' already exists")
+ % dir);
app.create_working_copy(dir);
transaction_guard guard(app.db);
========================================================================
--- file_io.cc 1becb609e61b68d6d725f5a11c63b2c4458bd982
+++ file_io.cc a887c87104212bab175b54ec1ceb1fa5153024e5
@@ -8,6 +8,7 @@
#include
#include
#include
+#include
#include "botan/botan.h"
@@ -143,7 +144,23 @@
void
mkdir_p(any_path const & p)
{
- fs::create_directories(mkdir(p));
+ try
+ {
+ fs::create_directories(mkdir(p));
+ }
+ catch (fs::filesystem_error & err)
+ {
+ // check for this case first, because in this case, the next line will
+ // print "could not create directory: Success". Which is unhelpful.
+ E(get_path_status(p) != path::file,
+ F("could not create directory '%s'\nit is a file") % p);
+ E(false,
+ F("could not create directory '%s'\n%s")
+ % err.path1().native_directory_string() % strerror(err.native_error()));
+ }
+ require_path_is_directory(p,
+ F("could not create directory '%s'") % p,
+ F("could not create directory '%s'\nit is a file") % p);
}
void
@@ -152,7 +169,10 @@
fs::path tmp(p.as_external(), fs::native);
if (tmp.has_branch_path())
{
- fs::create_directories(tmp.branch_path());
+ fs::path dir = tmp.branch_path();
+ fs::create_directories(dir);
+ N(fs::exists(dir) && fs::is_directory(dir),
+ F("failed to create directory '%s' for '%s'") % dir.string() % p);
}
}
========================================================================
--- tests/t_checkout_dir.at 1b35d4f082c692506c02ccf8fa79e5bac95805a5
+++ tests/t_checkout_dir.at 98e7c88da741590079b68cbbf44041a628315739
@@ -14,15 +14,19 @@
[1], [ignore], [ignore])
mkdir test_dir3
-chmod 444 test_dir3
+AT_CHECK(MONOTONE --branch=testbranch checkout test_dir3,
+ [1], [ignore], [ignore])
+
+mkdir test_dir4
+chmod 444 test_dir4
# XFAIL if run as root (hi Gentoo!)
AT_XFAIL_IF(test -O /)
-AT_CHECK(MONOTONE --branch=testbranch checkout test_dir3,
+AT_CHECK(MONOTONE --branch=testbranch checkout test_dir4,
[1], [ignore], [ignore])
-AT_CHECK(MONOTONE --branch=testbranch checkout test_dir3/subdir,
+AT_CHECK(MONOTONE --branch=testbranch checkout test_dir4/subdir,
[1], [ignore], [ignore])
# Reset the permissions so Autotest can correctly clean up our
# temporary directory.
-chmod 700 test_dir3
+chmod 700 test_dir4
AT_CLEANUP
========================================================================
--- tests/t_setup_existing_path.at
+++ tests/t_setup_existing_path.at 65ed903effa04ed5e70989bf0bfd4b1938e6878f
@@ -0,0 +1,11 @@
+AT_SETUP([setup on existing path])
+MONOTONE_SETUP
+
+AT_DATA(foo, [blah blah
+])
+AT_CHECK(MONOTONE setup foo, [1], [ignore], [ignore])
+AT_CHECK(mkdir bar)
+AT_CHECK(MONOTONE setup bar, [], [ignore], [ignore])
+AT_CHECK(test -d bar/MT)
+
+AT_CLEANUP
========================================================================
--- testsuite.at 6793ac5be3d28a0c6c3f1d3c616dc38ae01db618
+++ testsuite.at 3069578e5268491a6c837912613346860e6f7ea5
@@ -697,3 +697,4 @@
m4_include(tests/t_drop_execute.at)
m4_include(tests/t_rename_execute.at)
m4_include(tests/t_read_from_file.at)
+m4_include(tests/t_setup_existing_path.at)