# # # patch "app_state.cc" # from [cbb847daf2800d068a0f5f3897b2fb15d4bbeada] # to [d3ce40848b3c514e3b1b7dbbeaf0e8987a9efa06] # # patch "app_state.hh" # from [d3043a4c8bd079e3cb6e61226cc814d7ad0599d6] # to [8967f9cf2d271717a32f37463fadf64f96158ca7] # # patch "cmd_db.cc" # from [081f12f18b9bb58d080d07b69e71cd33b8ed7428] # to [f01ed60ffdc4fc22a4b7806161dc3c56b2e6fa1c] # # patch "cmd_merging.cc" # from [4d403e14031d2efa2e447ee2a533cfe941730394] # to [8960af5e11ed8cc50bb05dc3dd29bd438287df5b] # # patch "cmd_ws_commit.cc" # from [bc75003a35d2e994c039c38f3bbb8d2d90bf3f7c] # to [45743e541263b5feb6f6e605b9431a6f86688211] # # patch "monotone.cc" # from [c73711529cf72e60813e162d9f80225a1ac2c400] # to [5d6d40f09d80ce2fa27a125625aeeb71051dfbd6] # ============================================================ --- app_state.cc cbb847daf2800d068a0f5f3897b2fb15d4bbeada +++ app_state.cc d3ce40848b3c514e3b1b7dbbeaf0e8987a9efa06 @@ -8,54 +8,22 @@ // PURPOSE. #include "base.hh" -#include "vector.hh" - -#include "botan/pubkey.h" -#include "botan/rsa.h" - #include "app_state.hh" -#include "charset.hh" -#include "database.hh" -#include "file_io.hh" -#include "platform.hh" #include "sanity.hh" -#include "ui.hh" -#include "work.hh" -using std::exception; -using std::map; using std::string; -using std::vector; -using std::vector; app_state::app_state() : lua(this), work(lua), - branch_is_sticky(false), - mtn_automate_allowed(false) + found_workspace(false), + mtn_automate_allowed(false), + branch_is_sticky(false) {} app_state::~app_state() {} void -app_state::allow_workspace() -{ - found_workspace = find_and_go_to_workspace(opts.root); - - if (found_workspace) - { - bookkeeping_path dump_path; - work.get_local_dump_path(dump_path); - - // The 'false' means that, e.g., if we're running checkout, - // then it's okay for dumps to go into our starting working - // dir's _MTN rather than the new workspace dir's _MTN. - global_sanity.set_dump_path(system_path(dump_path, false).as_external()); - } - lua.load_rcfiles(opts); -} - -void app_state::process_options() { system_path database_option; @@ -96,7 +64,7 @@ void } void -app_state::write_options() +app_state::write_options(bool branch_is_sticky) { system_path database_option; branch_name branch_option; @@ -106,7 +74,7 @@ app_state::write_options() database_option = opts.dbname; keydir_option = opts.key_dir; - if (branch_is_sticky) + if (branch_is_sticky || this->branch_is_sticky) branch_option = opts.branchname; if (opts.key_given) @@ -122,7 +90,7 @@ app_state::require_workspace(string cons N(found_workspace, F("workspace required but not found%s%s") % (explanation.empty() ? "" : "\n") % explanation); - write_options(); + write_options(false); } void @@ -145,10 +113,8 @@ app_state::create_workspace(system_path mkdir_p(bookkeeping_root); - make_branch_sticky(); + write_options(true); - write_options(); - work.write_ws_format(); work.blank_user_log(); @@ -167,25 +133,6 @@ app_state::create_workspace(system_path lua.load_rcfiles(opts); } -void -app_state::make_branch_sticky() -{ - branch_is_sticky = true; - if (found_workspace) - { - // Already have a workspace, can (must) write options directly, - // because no-one else will do so. If we don't have a workspace - // yet, then require_workspace (for instance) will call - // write_options when it finds one. - write_options(); - } -} - -// rc files are loaded after we've changed to the workspace so that -// _MTN/monotonerc can be loaded between ~/.monotone/monotonerc and other -// rcfiles. - - // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- app_state.hh d3043a4c8bd079e3cb6e61226cc814d7ad0599d6 +++ app_state.hh 8967f9cf2d271717a32f37463fadf64f96158ca7 @@ -32,24 +32,13 @@ public: workspace work; bool found_workspace; - bool branch_is_sticky; bool mtn_automate_allowed; + bool branch_is_sticky; void process_options(); - void allow_workspace(); void require_workspace(std::string const & explanation = ""); void create_workspace(system_path const & dir); - - // Set the branch name. If you only invoke set_branch, the branch - // name is not sticky (and won't be written to the workspace and - // reused by subsequent monotone invocations). Commands which - // switch the working to a different branch should invoke - // make_branch_sticky (before require_workspace because this - // function updates the workspace). - void make_branch_sticky(); - -private: - void write_options(); + void write_options(bool branch_is_sticky); }; // Local Variables: ============================================================ --- cmd_db.cc 081f12f18b9bb58d080d07b69e71cd33b8ed7428 +++ cmd_db.cc f01ed60ffdc4fc22a4b7806161dc3c56b2e6fa1c @@ -155,7 +155,6 @@ CMD(db_kill_rev_locally, "kill_rev_local // c) there are uncomitted changes in the working revision of this workspace. // this *eventually* could be handled with a workspace merge scenario, but // is left out for now - app.allow_workspace(); if (app.found_workspace) { revision_t old_work_rev; ============================================================ --- cmd_merging.cc 4d403e14031d2efa2e447ee2a533cfe941730394 +++ cmd_merging.cc 8960af5e11ed8cc50bb05dc3dd29bd438287df5b @@ -213,8 +213,7 @@ CMD(update, "update", "", CMD_REF(worksp P(F("already up to date at %s") % old_rid); // do still switch the workspace branch, in case they have used // update to switch branches. - if (!app.opts.branchname().empty()) - app.make_branch_sticky(); + app.write_options(true); return; } @@ -303,9 +302,8 @@ CMD(update, "update", "", CMD_REF(worksp app.work.put_work_rev(remaining); app.work.update_any_attrs(db); app.work.maybe_update_inodeprints(db); + app.write_options(true); - if (!app.opts.branchname().empty()) - app.make_branch_sticky(); if (switched_branch) P(F("switched branch; next commit will use branch %s") % app.opts.branchname()); P(F("updated to base revision %s") % chosen_rid); ============================================================ --- cmd_ws_commit.cc bc75003a35d2e994c039c38f3bbb8d2d90bf3f7c +++ cmd_ws_commit.cc 45743e541263b5feb6f6e605b9431a6f86688211 @@ -1082,7 +1082,6 @@ CMD(commit, "commit", "ci", CMD_REF(work cset excluded; app.require_workspace(); - app.make_branch_sticky(); app.work.get_parent_rosters(db, old_rosters); app.work.get_current_roster_shape(db, nis, new_roster); @@ -1269,6 +1268,9 @@ CMD(commit, "commit", "ci", CMD_REF(work guard.commit(); } + // the workspace should remember the branch we just committed to. + app.write_options(true); + // the work revision is now whatever changes remain on top of the revision // we just checked in. revision_t remaining; ============================================================ --- monotone.cc c73711529cf72e60813e162d9f80225a1ac2c400 +++ monotone.cc 5d6d40f09d80ce2fa27a125625aeeb71051dfbd6 @@ -206,19 +206,32 @@ cpp_main(int argc, char ** argv) return 0; } - // at this point we allow a workspace (meaning search for it - // and if found read _MTN/options, but don't use the data quite - // yet, and read all the monotonercs). Processing the data - // from _MTN/options happens later. + // at this point we allow a workspace (meaning search for it, + // and if found, change directory to it // Certain commands may subsequently require a workspace or fail // if we didn't find one at this point. - app.allow_workspace(); + app.found_workspace = find_and_go_to_workspace(app.opts.root); + // Load all available monotonercs. If we found a workspace above, + // we'll pick up _MTN/monotonerc as well as the user's monotonerc. + app.lua.load_rcfiles(app.opts); + // now grab any command specific options and parse the command // this needs to happen after the monotonercs have been read commands::command_id cmd = read_options(app.opts, optset, opt_args); - if (!app.found_workspace) + if (app.found_workspace) + { + bookkeeping_path dump_path; + app.work.get_local_dump_path(dump_path); + + // The 'false' means that, e.g., if we're running checkout, + // then it's okay for dumps to go into our starting working + // dir's _MTN rather than the new workspace dir's _MTN. + global_sanity.set_dump_path(system_path(dump_path, false) + .as_external()); + } + else global_sanity.set_dump_path((app.opts.conf_dir / "dump") .as_external());