# # # add_file "tests/t_restriction_excludes_parent.at" # content [1d7f70ad7393b27b6ad40728ff6eded71de6281f] # # patch "ChangeLog" # from [1d76357943900accc6971a7d22faaab5aed47940] # to [0a929dc5dce46bbbee3ecfdc850de6fc67716c32] # # patch "app_state.cc" # from [4990c26751504dded9cef9b1c6ffa66bef0d2b32] # to [6b1b9700a2a10d936f13eb1d20ae858f4a9781d0] # # patch "app_state.hh" # from [03afbc7ba543f0b26f8ddf70d97c05e872cdb36b] # to [9a76507a50ff842cd7eb62a775b1381d6c520160] # # patch "restrictions.cc" # from [5ae2c8255b6eb1e65662d68d5889ac9d4d3c24c8] # to [80183dbc99249d83cbcde3fe8d59a0a9585cd0f9] # # patch "restrictions.hh" # from [f0b311b47b461a5f9479bef3c5dcb28f1eaf5131] # to [79ef3d493453af0098cfb11618e6fce1e8bb8f6d] # # patch "tests/t_persistent_server_keys_2.at" # from [63a6ad1e1eebabf989fa1d061cb8194614caf134] # to [aabf8cfcd040e7f3290819ed90e46c7c6b6cc074] # # patch "tests/t_restriction_with_exclude.at" # from [bf85428b2d62062acb23d375b0b18a3706adc5dd] # to [d356460f153f0a8c64052b530d07c6e3da6b8bf5] # # patch "tests/t_restrictions.at" # from [84972130299ee9cc3449101f4a4135795cf863f0] # to [765a23ae21d3034f6a94899cc919b7962e2ed239] # # patch "tests/t_revert_new_project.at" # from [ac8b9497aa5d1a89d01be066365bddb8b3889baf] # to [364fa3c8e677fec2303aee44d3caa3197b0dc982] # # patch "tests/t_subdirs.at" # from [ba25cf0001810a9c5ba358fc34bab80d311c54a5] # to [c4f829c5b8bbdf0ed27d534bf13a1b8fd9672c6a] # # patch "testsuite.at" # from [fa6d4d9f984c7631d5f3efe418ebfe1b5f3f0d70] # to [9805b37b0392a9f3c6881343d2fb874f47301a19] # ============================================================ --- tests/t_restriction_excludes_parent.at 1d7f70ad7393b27b6ad40728ff6eded71de6281f +++ tests/t_restriction_excludes_parent.at 1d7f70ad7393b27b6ad40728ff6eded71de6281f @@ -0,0 +1,41 @@ +AT_SETUP([restriction excludes parent dir]) +MONOTONE_SETUP + +# this test is a bug report +# +# - restricting a new project excludes the root directory addition +# - restricting to things below a newly added directory excludes the directory +# - excluding added directories but including things they contain is bad +# +# we should issue a nice error indicating that such a restriction must +# be expanded to include the containing directories. +# we should also provide some way to include only these directories and not +# all of their contents. +# +# --depth=0 should probably mean "directory without contents" rather than +# "directory and all immediate children" + +AT_XFAIL_IF(true) + +ADD_FILE(file, [file +]) + +# exclude newly added root dir but include file below it +AT_CHECK(MONOTONE st file, [3], [ignore], [ignore]) + +COMMIT(testbranch) + +AT_CHECK(mkdir foo) + +ADD_FILE(foo/bar, [foobar +]) + + +# exclude newly added foo dir but include bar below it +AT_CHECK(MONOTONE st foo/bar, [3], [ignore], [ignore]) + +# note that return status [3] above indicates a crash + +AT_CHECK(false) + +AT_CLEANUP ============================================================ --- ChangeLog 1d76357943900accc6971a7d22faaab5aed47940 +++ ChangeLog 0a929dc5dce46bbbee3ecfdc850de6fc67716c32 @@ -1,3 +1,19 @@ +2006-03-02 Derek Scherger + + * app_state.{cc,hh} (restriction_requires_parent): remove + * restrictions.cc (restrict_cset): remove call to + restriction_requires_parent + * restrictions.hh: remove unused struct + * tests/t_persistent_server_keys.at: use unrestricted commit to + avoid parent exclusion + * tests/t_restriction_with_exclude.at: remove bogus check + * tests/t_restrictions.at: work around excluded parents + * tests/t_revert_new_project.at: un-XFAIL + * tests/t_subdirs.at: work around excluded parents + * tests/t_restriction_excludes_parent.at: new XFAIL test for restrictions + that exclude required parent dirs + * testsuite.at: call it + 2006-02-26 Derek Scherger * tests/t_log_dir.at: new XFAIL test of log restricted to a single ============================================================ --- app_state.cc 4990c26751504dded9cef9b1c6ffa66bef0d2b32 +++ app_state.cc 6b1b9700a2a10d936f13eb1d20ae858f4a9781d0 @@ -194,28 +194,6 @@ } bool -app_state::restriction_requires_parent(split_path const & sp) -{ - file_path path(sp); - if (restrictions.empty()) - return false; - - for (path_set::const_iterator i = restrictions.begin(); - i != restrictions.end(); ++i) - { - // If sp is a parent of any member rs of the restriction, - // we want to return true. - split_path rs = *i; - if (rs.size() < sp.size()) - continue; - rs.resize(sp.size()); - if (rs == sp) - return true; - } - return false; -} - -bool app_state::restriction_includes(split_path const & sp) { // FIXME: this was written before split_path, and only later kludged to ============================================================ --- app_state.hh 03afbc7ba543f0b26f8ddf70d97c05e872cdb36b +++ app_state.hh 9a76507a50ff842cd7eb62a775b1381d6c520160 @@ -95,7 +95,6 @@ void set_restriction(path_set const & valid_paths, std::vector const & paths); - bool restriction_requires_parent(split_path const & path); bool restriction_includes(split_path const & path); // Set the branch name. If you only invoke set_branch, the branch ============================================================ --- restrictions.cc 5ae2c8255b6eb1e65662d68d5889ac9d4d3c24c8 +++ restrictions.cc 80183dbc99249d83cbcde3fe8d59a0a9585cd0f9 @@ -81,18 +81,7 @@ for (path_set::const_iterator i = cs.dirs_added.begin(); i != cs.dirs_added.end(); ++i) { - // Here is a trick: when you're dealing with restrictions, you need - // to make sure that any added parents required to make the - // restriction-affected files exist come along for the ride. - bool include_it = app.restriction_includes(*i); - if (!include_it) - { - include_it = app.restriction_requires_parent(*i); - if (include_it) - W(F("Included required parent path '%s'\n") % *i); - } - - if (include_it) + if (app.restriction_includes(*i)) safe_insert(included.dirs_added, *i); else safe_insert(excluded.dirs_added, *i); ============================================================ --- restrictions.hh f0b311b47b461a5f9479bef3c5dcb28f1eaf5131 +++ restrictions.hh 79ef3d493453af0098cfb11618e6fce1e8bb8f6d @@ -28,13 +28,6 @@ #include "roster.hh" #include "vocab.hh" -struct restriction -{ - roster_t base_roster; - roster_t current_roster; - roster_t restricted_roster; -}; - void extract_rearranged_paths(cset const & rearrangement, path_set & paths); ============================================================ --- tests/t_persistent_server_keys_2.at 63a6ad1e1eebabf989fa1d061cb8194614caf134 +++ tests/t_persistent_server_keys_2.at aabf8cfcd040e7f3290819ed90e46c7c6b6cc074 @@ -19,7 +19,8 @@ ADD_FILE(foo, [data data blah ]) -AT_CHECK(MONOTONE2 commit address@hidden --branch=testbranch -m 'commit foo' foo, [], [ignore], [ignore]) +AT_CHECK(MONOTONE2 status, [], [ignore], [ignore]) +AT_CHECK(MONOTONE2 commit address@hidden --branch=testbranch -m 'commit foo', [], [ignore], [ignore]) NETSYNC_SERVE_START(testbranch) NETSYNC_CLIENT_N_RUN(2, push, testbranch) ============================================================ --- tests/t_restriction_with_exclude.at bf85428b2d62062acb23d375b0b18a3706adc5dd +++ tests/t_restriction_with_exclude.at d356460f153f0a8c64052b530d07c6e3da6b8bf5 @@ -12,10 +12,16 @@ AT_CHECK(MONOTONE ci --exclude . -m 'x', [1], [ignore], [ignore]) -AT_CHECK(MONOTONE ci --exclude . file1 -m 'x', [], [ignore], [ignore]) -AT_CHECK(MONOTONE status --brief | grep "foo/bar", [], [ignore], [ignore]) -AT_CHECK(MONOTONE status --brief | grep "file1", [1], [ignore], [ignore]) -AT_CHECK(echo a >>file1) +# this is dumb. excluding the whole tree and including file1 is +# equivalent to just including file1. except that at this point +# the root dir has not been created and excluding the whole tree +# excludes this creation. this causes the commit to fail because +# file1 has no parent. +# +# AT_CHECK(MONOTONE ci --exclude . file1 -m 'x', [], [ignore], [ignore]) +# AT_CHECK(MONOTONE status --brief | grep "foo/bar", [], [ignore], [ignore]) +# AT_CHECK(MONOTONE status --brief | grep "file1", [1], [ignore], [ignore]) +# AT_CHECK(echo a >>file1) AT_CHECK(MONOTONE ci --exclude foo -m 'x', [], [ignore], [ignore]) AT_CHECK(MONOTONE status --brief | grep "foo/bar", [], [ignore], [ignore]) ============================================================ --- tests/t_restrictions.at 84972130299ee9cc3449101f4a4135795cf863f0 +++ tests/t_restrictions.at 765a23ae21d3034f6a94899cc919b7962e2ed239 @@ -42,6 +42,10 @@ AT_CHECK(MONOTONE add work/A/fileA, [], [ignore], [ignore]) AT_CHECK(MONOTONE add work/A/B/fileAB, [], [ignore], [ignore]) +# initial commit + +AT_CHECK(MONOTONE --branch=testbranch commit --message='add file[X23]', [], [ignore], [ignore]) + AT_CHECK(MONOTONE ls known --depth=0, [], [stdout], [ignore]) AT_CHECK(grep fileX stdout, [1], [ignore]) @@ -81,10 +85,6 @@ AT_CHECK(MONOTONE ls ignored --rcfile=ignored.lua work, [], [stdout], [ignore]) AT_CHECK(grep work/foo.o stdout, [0], [ignore]) -# initial commit - -AT_CHECK(MONOTONE --branch=testbranch commit --message='add file[X23]', [], [ignore], [ignore]) - # create moved, dropped, and changed work to test status, diff, commit AT_CHECK(mv work/fileX work/file1) ============================================================ --- tests/t_revert_new_project.at ac8b9497aa5d1a89d01be066365bddb8b3889baf +++ tests/t_revert_new_project.at 364fa3c8e677fec2303aee44d3caa3197b0dc982 @@ -1,9 +1,7 @@ # -*- Autoconf -*- AT_SETUP([revert file in new project]) -AT_XFAIL_IF(true) - MONOTONE_SETUP ============================================================ --- tests/t_subdirs.at ba25cf0001810a9c5ba358fc34bab80d311c54a5 +++ tests/t_subdirs.at c4f829c5b8bbdf0ed27d534bf13a1b8fd9672c6a @@ -14,6 +14,13 @@ AT_CHECK(MONOTONE add foo, [], [ignore], [ignore]) AT_CHECK(MONOTONE add bar, [], [ignore], [ignore]) +COMMIT(testbranch) + +AT_DATA(foo/foo.txt, [file foo.txt in dir foo changed +]) +AT_DATA(bar/bar.txt, [file bar.txt in dir bar changed +]) + # should have tests for # add, drop, rename, revert # - which use prefixing ============================================================ --- testsuite.at fa6d4d9f984c7631d5f3efe418ebfe1b5f3f0d70 +++ testsuite.at 9805b37b0392a9f3c6881343d2fb874f47301a19 @@ -785,3 +785,4 @@ m4_include(tests/t_pivot_root_update.at) m4_include(tests/t_rosterify_root_suture.at) m4_include(tests/t_log_dir.at) +m4_include(tests/t_restriction_parents.at)