# # patch "ChangeLog" # from [20bc2e82824d4e18d96b04e7d4418926c015905c] # to [02da640ecaeada65ac64f8ce088659b742726a55] # # patch "tests/t_rename_attr.at" # from [6dbd979997c7fb85de3cbc8f82dbd302ea5627e3] # to [6200a5c52034c1eba2322b4e96376fb52c897944] # # patch "work.cc" # from [1b62ad043f8d9c60ab99bd77a0ae6fd0f9f0d005] # to [dd492063ea45c95b8afa38dd889cf317e3396e59] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,8 @@ +2005-04-27 Joel Reed + + * work.cc: on rename move attributes as well. + * tests/t_rename_attr.at: No longer a bug. + 2005-04-22 Christof Petig * sqlite/*: update to sqlite 3.2.1 @@ -7281,4 +7286,3 @@ 2003-04-06 graydon hoare * initial release. - --- tests/t_rename_attr.at +++ tests/t_rename_attr.at @@ -1,9 +1,6 @@ AT_SETUP([rename moves 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,6 +11,9 @@ COMMIT(testbranch) AT_CHECK(MONOTONE rename testfile otherfile, [], [ignore], [ignore]) +AT_CHECK(mv testfile otherfile) +COMMIT(testbranch) + AT_CHECK(MONOTONE attr get testfile, [1], [ignore], [ignore]) AT_CHECK(MONOTONE attr get otherfile, [], [stdout], [ignore]) AT_CHECK(grep -q some_key stdout) --- work.cc +++ work.cc @@ -259,6 +259,35 @@ else pr_new.renamed_files.insert(std::make_pair(src, dst)); + // 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); + + // only write out a new attribute map if we find attrs to move + attr_map::iterator a = attrs.find(src); + if (a != attrs.end()) + { + N(attrs.find(dst) == attrs.end(), + F("refusing to overwrite existing attributes on %s") % dst); + + attrs[dst] = (*a).second; + attrs.erase(a); + + P(F("moving attributes for %s to %s\n") % src % dst); + + write_attr_map(attr_data, attrs); + write_data(attr_path, attr_data); + } + } + normalize_path_rearrangement(pr_new); concatenate_rearrangements(pr, pr_new, pr_concatenated); pr = pr_concatenated;