# # add_file "tests/t_diff_changeset_bug.at" # # add_file "tests/t_diff_outside_working_dir.at" # # add_file "tests/t_log_outside_working_dir.at" # # patch "ChangeLog" # from [6aae9a37db052ff5ffdb7b1b52548b28a08a5269] # to [1a2f2785043c87d6a0f1af2d807cb0d598655158] # # patch "commands.cc" # from [d04179187700889eee2af3e4e6ada1ffad5e7317] # to [889b85e8285c01cbd3cfecfecc5b2d687f9cdcd3] # # patch "paths.cc" # from [4e5102ee894c9a36efca874f1566b7f021b01069] # to [4ef0ae40dcb0c3edf9edbcf939bca52a34818cd2] # # patch "paths.hh" # from [6a40d74b6c578436c71a44a123ab7f8553404ba0] # to [b019e9708f84baea6625e9554f0d79969dd18051] # # patch "tests/t_diff_changeset_bug.at" # from [] # to [f2a49720200bcc77fcc581f5b6c39e82fcb1e828] # # patch "tests/t_diff_outside_working_dir.at" # from [] # to [68e1ab2a3186b905dc91af7814cb0dc10594bb3f] # # patch "tests/t_log_outside_working_dir.at" # from [] # to [394e25f09b80a55cd58f3e9f2e8474a4568b5624] # # patch "testsuite.at" # from [0d3e0effc051db81bd3de638ca542d358ddb8dc9] # to [5a310950bc3461a4c22892c145cd7ff321b911c7] # ======================================================================== --- ChangeLog 6aae9a37db052ff5ffdb7b1b52548b28a08a5269 +++ ChangeLog 1a2f2785043c87d6a0f1af2d807cb0d598655158 @@ -1,5 +1,19 @@ 2005-09-30 Grahame Bowland + * paths.hh: update file_path documentation, + remove file_path_internal_from_user + * paths.cc: remove file_path_internal_from_user + * commands.cc CMD(cat): change file_path_internal_from_user + to file_path_external + * tests/t_diff_outside_working_dir.at: check diff works outside + of a working dir (with a file specified) + * tests/t_log_outside_working_dir.at: check log works outside + of a working dir (with a file specified) + * tests/t_diff_changeset_bug.at: mysterious changeset bug + * testsuite.at: add new tests + +2005-09-30 Grahame Bowland + * paths.cc (file_path::file_path): Allow external paths outside of a working directory, so long as we don't enter a working directory later. ======================================================================== --- commands.cc d04179187700889eee2af3e4e6ada1ffad5e7317 +++ commands.cc 889b85e8285c01cbd3cfecfecc5b2d687f9cdcd3 @@ -1319,10 +1319,7 @@ // paths are interpreted as standard external ones when we're in a // working copy, but as project-rooted external ones otherwise file_path fp; - if (app.found_working_copy) - fp = file_path_external(idx(args, 0)); - else - fp = file_path_internal_from_user(idx(args, 0)); + fp = file_path_external(idx(args, 0)); manifest_id mid; app.db.get_revision_manifest(rid, mid); manifest_map m; ======================================================================== --- paths.cc 4e5102ee894c9a36efca874f1566b7f021b01069 +++ paths.cc 4ef0ae40dcb0c3edf9edbcf939bca52a34818cd2 @@ -171,11 +171,6 @@ case internal: data = path; break; - case internal_from_user: - data = path; - N(is_valid_internal(path), - F("path '%s' is invalid") % path); - break; case external: if (!initial_rel_path.initialized) { @@ -957,6 +952,9 @@ a.may_not_initialize(); BOOST_CHECK_THROW(a.set(1, false), std::logic_error); BOOST_CHECK_THROW(a.set(2, true), std::logic_error); + a.unset(); + a.set(1, false); + BOOST_CHECK_THROW(a.may_not_initialize(), std::logic_error); } void add_paths_tests(test_suite * suite) ======================================================================== --- paths.hh 6a40d74b6c578436c71a44a123ab7f8553404ba0 +++ paths.hh b019e9708f84baea6625e9554f0d79969dd18051 @@ -45,16 +45,11 @@ // to the project root. // file_path_external: use this for strings that come from the user. // these strings are normalized before being checked, and if there is -// a problem trigger N() invariants rather than I() invariants. such -// strings are interpreted as being _relative to the user's original -// directory_. this function can only be called from within a -// working copy. -// file_path_internal_from_user: use this for strings that come from -// the user, _but_ are not referring to paths in the working copy, -// but rather in some database object directly. for instance, 'cat -// -r REV PATH' uses this function. this function is exactly like -// file_path_internal, except that it raises N() errors rather than -// I() errors. +// a problem trigger N() invariants rather than I() invariants. if in +// a working directory, such strings are interpreted as being +// _relative to the user's original directory_. +// if not in a working copy, strings are treated as referring to some +// database object directly. // file_path's also provide optimized splitting and joining // functionality. // @@ -167,7 +162,7 @@ { return data < other.data; } private: - typedef enum { internal, external, internal_from_user } source_type; + typedef enum { internal, external } source_type; // input is always in utf8, because everything in our world is always in // utf8 (except interface code itself). // external paths: @@ -181,7 +176,6 @@ file_path(source_type type, std::string const & path); friend file_path file_path_internal(std::string const & path); friend file_path file_path_external(utf8 const & path); - friend file_path file_path_internal_from_user(utf8 const & path); }; // these are the public file_path constructors @@ -193,17 +187,7 @@ { return file_path(file_path::external, path()); } -// this is rarely used; it is for when the user provides not a path relative -// to their position in the working directory, but instead a project-root -// relative path (e.g., in 'cat REV PATH'). It is exactly like -// file_path_internal, but counts invalid paths as naughtiness rather than -// bugs. -inline file_path file_path_internal_from_user(utf8 const & path) -{ - return file_path(file_path::internal_from_user, path()); -} - class bookkeeping_path : public any_path { public: ======================================================================== --- tests/t_diff_changeset_bug.at +++ tests/t_diff_changeset_bug.at f2a49720200bcc77fcc581f5b6c39e82fcb1e828 @@ -0,0 +1,26 @@ +# -*- Autoconf -*- + +AT_SETUP([diffing a file within revision outside a working dir]) + +# this is a bug +AT_XFAIL_IF(true) + +MONOTONE_SETUP + +AT_DATA(foo1, [foo file 1 +]) +AT_DATA(foo2, [foo file 2 +]) + +AT_CHECK(MONOTONE add foo1, [], [ignore], [ignore]) +AT_CHECK(MONOTONE --branch=testbranch commit --message blah, [], [ignore], [ignore]) +parent=`BASE_REVISION` +AT_CHECK(MONOTONE add foo2, [], [ignore], [ignore]) +AT_CHECK(MONOTONE --branch=testbranch commit --message bleh, [], [ignore], [ignore]) + +second=`BASE_REVISION` +AT_CHECK(rm -rf MT) +# fails mysteriously +AT_CHECK(MONOTONE diff --revision=$parent --revision=$second foo1, [], [ignore], [ignore]) + +AT_CLEANUP ======================================================================== --- tests/t_diff_outside_working_dir.at +++ tests/t_diff_outside_working_dir.at 68e1ab2a3186b905dc91af7814cb0dc10594bb3f @@ -0,0 +1,24 @@ +# -*- Autoconf -*- + +AT_SETUP([diffing a file within revision outside a working dir]) + +MONOTONE_SETUP + +AT_DATA(foo1, [foo file 1 +]) +AT_DATA(foo2, [foo file 2 +]) + +AT_CHECK(MONOTONE add foo1, [], [ignore], [ignore]) +AT_CHECK(MONOTONE --branch=testbranch commit --message blah, [], [ignore], [ignore]) +parent=`BASE_REVISION` +AT_CHECK(MONOTONE add foo2, [], [ignore], [ignore]) +AT_CHECK(MONOTONE --branch=testbranch commit --message bleh, [], [ignore], [ignore]) + +second=`BASE_REVISION` +AT_CHECK(rm -rf MT) +AT_CHECK(MONOTONE diff --revision=$parent --revision=$second, [], [ignore], [ignore]) +# check it works when specifying files +AT_CHECK(MONOTONE diff --revision=$parent --revision=$second foo2, [], [ignore], [ignore]) + +AT_CLEANUP ======================================================================== --- tests/t_log_outside_working_dir.at +++ tests/t_log_outside_working_dir.at 394e25f09b80a55cd58f3e9f2e8474a4568b5624 @@ -0,0 +1,19 @@ +# -*- Autoconf -*- + +AT_SETUP([diffing a file within revision outside a working dir]) + +MONOTONE_SETUP + +AT_DATA(foo1, [foo file 1 +]) +AT_DATA(foo2, [foo file 2 +]) + +AT_CHECK(MONOTONE add foo1, [], [ignore], [ignore]) +AT_CHECK(MONOTONE --branch=testbranch commit --message blah, [], [ignore], [ignore]) +parent=`BASE_REVISION` + +AT_CHECK(rm -rf MT) +AT_CHECK(MONOTONE log --revision=$parent foo1, [], [ignore], [ignore]) + +AT_CLEANUP ======================================================================== --- testsuite.at 0d3e0effc051db81bd3de638ca542d358ddb8dc9 +++ testsuite.at 5a310950bc3461a4c22892c145cd7ff321b911c7 @@ -707,3 +707,6 @@ m4_include(tests/t_restriction_with_exclude.at) m4_include(tests/t_restriction_with_exclude_iprint.at) m4_include(tests/t_rename_diff_names.at) +m4_include(tests/t_diff_outside_working_dir.at) +m4_include(tests/t_log_outside_working_dir.at) +m4_include(tests/t_diff_changeset_bug.at)