# # add_file "tests/t_add_stomp_file.at" # # patch "ChangeLog" # from [17005e6b477d1e10e723855784f06be09057eb21] # to [8c3d7a97ff40b113c665de3d32c91aa701de636a] # # patch "commands.cc" # from [e24b9d3f4cf1db10ea68ce3733c1a8bdafb5371d] # to [e351cc76be3dbe3eaa3d9a35f69a3efe5b09c414] # # patch "monotone.texi" # from [412d8c60e2a7e06ae07a6b8350393421d7f87b2b] # to [939f56de6aac68a630492031939ce4654f093203] # # patch "tests/t_add_stomp_file.at" # from [] # to [ff7f16f34c202ec044ad232af78786bd119b5e98] # # patch "testsuite.at" # from [63f222bf1549f1b5ea773c38860809fd131a88e4] # to [c9806d0931d6dec93838b7479f2d31b378be8453] # # patch "transforms.cc" # from [0301854cc96c7c43b527feb0ac5c2914537d9027] # to [61593e946306f8bd5926c02fca2ea683e510d271] # --- ChangeLog +++ ChangeLog @@ -6,8 +6,23 @@ branch globs and regexps. (glob_to_regexp_test): A unit test for glob_to_regexp(). +2005-04-16 Emile Snyder + + * tests/t_add_stomp_file.at: New test for failing case. + If you have a file foo in your working dir (not monotone + controlled) and someone else adds a file foo and commits, + update should at least warn you before stomping your + non-recoverable foo file. + * testsuite.at: Add it. + 2005-04-17 Matt Johnston + * commands.cc: warn that dropkey won't truly erase the privkey + from the database + * monotone.texi: same + +2005-04-17 Matt Johnston + * database.cc: mention that it could be the filesystem that is full in the SQLITE_FULL error message --- commands.cc +++ commands.cc @@ -1184,7 +1184,10 @@ if (app.db.private_key_exists(ident)) { - P(F("dropping private key '%s' from database\n") % ident); + P(F("dropping private key '%s' from database\n\n") % ident); + W(F("the private key data may not have been erased from the")); + W(F("database. it is recommended that you use 'db dump' and")); + W(F("'db load' to be sure.")); app.db.delete_private_key(ident); key_deleted = true; } --- monotone.texi +++ monotone.texi @@ -3813,7 +3813,10 @@ This command drops the public and/or private key. If both exist, both are dropped, if only one exists, it is dropped. This command should be used with caution as changes are irreversible without a backup of -the key(s) that were dropped. +the key(s) that were dropped. Note also that the private key is not +guaranteed to actually be erased from your database file - if you are +going to make the database file public, you should use 'db dump' +and 'db load' to import into a fresh database. @item monotone chkeypass @var{id} --- tests/t_add_stomp_file.at +++ tests/t_add_stomp_file.at @@ -0,0 +1,44 @@ +AT_SETUP([make sure update does not stomp non-monotone file]) +MONOTONE_SETUP + +# This test is a bug report +AT_XFAIL_IF(true) + +# 1. Alice checks out project, creates file foo +# 2. Bob checks out project, creates foo, adds foo, and commits +# 3. Now Alice does an update +# +# monotone should warn her before stomping her non-revision controlled 'foo' file +# + +AT_DATA(initial, [some initial data +]) + +AT_DATA(foo.alice, [foo +not revision controlled +]) + +AT_DATA(foo.bob, [foo +checked into project +]) + +# Alice make project, writes foo, but doesn't check it in +AT_CHECK(mkdir alicewd) +AT_CHECK(cp initial alicewd/initial) +AT_CHECK(MONOTONE --branch=testbranch setup alicewd, [], [ignore], [ignore]) +AT_CHECK( (cd alicewd; MONOTONE --branch=testbranch --root=. add initial), [], [ignore], [ignore]) +AT_CHECK( (cd alicewd; MONOTONE --branch=testbranch --root=. commit -m 'initial commit'), [], [ignore], [ignore]) +AT_CHECK(cp foo.alice alicewd/foo) + +# Bob does add of file foo, and commits +AT_CHECK(MONOTONE --branch=testbranch checkout bobwd, [], [ignore], [ignore]) +AT_CHECK(cp foo.bob bobwd/foo) +AT_CHECK( (cd bobwd; MONOTONE --branch=testbranch --root=. add foo), [], [ignore], [ignore]) +AT_CHECK( (cd bobwd; MONOTONE --branch=testbranch --root=. commit -m 'bob commit'), [], [ignore], [ignore]) +REV=`BASE_REVISION` + +# Alice does her update, discovers foo has been stomped! +AT_CHECK( (cd alicewd; MONOTONE --branch=testbranch --root=. update $REV), [], [ignore], [ignore]) +AT_CHECK(cmp foo.alice alicewd/foo) + +AT_CLEANUP --- testsuite.at +++ testsuite.at @@ -562,3 +562,4 @@ m4_include(tests/t_add_vs_commit.at) m4_include(tests/t_update_nonexistent.at) m4_include(tests/t_override_author_date.at) +m4_include(tests/t_add_stomp_file.at) --- transforms.cc +++ transforms.cc @@ -437,10 +437,23 @@ string remove_ws(string const & s) { - string tmp = s; - string::size_type pos = 0; - while ((pos = tmp.find_first_of("\n\r\t ")) != string::npos) - tmp.erase(pos,1); + string tmp; + tmp.reserve(s.size()); + for (string::const_iterator i = s.begin(); + i != s.end(); ++i) + { + switch (*i) + { + case '\n': + case '\r': + case '\t': + case ' ': + break; + default: + tmp += *i; + break; + } + } return tmp; }