# # # patch "cmd.hh" # from [6bd31b3c5f20311811d208ec0255abbd2012c9cb] # to [bd53821a5daaf2e2b6731ffa18c0f64d5388568e] # # patch "cmd_automate.cc" # from [a597c37937f9c9771db4c92d450bcd545c57158f] # to [80402564622e7c6db7e25bdbae95c70d9215fe65] # # patch "cmd_diff_log.cc" # from [0a948c2b416b4c325c8702ebe824a8b007ddc28f] # to [5202385ce32ba2e2e41ae2c99c7cff579ce9e491] # # patch "cmd_merging.cc" # from [fe110559e7d83804c10fb36352b9ea22de724861] # to [d9ab554e280d2364e2faf8e5ba6db5376dbeb0e3] # # patch "cmd_ws_commit.cc" # from [7f18334033c144ff6d9027e0bbedc92ebbb9de5c] # to [ac359c1689f1151900da5dd130319956a658b6f1] # # patch "commands.cc" # from [dbbbf822e108aef1d4cd220bc5c1fb63bfadca59] # to [e367cd7602398b96d4b5cd34882f0b43d97ffe97] # # patch "selectors.cc" # from [acbef6eec0355e5d85a3a775de4fcb2cecb7e252] # to [f36b8286536456f635dc8a3ec6ff9f64c6560eeb] # ============================================================ --- cmd.hh 6bd31b3c5f20311811d208ec0255abbd2012c9cb +++ cmd.hh bd53821a5daaf2e2b6731ffa18c0f64d5388568e @@ -110,9 +110,9 @@ namespace commands // all automation commands. Also, this is also needed by the "stdio" // automation, as it executes multiple of these commands sharing the // same initialization, hence the friend declaration. - virtual void exec_from_automate(args_vector args, + virtual void exec_from_automate(app_state & app, command_id const & execid, - app_state & app, + args_vector const & args, std::ostream & output) const = 0; friend class automate_stdio; @@ -163,10 +163,10 @@ void bool ignore_suspend_certs); void -process_commit_message_args(bool & given, +process_commit_message_args(options const & opts, + bool & given, utf8 & log_message, - app_state & app, - utf8 message_prefix = utf8("")); + utf8 const & message_prefix = utf8()); #define CMD_FWD_DECL(C) \ namespace commands { \ @@ -260,9 +260,9 @@ namespace commands { namespace commands { \ class automate_ ## C : public automate \ { \ - void exec_from_automate(args_vector args, \ + void exec_from_automate(app_state & app, \ command_id const & execid, \ - app_state & app, \ + args_vector const & args, \ std::ostream & output) const; \ public: \ automate_ ## C() : automate(#C, params, abstract, desc, \ @@ -272,9 +272,9 @@ void commands::automate_ ## C :: exec_fr automate_ ## C C ## _automate; \ } \ void commands::automate_ ## C :: exec_from_automate \ - (args_vector args, \ + (app_state & app, \ command_id const & execid, \ - app_state & app, \ + args_vector const & args, \ std::ostream & output) const #define CMD_REQUIRES_DATABASE(app) \ ============================================================ --- cmd_automate.cc a597c37937f9c9771db4c92d450bcd545c57158f +++ cmd_automate.cc 80402564622e7c6db7e25bdbae95c70d9215fe65 @@ -50,7 +50,7 @@ namespace commands { std::ostream & output) const { make_io_binary(); - exec_from_automate(args, execid, app, output); + exec_from_automate(app, execid, args, output); } void @@ -400,7 +400,7 @@ CMD_AUTOMATE(stdio, "", opts = options::opts::globals() | acmd->opts(); opts.instantiate(&app.opts).from_key_value_pairs(params); - acmd->exec_from_automate(args, id, app, os); + acmd->exec_from_automate(app, id, args, os); } else opts.instantiate(&app.opts).from_key_value_pairs(params); ============================================================ --- cmd_diff_log.cc 0a948c2b416b4c325c8702ebe824a8b007ddc28f +++ cmd_diff_log.cc 5202385ce32ba2e2e41ae2c99c7cff579ce9e491 @@ -183,9 +183,8 @@ static void } static void -do_external_diff(cset const & cs, - app_state & app, - bool new_is_archived) +do_external_diff(options & opts, lua_hooks & lua, database & db, + cset const & cs, bool new_is_archived) { for (map >::const_iterator i = cs.deltas_applied.begin(); @@ -195,13 +194,13 @@ do_external_diff(cset const & cs, data data_new; file_data f_old; - app.db.get_file_version(delta_entry_src(i), f_old); + db.get_file_version(delta_entry_src(i), f_old); data_old = f_old.inner(); if (new_is_archived) { file_data f_new; - app.db.get_file_version(delta_entry_dst(i), f_new); + db.get_file_version(delta_entry_dst(i), f_new); data_new = f_new.inner(); } else @@ -214,23 +213,26 @@ do_external_diff(cset const & cs, guess_binary(data_new())) is_binary = true; - app.lua.hook_external_diff(delta_entry_path(i), - data_old, - data_new, - is_binary, - app.opts.external_diff_args_given, - app.opts.external_diff_args, - delta_entry_src(i).inner()(), - delta_entry_dst(i).inner()()); + lua.hook_external_diff(delta_entry_path(i), + data_old, + data_new, + is_binary, + opts.external_diff_args_given, + opts.external_diff_args, + delta_entry_src(i).inner()(), + delta_entry_dst(i).inner()()); } } static void -dump_diffs(cset const & cs, - app_state & app, +dump_diffs(lua_hooks & lua, + database & db, + cset const & cs, + set const & paths, + std::ostream & output, + diff_type diff_format, bool new_is_archived, - std::ostream & output, - set const & paths, + bool show_encloser, bool limit_paths = false) { // 60 is somewhat arbitrary, but less than 80 @@ -250,7 +252,7 @@ dump_diffs(cset const & cs, if (new_is_archived) { file_data dat; - app.db.get_file_version(i->second, dat); + db.get_file_version(i->second, dat); unpacked = dat.inner(); } else @@ -259,15 +261,15 @@ dump_diffs(cset const & cs, } std::string pattern(""); - if (!app.opts.no_show_encloser) - app.lua.hook_get_encloser_pattern(i->first, pattern); + if (show_encloser) + lua.hook_get_encloser_pattern(i->first, pattern); make_diff(i->first.as_internal(), i->first.as_internal(), i->second, i->second, data(), unpacked, - output, app.opts.diff_format, pattern); + output, diff_format, pattern); } map reverse_rename_map; @@ -291,13 +293,13 @@ dump_diffs(cset const & cs, output << patch_sep << '\n'; - app.db.get_file_version(delta_entry_src(i), f_old); + db.get_file_version(delta_entry_src(i), f_old); data_old = f_old.inner(); if (new_is_archived) { file_data f_new; - app.db.get_file_version(delta_entry_dst(i), f_new); + db.get_file_version(delta_entry_dst(i), f_new); data_new = f_new.inner(); } else @@ -313,34 +315,38 @@ dump_diffs(cset const & cs, src_path = re->second; std::string pattern(""); - if (!app.opts.no_show_encloser) - app.lua.hook_get_encloser_pattern(src_path, - pattern); + if (show_encloser) + lua.hook_get_encloser_pattern(src_path, pattern); make_diff(src_path.as_internal(), dst_path.as_internal(), delta_entry_src(i), delta_entry_dst(i), data_old, data_new, - output, app.opts.diff_format, pattern); + output, diff_format, pattern); } } static void -dump_diffs(cset const & cs, - app_state & app, +dump_diffs(lua_hooks & lua, + database & db, + cset const & cs, + std::ostream & output, + diff_type diff_format, bool new_is_archived, - std::ostream & output) + bool show_encloser) { set dummy; - dump_diffs(cs, app, new_is_archived, output, dummy); + dump_diffs(lua, db, cs, dummy, output, + diff_format, new_is_archived, show_encloser); } // common functionality for diff and automate content_diff to determine // revisions and rosters which should be diffed +// FIXME needs app_state for require_workspace static void -prepare_diff(cset & included, - app_state & app, +prepare_diff(app_state & app, + cset & included, args_vector args, bool & new_is_archived, std::string & revheader) @@ -494,7 +500,7 @@ CMD(diff, "diff", "di", CMD_REF(informat std::string revs; bool new_is_archived; - prepare_diff(included, app, args, new_is_archived, revs); + prepare_diff(app, included, args, new_is_archived, revs); data summary; write_cset(included, summary); @@ -517,11 +523,13 @@ CMD(diff, "diff", "di", CMD_REF(informat if (app.opts.diff_format == external_diff) { - do_external_diff(included, app, new_is_archived); + do_external_diff(app.opts, app.lua, app.db, included, new_is_archived); } else { - dump_diffs(included, app, new_is_archived, cout); + dump_diffs(app.lua, app.db, included, cout, + app.opts.diff_format, new_is_archived, + !app.opts.no_show_encloser); } } @@ -542,15 +550,14 @@ CMD_AUTOMATE(content_diff, N_("[FILE [.. options::opts::revision | options::opts::depth | options::opts::exclude) { - // FIXME: prepare_diff and dump_diffs should not take 'app' argument. - cset included; std::string dummy_header; bool new_is_archived; - prepare_diff(included, app, args, new_is_archived, dummy_header); + prepare_diff(app, included, args, new_is_archived, dummy_header); - dump_diffs(included, app, new_is_archived, output); + dump_diffs(app.lua, app.db, included, output, + app.opts.diff_format, new_is_archived, !app.opts.no_show_encloser); } @@ -918,8 +925,9 @@ CMD(log, "log", "", CMD_REF(informative) { for (edge_map::const_iterator e = rev.edges.begin(); e != rev.edges.end(); ++e) - dump_diffs(edge_changes(e), app, true, out, - diff_paths, !mask.empty()); + dump_diffs(app.lua, app.db, edge_changes(e), diff_paths, out, + app.opts.diff_format, true, + !app.opts.no_show_encloser, !mask.empty()); } if (next > 0) ============================================================ --- cmd_merging.cc fe110559e7d83804c10fb36352b9ea22de724861 +++ cmd_merging.cc d9ab554e280d2364e2faf8e5ba6db5376dbeb0e3 @@ -86,14 +86,14 @@ static bool } static bool -pick_branch_for_update(revision_id chosen_rid, app_state & app) +pick_branch_for_update(options & opts, database & db, revision_id chosen_rid) { bool switched_branch = false; // figure out which branches the target is in vector< revision > certs; - app.db.get_revision_certs(chosen_rid, branch_cert_name, certs); - erase_bogus_certs(app.db, certs); + db.get_revision_certs(chosen_rid, branch_cert_name, certs); + erase_bogus_certs(db, certs); set< branch_name > branches; for (vector< revision >::const_iterator i = certs.begin(); @@ -104,9 +104,9 @@ pick_branch_for_update(revision_id chose branches.insert(branch_name(b())); } - if (branches.find(app.opts.branchname) != branches.end()) + if (branches.find(opts.branchname) != branches.end()) { - L(FL("using existing branch %s") % app.opts.branchname()); + L(FL("using existing branch %s") % opts.branchname()); } else { @@ -124,7 +124,7 @@ pick_branch_for_update(revision_id chose else if (branches.size() == 1) { // one non-matching, inform and update - app.opts.branchname = *(branches.begin()); + opts.branchname = *(branches.begin()); switched_branch = true; } else @@ -132,7 +132,7 @@ pick_branch_for_update(revision_id chose I(branches.size() == 0); W(F("target revision not in any branch\n" "next commit will use branch %s") - % app.opts.branchname); + % opts.branchname); } } return switched_branch; @@ -221,7 +221,7 @@ CMD(update, "update", "", CMD_REF(worksp // Fiddle around with branches, in an attempt to guess what the user // wants. - bool switched_branch = pick_branch_for_update(chosen_rid, app); + bool switched_branch = pick_branch_for_update(app.opts, app.db, chosen_rid); if (switched_branch) P(F("switching to branch %s") % app.opts.branchname()); @@ -646,7 +646,7 @@ CMD(merge_into_dir, "merge_into_dir", "" bool log_message_given; utf8 log_message; - process_commit_message_args(log_message_given, log_message, app); + process_commit_message_args(app.opts, log_message_given, log_message); if (!log_message_given) log_message = utf8((FL("propagate from branch '%s' (head %s)\n" " to branch '%s' (head %s)\n") ============================================================ --- cmd_ws_commit.cc 7f18334033c144ff6d9027e0bbedc92ebbb9de5c +++ cmd_ws_commit.cc ac359c1689f1151900da5dd130319956a658b6f1 @@ -97,16 +97,17 @@ static void } static void -get_log_message_interactively(revision_t const & cs, - app_state & app, +get_log_message_interactively(lua_hooks & lua, workspace & work, + revision_t const & cs, + branch_name const & branchname, utf8 & log_message) { utf8 summary; - revision_summary(cs, app.opts.branchname, summary); + revision_summary(cs, branchname, summary); external summary_external; utf8_to_system_best_effort(summary, summary_external); - utf8 branch_comment = utf8((F("branch \"%s\"\n\n") % app.opts.branchname).str()); + utf8 branch_comment = utf8((F("branch \"%s\"\n\n") % branchname).str()); external branch_external; utf8_to_system_best_effort(branch_comment, branch_external); @@ -123,7 +124,7 @@ get_log_message_interactively(revision_t external commentary(commentary_str); utf8 user_log_message; - app.work.read_user_log(user_log_message); + work.read_user_log(user_log_message); //if the _MTN/log file was non-empty, we'll append the 'magic' line utf8 user_log; @@ -136,8 +137,8 @@ get_log_message_interactively(revision_t utf8_to_system_best_effort(user_log, user_log_message_external); external log_message_external; - N(app.lua.hook_edit_comment(commentary, user_log_message_external, - log_message_external), + N(lua.hook_edit_comment(commentary, user_log_message_external, + log_message_external), F("edit of log message failed")); N(log_message_external().find(magic_line) == string::npos, @@ -356,7 +357,7 @@ CMD(disapprove, "disapprove", "", CMD_RE guess_branch(app.opts, project, r); N(app.opts.branchname() != "", F("need --branch argument for disapproval")); - process_commit_message_args(log_message_given, log_message, app, + process_commit_message_args(app.opts, log_message_given, log_message, utf8((FL("disapproval of revision '%s'") % r).str())); cache_user_key(app.opts, app.lua, app.db, keys); @@ -1113,7 +1114,7 @@ CMD(commit, "commit", "ci", CMD_REF(work % restricted_rev.new_manifest % restricted_rev_id); - process_commit_message_args(log_message_given, log_message, app); + process_commit_message_args(app.opts, log_message_given, log_message); N(!(log_message_given && app.work.has_contents_user_log()), F("_MTN/log is non-empty and log message " @@ -1124,9 +1125,9 @@ CMD(commit, "commit", "ci", CMD_REF(work if (!log_message_given) { // This call handles _MTN/log. + get_log_message_interactively(app.lua, app.work, restricted_rev, + app.opts.branchname, log_message); - get_log_message_interactively(restricted_rev, app, log_message); - // We only check for empty log messages when the user entered them // interactively. Consensus was that if someone wanted to explicitly // type --message="", then there wasn't any reason to stop them. ============================================================ --- commands.cc dbbbf822e108aef1d4cd220bc5c1fb63bfadca59 +++ commands.cc e367cd7602398b96d4b5cd34882f0b43d97ffe97 @@ -905,28 +905,28 @@ void } void -process_commit_message_args(bool & given, +process_commit_message_args(options const & opts, + bool & given, utf8 & log_message, - app_state & app, - utf8 message_prefix) + utf8 const & message_prefix) { // can't have both a --message and a --message-file ... - N(!app.opts.message_given || !app.opts.msgfile_given, + N(!opts.message_given || !opts.msgfile_given, F("--message and --message-file are mutually exclusive")); - if (app.opts.message_given) + if (opts.message_given) { string msg; - join_lines(app.opts.message, msg); + join_lines(opts.message, msg); log_message = utf8(msg); if (message_prefix().length() != 0) log_message = utf8(message_prefix() + "\n\n" + log_message()); given = true; } - else if (app.opts.msgfile_given) + else if (opts.msgfile_given) { data dat; - read_data_for_command_line(app.opts.msgfile, dat); + read_data_for_command_line(opts.msgfile, dat); external dat2 = external(dat()); system_to_utf8(dat2, log_message); if (message_prefix().length() != 0) ============================================================ --- selectors.cc acbef6eec0355e5d85a3a775de4fcb2cecb7e252 +++ selectors.cc f36b8286536456f635dc8a3ec6ff9f64c6560eeb @@ -47,10 +47,10 @@ static void typedef vector > selector_list; static void -decode_selector(string const & orig_sel, +decode_selector(app_state & app, + string const & orig_sel, selector_type & type, - string & sel, - app_state & app) + string & sel) { sel = orig_sel; @@ -175,8 +175,7 @@ static void } static void -parse_selector(string const & str, selector_list & sels, - app_state & app) +parse_selector(app_state & app, string const & str, selector_list & sels) { sels.clear(); @@ -202,7 +201,7 @@ parse_selector(string const & str, selec string sel; selector_type type = sel_unknown; - decode_selector(*i, type, sel, app); + decode_selector(app, *i, type, sel); sels.push_back(make_pair(type, sel)); } } @@ -336,7 +335,7 @@ complete(app_state & app, set & completions) { selector_list sels; - parse_selector(str, sels, app); + parse_selector(app, str, sels); // avoid logging if there's no expansion to be done if (sels.size() == 1 @@ -391,7 +390,7 @@ expand_selector(app_state & app, set & completions) { selector_list sels; - parse_selector(str, sels, app); + parse_selector(app, str, sels); // avoid logging if there's no expansion to be done if (sels.size() == 1