# # add_file "tests/t_revert_restrict.at" # # patch "ChangeLog" # from [af74798351fab132d38bf3bdc922e954b884482d] # to [d8b4e1c1edb8e4b021fe0557d74e745be470fbbf] # # patch "app_state.cc" # from [7c12ea6894df8aed4ac689b333df2f5dc19e3fd4] # to [7059471c5febbb78676ba5b2e7e432ce3fe39977] # # patch "app_state.hh" # from [3ac03fa785dd39a9c005a7a35ad1962468d5be32] # to [ba2b8d968ce1eabe69b2c7fb60a7c666cfa4ada7] # # patch "commands.cc" # from [9bd8efa9851b45da733ea27333a77e285a035c80] # to [5d992c6d2826ea22eba4bfc5366f35e21c433a86] # # patch "tests/t_revert_restrict.at" # from [] # to [ca9b1e167516b4b92a5d285da56b7ca076dbd587] # # patch "testsuite.at" # from [870e8ba2df0bf039b75504971f0b4ba11c1cc859] # to [353e351595bd4a6dadf8360e19ee41a4f4d8e68a] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,12 @@ +2005-06-11 Matt Johnston + + * commands.cc: revert should ignore the ignore hooks, otherwise bad + things happen (revert a single ignored file, resultant empty ignore list + reverts the whole working copy). + * app_state.cc, app_state.hh: give set_restriction a flag to disregard + file-ignore hooks. + * tests/t_revert_restrict.at, testsuite.at: a test + 2005-06-09 Riccardo Ghetta * std_hooks.lua: make binary_file return nil on unreadable/empty files --- app_state.cc +++ app_state.cc @@ -155,7 +155,9 @@ } void -app_state::set_restriction(path_set const & valid_paths, vector const & paths) +app_state::set_restriction(path_set const & valid_paths, + vector const & paths, + bool respect_ignore) { // this can't be a file-global static, because file_path's initializer // depends on another global static being defined. @@ -165,7 +167,7 @@ { file_path p = prefix(*i); - if (lua.hook_ignore_file(p)) + if (respect_ignore && lua.hook_ignore_file(p)) { L(F("'%s' ignored by restricted path set\n") % p()); continue; --- app_state.hh +++ app_state.hh @@ -54,7 +54,9 @@ void create_working_copy(std::string const & dir); file_path prefix(utf8 const & path); - void set_restriction(path_set const & valid_paths, std::vector const & paths); + void app_state::set_restriction(path_set const & valid_paths, + std::vector const & paths, + bool respect_ignore = true); bool restriction_includes(file_path const & path); // Set the branch name. If you only invoke set_branch, the branch --- commands.cc +++ commands.cc @@ -3392,7 +3392,7 @@ extract_rearranged_paths(work, valid_paths); add_intermediate_paths(valid_paths); - app.set_restriction(valid_paths, args); + app.set_restriction(valid_paths, args, false); restrict_path_rearrangement(work, included, excluded, app); --- tests/t_revert_restrict.at +++ tests/t_revert_restrict.at @@ -0,0 +1,58 @@ +# -*- Autoconf -*- + +AT_SETUP([revert works with restrictions]) + +MONOTONE_SETUP + +AT_DATA(origfile, [some file +]) +AT_DATA(orig.ignore, [a file type that is usually ignored +]) +AT_DATA(orig2, [another file +]) +AT_DATA(modified1, [this is different 1 +]) +AT_DATA(modified2, [this is different 2 +]) +AT_DATA(modified3, [this is different 3 +]) + +AT_DATA(ignore_hook.lua, [ +function ignore_file(name) + if (string.find(name, "test_hooks.lua")) then return true end + if (string.find(name, "test.db")) then return true end + if (string.find(name, "%.ignore$")) then return true end + return false +end +]) + +AT_CHECK(cp origfile testfile) +AT_CHECK(cp orig.ignore file.ignore) +AT_CHECK(cp orig2 file2) +AT_CHECK(MONOTONE add testfile file.ignore file2, [], [ignore], [ignore]) +AT_CHECK(MONOTONE --branch=testbranch commit --message='blah blah', [], [ignore], [ignore]) + +# modify the files, then revert the 'ignored' file +AT_CHECK(cp modified1 testfile) +AT_CHECK(cp modified2 file.ignore) + +AT_CHECK(MONOTONE --rcfile=ignore_hook.lua revert file.ignore, [], [ignore], [ignore]) + +# check that only the 'ignored' file was reverted +AT_CHECK(cmp testfile modified1, [0], [ignore], [ignore]) +AT_CHECK(cmp file.ignore orig.ignore, [0], [ignore], [ignore]) + +# now run it again with two paths, one in the ignorehook list, the other normal +AT_CHECK(MONOTONE revert, [], [ignore], [ignore]) +AT_CHECK(cp modified1 testfile) +AT_CHECK(cp modified2 file.ignore) +AT_CHECK(cp modified3 file2) + +AT_CHECK(MONOTONE --rcfile=ignore_hook.lua revert file.ignore testfile, [], [ignore], [ignore]) + +# check that the files are correct +AT_CHECK(cmp testfile origfile, [0], [ignore], [ignore]) +AT_CHECK(cmp file.ignore orig.ignore, [0], [ignore], [ignore]) +AT_CHECK(cmp file2 modified3, [0], [ignore], [ignore]) + +AT_CLEANUP --- testsuite.at +++ testsuite.at @@ -657,3 +657,4 @@ m4_include(tests/t_update_with_pending_rename.at) m4_include(tests/t_restricted_commit_with_inodeprints.at) m4_include(tests/t_merge_manual.at) +m4_include(tests/t_revert_restrict.at)