# # add_file "tests/t_update_branch.at" # # patch "ChangeLog" # from [bacbb1a91ee1d2137c9e1af3544ac838844ff091] # to [052abd2ef070306b0c67e388bcea872877d8196c] # # patch "app_state.cc" # from [7950e66c8a6ea67081349e7dd02b8429a4c8454b] # to [414019cdae9443eaf3d71170e6af2e20fda97759] # # patch "commands.cc" # from [58614444e3fc5147e0f78a685ad92615d505c3f1] # to [75481093100bfad9ebc37e00e0eedb053762e4f3] # # patch "tests/t_update_branch.at" # from [] # to [248a24155ced3052ff905aa79e43f1fba6bfc136] # # patch "testsuite.at" # from [97222f8297b2c402e778b69ac58ddb8600923b47] # to [f6a51d0fb96bb204d2588b14600440c90a0cf2d9] # =============================================== --- ChangeLog bacbb1a91ee1d2137c9e1af3544ac838844ff091 +++ ChangeLog 052abd2ef070306b0c67e388bcea872877d8196c @@ -1,5 +1,16 @@ 2005-07-27 Nathaniel Smith + * tests/t_update_branch.at: New test. + * testsuite.at: Add it. + (REVERT_TO): Do not preserve MT/options file (can setup invalid + branch). + * app_state.cc (make_branch_sticky): Call write_options when + already have a working copy. + * commands.cc (update): Call make_branch_sticky at appropriate + time. + +2005-07-27 Nathaniel Smith + * commands.cc: ALIAS(mv, rename). ALIAS(rm, drop). 2005-07-26 Nathaniel Smith =============================================== --- app_state.cc 7950e66c8a6ea67081349e7dd02b8429a4c8454b +++ app_state.cc 414019cdae9443eaf3d71170e6af2e20fda97759 @@ -271,6 +271,13 @@ app_state::make_branch_sticky() { options[branch_option] = branch_name(); + if (found_working_copy) + { + // already have a working copy, can (must) write options directly + // if we don't have a working copy yet, then require_working_copy (for + // instance) will call write_options when it finds one. + write_options(); + } } void =============================================== --- commands.cc 58614444e3fc5147e0f78a685ad92615d505c3f1 +++ commands.cc 75481093100bfad9ebc37e00e0eedb053762e4f3 @@ -2940,8 +2940,6 @@ if (app.revision_selectors.size() > 1) throw usage(name); - if (!app.branch_name().empty()) - app.make_branch_sticky(); app.require_working_copy(); calculate_unrestricted_revision(app, r_working, m_old, m_working); @@ -3067,6 +3065,10 @@ // nb: we write out r_chosen, not r_new, because the revision-on-disk // is the basis of the working copy, not the working copy itself. put_revision_id(r_chosen_id); + if (!app.branch_name().empty()) + { + app.make_branch_sticky(); + } P(F("updated to base revision %s\n") % r_chosen_id); put_path_rearrangement(remaining.rearrangement); =============================================== --- tests/t_update_branch.at +++ tests/t_update_branch.at 248a24155ced3052ff905aa79e43f1fba6bfc136 @@ -0,0 +1,25 @@ +AT_SETUP([update -b foo updates MT/options correctly]) +MONOTONE_SETUP + +ADD_FILE(testfile, [blah blah +]) +COMMIT(testbranch) +REV=`BASE_REVISION` + +SET_FILE(testfile, [other other +]) +COMMIT(otherbranch) + +AT_CHECK(MONOTONE update -b testbranch, [], [ignore], [ignore]) +AT_CHECK(grep -q otherbranch MT/options, []) +AT_CHECK(grep -q testbranch MT/options, [1]) + +REVERT_TO($REV, testbranch) +AT_CHECK(grep -q otherbranch MT/options, [1]) +AT_CHECK(grep -q testbranch MT/options, []) + +AT_CHECK(MONOTONE update -b otherbranch, [], [ignore], [ignore]) +AT_CHECK(grep -q otherbranch MT/options, []) +AT_CHECK(grep -q testbranch MT/options, [1]) + +AT_CLEANUP =============================================== --- testsuite.at 97222f8297b2c402e778b69ac58ddb8600923b47 +++ testsuite.at f6a51d0fb96bb204d2588b14600440c90a0cf2d9 @@ -215,7 +215,6 @@ m4_case([$2], [], [AT_CHECK(MONOTONE checkout --revision=$1 ., [], [ignore])], [AT_CHECK(MONOTONE --branch=$2 checkout --revision=$1 ., [], [ignore])]) -AT_CHECK(mv MT.old/options MT) PROBE_R_SHA=`BASE_REVISION` AT_CHECK(test $PROBE_R_SHA = $1) ]) @@ -678,3 +677,4 @@ m4_include(tests/t_ls_branches.at) m4_include(tests/t_database_check_normalized.at) m4_include(tests/t_annotate_no_rev.at) +m4_include(tests/t_update_branch.at)