# # # patch "NEWS" # from [f0451ac63f4685bad1d2d41f78007d68e0ae1700] # to [13cc96981011b0e0e5311f0cefaa6729f5c7ee2c] # # patch "cmd_automate.cc" # from [580588418ece14e8bf1c1b4db3db02829127c565] # to [ae6e3bf90ed1c87f83be06b947ebf18dd2873b24] # # patch "options.cc" # from [ba83b047efc456f0c45b6bcb9662634c1aaa3ac9] # to [3fd2f0ffb4e8d250dc905a4461c1cdf43df0a88d] # # patch "options.hh" # from [8af2d2fa88a70d3f8cec1331fb8e5823adc74849] # to [7bcd146217355875a516967d93b97f7f7a4db2a3] # ============================================================ --- NEWS f0451ac63f4685bad1d2d41f78007d68e0ae1700 +++ NEWS 13cc96981011b0e0e5311f0cefaa6729f5c7ee2c @@ -87,6 +87,9 @@ much more selectively in the same manner that content and name changes are applied. + - mtn automate stdio previously didn't reset global options which were + set or changed by a previously executed command; this has been fixed. + New features - The `mtn_automate' lua function now correctly parses and sets ============================================================ --- cmd_automate.cc 580588418ece14e8bf1c1b4db3db02829127c565 +++ cmd_automate.cc ae6e3bf90ed1c87f83be06b947ebf18dd2873b24 @@ -361,6 +361,8 @@ CMD_AUTOMATE(stdio, "", // immediately if a version discrepancy exists db.ensure_open(); + options original_opts = app.opts; + automate_ostream os(output, app.opts.automate_stdio_size); automate_reader ar(std::cin); vector > params; @@ -408,11 +410,6 @@ CMD_AUTOMATE(stdio, "", cmd = CMD_REF(automate)->find_command(id); I(cmd != NULL); - // reset the application's global options - options::options_type opts; - opts = options::opts::all_options() - options::opts::globals(); - opts.instantiate(&app.opts).reset(); - if (cmd->use_workspace_options()) { // Re-read the ws options file, rather than just copying @@ -422,9 +419,9 @@ CMD_AUTOMATE(stdio, "", workspace::get_options(app.opts); } + options::options_type opts; opts = options::opts::globals() | cmd->opts(); opts.instantiate(&app.opts).from_key_value_pairs(params); - } // FIXME: we need to re-package and rethrow this special exception // since it is not based on informative_failure @@ -450,6 +447,9 @@ CMD_AUTOMATE(stdio, "", automate const * acmd = dynamic_cast< automate const * >(cmd); I(acmd); acmd->exec_from_automate(app, id, args, os); + // set app.opts to the originally given options + // so the next command has an identical setup + app.opts = original_opts; } catch(recoverable_failure & f) { ============================================================ --- options.cc ba83b047efc456f0c45b6bcb9662634c1aaa3ac9 +++ options.cc 3fd2f0ffb4e8d250dc905a4461c1cdf43df0a88d @@ -101,6 +101,26 @@ options::options() # undef OPTSET_REL } +const options & +options::operator = (options const & other) +{ +# define OPTSET(name) +# define OPTVAR(group, type, name, default_) \ + name = other.name; +# define OPTION(optset, name, hasarg, optstring, description) \ + name ## _given = other.name ## _given; +# define OPTSET_REL(parent, child) + +# include "options_list.hh" + +# undef OPTSET +# undef OPTVAR +# undef OPTION +# undef OPTSET_REL + + return *this; +} + static options::options_type collect_children(options::static_options_fun opt) { @@ -189,7 +209,6 @@ options::options_type const & options::o # undef OPTION # undef OPTSET_REL - option::option_set operator | (option::option_set const & opts, option::option_set const & (*fun)()) ============================================================ --- options.hh 8af2d2fa88a70d3f8cec1331fb8e5823adc74849 +++ options.hh 7bcd146217355875a516967d93b97f7f7a4db2a3 @@ -26,6 +26,7 @@ struct options struct options { options(); + const options & operator = (options const & other); typedef boost::function reset_function; typedef option::option option_type;