# # patch "ChangeLog" # from [e112fae8fe4dab216835e0323a85cc1d603068bb] # to [f4bceff795ed09c125694301cc9f6edbaca48290] # # patch "monotone.texi" # from [779576797904c3707bf401e6392f4d8ed4031c31] # to [b9644236bc61815fe819902c65c37c0396f0e261] # # patch "tests/t_rename_attr.at" # from [6200a5c52034c1eba2322b4e96376fb52c897944] # to [73f6d07fd5c560ab99d9dd5c7bae3330dbdfb43c] # # patch "work.cc" # from [29f75856fcd8eff9496ea288a1a57c4900e81950] # to [fc6dc12266db9250f4168ece7e079bd5099f1dc5] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,14 @@ +2005-04-28 Nathaniel Smith + + * tests/t_rename_attr.at: Fix a bit; also test that rename refuses + to move a file to a name that already has attrs. + * work.cc (build_rename): Cleanup a bit; refuse to move a file to + a name that already has attrs. + + * monotone.texi (Working Copy): Document explicitly that "drop" + and "rename" do not modify the filesystem directly, and do affect + attributes. + 2005-04-28 Richard Levitte * tests/t_automate_select.at: silly ignores not needed any more. --- monotone.texi +++ monotone.texi @@ -3365,10 +3365,12 @@ @item monotone drop @var{pathname...} This command places ``drop'' entries for the paths specified in address@hidden in the working copy's ``work list''. The work list -of your working copy is located at @file{MT/work}, and is a list of address@hidden in the working copy's ``work list''. The work list of +your working copy is located at @file{MT/work}, and is a list of explicit pathname changes you wish to commit at some future time, such -as addition, removal, or renaming of files. +as addition, removal, or renaming of files. This command also removes +any attributes on @var{pathname}; see @ref{File Attributes} for more +details. While this command places a ``drop'' entry on your work list, it does not immediately affect your database. When you @command{commit} your @@ -3376,12 +3378,19 @@ which it will then commit to the database. The new revision will have any dropped entries removed from its manifest. +Currently this command does @emph{not} actually delete the file address@hidden in your filesystem; if you want to actually delete the file, +you should run @command{drop}, and then perform the actual delete using +whatever mechanism you normally use to delete files. + @item monotone rename @var{src} @var{dst} This command places ``rename'' entries for the paths specified in @var{src} and @var{dst} in the working copy's ``work list''. The work -list of your working copy is located at @file{MT/work}, and is a list -of explicit pathname changes you wish to commit at some future time, -such as addition, removal, or renaming of files. +list of your working copy is located at @file{MT/work}, and is a list of +explicit pathname changes you wish to commit at some future time, such +as addition, removal, or renaming of files. This command also moves any +attributes on @var{src} to @var{dst}; see @ref{File Attributes} for more +details. While this command places a ``rename'' entry on your work list, it does not immediately affect your database. When you @command{commit} @@ -3390,6 +3399,10 @@ will have any renamed entries in its manifest adjusted to their new names. +Currently this command does @emph{not} actually rename the file address@hidden in your filesystem; after you run this command, you should do +the actual rename, using whatever mechanism you normally use to rename +files. @item monotone commit @itemx monotone commit address@hidden --- tests/t_rename_attr.at +++ tests/t_rename_attr.at @@ -14,9 +14,23 @@ AT_CHECK(mv testfile otherfile) COMMIT(testbranch) -AT_CHECK(MONOTONE attr get testfile, [1], [ignore], [ignore]) +# Create a new testfile, so 'attr get' has a chance to succeed +ADD_FILE(testfile, [thing stuff +]) +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_CHECK(MONOTONE attr get otherfile, [], [stdout], [ignore]) AT_CHECK(grep -q some_key stdout) AT_CHECK(grep -q some_value stdout) +# Make sure rename fails if the user has someone managed to put +# attributes on the target file. + +AT_DATA(.mt-attrs, [ file "has_attrs" +execute "true" +]) + +AT_CHECK(MONOTONE rename otherfile has_attrs, [1], [ignore], [ignore]) + AT_CLEANUP --- work.cc +++ work.cc @@ -262,21 +262,22 @@ file_path attr_path; get_attr_path(attr_path); - data attr_data; - attr_map attrs; - if (file_exists(attr_path)) { + data attr_data; read_data(attr_path, attr_data); + attr_map attrs; read_attr_map(attr_data, attrs); + // make sure there aren't pre-existing attributes that we'd accidentally + // pick up + N(attrs.find(dst) == attrs.end(), + F("%s has existing attributes in .mt-attrs; clean them up first") % dst); + // 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);