# # patch "ChangeLog" # from [1ca0c140585eb24f3192496cb9194d1cde27c84b] # to [2cf536f095e2af74399769d9ced46a1cf8387a7b] # # patch "tests/t_drop_attr.at" # from [68392ef89463df3f259d3b938777e4eced346cdf] # to [a88f420f9e89876865d487e8d16fa0d76a117c01] # # patch "work.cc" # from [168c7482e944a7fc1c8b70b72615f8312a3a31bd] # to [1b62ad043f8d9c60ab99bd77a0ae6fd0f9f0d005] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,8 @@ +2005-04-22 Joel Reed + + * work.cc (build_deletions) : on drop FILE also drop attributes. + * tests/t_drop_attr.at : test for success now, fixed bug. + 2005-04-21 Jeremy Cowgar * tests/t_multiple_heads_msg.at: Now checks to ensure 'multiple head' --- tests/t_drop_attr.at +++ tests/t_drop_attr.at @@ -1,9 +1,6 @@ AT_SETUP([drop removes attributes]) MONOTONE_SETUP -# This test is a bug report. -AT_XFAIL_IF(true) - ADD_FILE(testfile, [foo bar ]) AT_CHECK(MONOTONE attr set testfile some_key some_value, [], [ignore], [ignore]) @@ -14,8 +11,8 @@ COMMIT(testbranch) AT_CHECK(MONOTONE drop testfile, [], [ignore], [ignore]) -AT_CHECK(MONOTONE attr get testfile, [1], [ignore], [ignore]) -AT_CHECK(grep -q some_key stdout) -AT_CHECK(grep -q some_value stdout) +AT_CHECK(MONOTONE attr get testfile, [], [stdout], [ignore]) +AT_CHECK(grep -q some_key stdout, [1]) +AT_CHECK(grep -q some_value stdout, [1]) AT_CLEANUP --- work.cc +++ work.cc @@ -170,6 +170,21 @@ extract_path_set(man, ps); apply_path_rearrangement(pr, ps); + // read attribute map if available + file_path attr_path; + get_attr_path(attr_path); + + data attr_data; + attr_map attrs; + + if (file_exists(attr_path)) + { + read_data(attr_path, attr_data); + read_attr_map(attr_data, attrs); + } + + bool updated_attr_map = false; + for (vector::const_iterator i = paths.begin(); i != paths.end(); ++i) { bool dir_p = false; @@ -191,12 +206,28 @@ pr_new.deleted_dirs.insert(*i); } else - pr_new.deleted_files.insert(*i); + { + pr_new.deleted_files.insert(*i); + + // delete any associated attributes for this file + if (1 == attrs.erase(*i)) + { + updated_attr_map = true; + P(F("dropped attributes for file %s from .mt_attrs\n") % (*i) ); + } + } } normalize_path_rearrangement(pr_new); concatenate_rearrangements(pr, pr_new, pr_concatenated); pr = pr_concatenated; + + // write out updated map if necessary + if (updated_attr_map) + { + write_attr_map(attr_data, attrs); + write_data(attr_path, attr_data); + } } void