# # # patch "cmd_automate.cc" # from [5d377f31e2714ebdd959bb4a7d9c9e6e4f1de8b9] # to [eaa948261c63f4bf76d6e8c646e8ec7361333474] # # patch "cmd_netsync.cc" # from [60d61b8d3dfa4bffd394f2bcc70f2970ba41e6c4] # to [754f438fb04a0d11fc076b611aab56496d927a14] # # patch "cmd_ws_commit.cc" # from [8f12395a73d4c2fbd19e4eac883b719e581d0ae7] # to [f8dc69b9abbc64d40b7ee151e624bfa3990ffb9b] # # patch "monotone.cc" # from [93efe8898e46a4888eff29a34a77bfedbe7172ce] # to [d6ffaa534444ebd7fa7845054fc3825a5d6f00d4] # # patch "network/automate_session.cc" # from [69fcc9df864eb5edfdd8e0472846d7698add6a3b] # to [6a5a30794cca1274cee04eeb4d672fc4c8e4602d] # # patch "selectors.cc" # from [952f8becd5473558a75ceff46a93feb310756908] # to [3dc0d2b2b0d271f2e96a1afacb43d7565b03f4c2] # # patch "work.cc" # from [179aa79ab655680e20b6acbd160b464e2803f94d] # to [dde5e4d1352d7b6e34823b600930ddcb791a9796] # # patch "work.hh" # from [12a0cb4870fdb76affdfed725039d7407be701b8] # to [f57aad376673bbda8271fcfd2d92e97241f05700] # ============================================================ --- cmd_automate.cc 5d377f31e2714ebdd959bb4a7d9c9e6e4f1de8b9 +++ cmd_automate.cc eaa948261c63f4bf76d6e8c646e8ec7361333474 @@ -323,6 +323,14 @@ CMD_AUTOMATE_NO_STDIO(stdio, "", acmd->exec_from_automate(app, id, args, os); os.end_cmd(0); + // usually, if a command succeeds, any of its workspace-relevant + // options are saved back to _MTN/options, this shouldn't be + // any different here + if (workspace::found) + { + workspace::set_options(app.opts); + } + // restore app.opts app.opts = original_opts; } @@ -462,6 +470,14 @@ LUAEXT(mtn_automate, ) I(acmd); acmd->exec(*app_p, id, app_p->opts.args, os); + // usually, if a command succeeds, any of its workspace-relevant + // options are saved back to _MTN/options, this shouldn't be + // any different here + if (workspace::found) + { + workspace::set_options(app_p->opts); + } + // allow further calls app_p->mtn_automate_allowed = true; } ============================================================ --- cmd_netsync.cc 60d61b8d3dfa4bffd394f2bcc70f2970ba41e6c4 +++ cmd_netsync.cc 754f438fb04a0d11fc076b611aab56496d927a14 @@ -607,7 +607,7 @@ CMD(sync, "sync", "", CMD_REF(network), { // Write workspace options, including key; this is the simplest way to // fix a "found multiple keys" error reported by sync. - workspace work(app, true); + workspace::set_options(app.opts); } run_netsync_protocol(app, app.opts, app.lua, project, keys, @@ -632,7 +632,7 @@ CMD_AUTOMATE(sync, N_("[ADDRESS[:PORTNUM { // Write workspace options, including key; this is the simplest way to // fix a "found multiple keys" error reported by sync. - workspace work(app, true); + workspace::set_options(app.opts); } run_netsync_protocol(app, app.opts, app.lua, project, keys, ============================================================ --- cmd_ws_commit.cc 8f12395a73d4c2fbd19e4eac883b719e581d0ae7 +++ cmd_ws_commit.cc f8dc69b9abbc64d40b7ee151e624bfa3990ffb9b @@ -1516,7 +1516,7 @@ CMD_NO_WORKSPACE(migrate_workspace, "mig workspace::found = true; } - workspace work(app, false); + workspace work(app); work.migrate_format(); } ============================================================ --- monotone.cc 93efe8898e46a4888eff29a34a77bfedbe7172ce +++ monotone.cc d6ffaa534444ebd7fa7845054fc3825a5d6f00d4 @@ -283,6 +283,12 @@ cpp_main(int argc, char ** argv) commands::process(app, cmd, app.opts.args); + + if (workspace::found) + { + workspace::set_options(app.opts); + } + // The command will raise any problems itself through // exceptions. If we reach this point, it is because it // worked correctly. ============================================================ --- network/automate_session.cc 69fcc9df864eb5edfdd8e0472846d7698add6a3b +++ network/automate_session.cc 6a5a30794cca1274cee04eeb4d672fc4c8e4602d @@ -254,6 +254,15 @@ bool automate_session::do_work(transacti try { acmd->exec_from_automate(app, id, args, oss); + + // usually, if a command succeeds, any of its workspace-relevant + // options are saved back to _MTN/options, this shouldn't be + // any different here + if (workspace::found) + { + workspace::set_options(app.opts); + } + // restore app.opts app.opts = original_opts; } ============================================================ --- selectors.cc 952f8becd5473558a75ceff46a93feb310756908 +++ selectors.cc 3dc0d2b2b0d271f2e96a1afacb43d7565b03f4c2 @@ -186,7 +186,7 @@ decode_selector(options const & opts, lu case sel_parent: if (sel.empty()) { - workspace work(opts, lua, F("the empty parent selector p: refers to " + workspace work(lua, F("the empty parent selector p: refers to " "the base revision of the workspace")); parent_map parents; @@ -209,7 +209,7 @@ decode_selector(options const & opts, lu E(sel.empty(), origin::user, F("no value is allowed with the update selector u:")); { - workspace work(opts, lua, F("the update selector u: refers to the " + workspace work(lua, F("the update selector u: refers to the " "revision before the last update in the " "workspace")); revision_id update_id; @@ -368,7 +368,7 @@ complete_one_selector(options const & op case sel_base: { - workspace work(opts, lua, F("the selector w: returns the " + workspace work(lua, F("the selector w: returns the " "base revision(s) of the workspace")); parent_map parents; work.get_parent_rosters(project.db, parents); ============================================================ --- work.cc 179aa79ab655680e20b6acbd160b464e2803f94d +++ work.cc dde5e4d1352d7b6e34823b600930ddcb791a9796 @@ -180,30 +180,22 @@ workspace::create_workspace(options cons } // Normal-use constructor. -workspace::workspace(app_state & app, bool writeback_options) +workspace::workspace(app_state & app) : lua(app.lua) { require_workspace(); - if (writeback_options) - set_options(app.opts, false); } -workspace::workspace(app_state & app, i18n_format const & explanation, - bool writeback_options) +workspace::workspace(app_state & app, i18n_format const & explanation) : lua(app.lua) { require_workspace(explanation); - if (writeback_options) - set_options(app.opts, false); } -workspace::workspace(options const & opts, lua_hooks & lua, - i18n_format const & explanation, bool writeback_options) +workspace::workspace(lua_hooks & lua, i18n_format const & explanation) : lua(lua) { require_workspace(explanation); - if (writeback_options) - set_options(opts, false); } // routines for manipulating the bookkeeping directory @@ -553,6 +545,10 @@ workspace::get_database_option(system_pa workspace_key, workspace_keydir); } +// This function should usually be called at the (successful) +// execution of a function, because we don't do many checks here, f.e. +// if this is a valid sqlite file and if it contains the correct identifier, +// so be warned that you do not call this too early void workspace::set_options(options const & opts, bool branch_is_sticky) { @@ -573,10 +569,6 @@ workspace::set_options(options const & o workspace_database, workspace_branch, workspace_key, workspace_keydir); - // FIXME: we should do more checks here, f.e. if this is a valid sqlite - // file and if it contains the correct identifier, but these checks would - // duplicate those in database.cc. At the time it is checked there, however, - // the options file for the workspace is already written out... bool options_changed = false; if (!opts.dbname.as_internal().empty() && @@ -596,7 +588,7 @@ workspace::set_options(options const & o } if ((branch_is_sticky || workspace::branch_is_sticky) && - !opts.branch().empty() && + !opts.branch().empty() && workspace_branch != opts.branch) { workspace_branch = opts.branch; @@ -611,9 +603,12 @@ workspace::set_options(options const & o // only rewrite the options file if there are actual changes if (options_changed) - write_options_file(o_path, - workspace_database, workspace_branch, - workspace_key, workspace_keydir); + { + L(FL("workspace options changed - writing back to _MTN/options")); + write_options_file(o_path, + workspace_database, workspace_branch, + workspace_key, workspace_keydir); + } } void ============================================================ --- work.hh 12a0cb4870fdb76affdfed725039d7407be701b8 +++ work.hh f57aad376673bbda8271fcfd2d92e97241f05700 @@ -123,11 +123,9 @@ public: // Constructor. In normal usage, calling this transitions from the state // where there may or may not be a workspace to the state where there // definitely is. - explicit workspace(app_state & app, bool writeback_options = true); - explicit workspace(app_state & app, i18n_format const & explanation, - bool writeback_options = true); - explicit workspace(options const & opts, lua_hooks & lua, - i18n_format const & explanation, bool writeback_options = true); + explicit workspace(app_state & app); + explicit workspace(app_state & app, i18n_format const & explanation); + explicit workspace(lua_hooks & lua, i18n_format const & explanation); // Methods for manipulating the workspace's content. void find_missing(roster_t const & new_roster_shape, @@ -232,7 +230,7 @@ public: static void get_options(options & opts); static void get_database_option(system_path const & workspace_root, system_path & database_option); - static void set_options(options const & opts, bool branch_is_sticky); + static void set_options(options const & opts, bool branch_is_sticky = false); static void print_option(utf8 const & opt, std::ostream & output); // the "bisect" infromation file is a file that records current status