# # old_revision [3dfd6e2f7ba8a63a6a33de8e1f48a6c7714c61d3] # # patch "app_state.cc" # from [b6b5c4ce81c896c9ec30ae1ce7a2566544ea9604] # to [1ac11de8b02eac2df5ed4828d67c287808764a57] # # patch "app_state.hh" # from [d29cbc5965798994b564e7841752d1b7159d33b1] # to [7f0282fa78e9b84649b9793df28cd184c176bd3d] # # patch "cmd_merging.cc" # from [3eb23261c6e8c791574c49e100a40f4ccf15e4ab] # to [1814c5fb1a19405e7317492702678a0860532fec] # # patch "cmd_ws_commit.cc" # from [970eb21298fe1bea992478c5b97455bbd34a2159] # to [2fb3d9649e5febe36820b0603140fc4686963606] # # patch "commands.cc" # from [79edb01e23e7bac3b6b0c8096687f6309e2d4ed9] # to [e47c715e0d008366d4b473ec02410c88b264ecd1] # # patch "database.cc" # from [7f4dd6f538de13dbc1c35c3bd9a2f6966250fa69] # to [083ddf93278561d25ed5ad2aa5e63240fb0b1000] # # patch "monotone.cc" # from [17b0f570b6adf772aa4a603e94ba1dfda1992db1] # to [2cc94ffaf349a01352665203bf5308ed239d20e6] # # patch "netsync.cc" # from [f0700b1fdfefd473485be59bc572f4153ce72bab] # to [816746f3fc709badab6c8082986cbf18fe1e995f] # # patch "roster.cc" # from [d03806d489e8b30fc4564b9a4f025669770403d6] # to [bd80eae12d6628fe93c1963e09201a2957ac1bd8] # # patch "ui.cc" # from [75ec26afdc2f781818facabaf95ea615e76f5737] # to [359b41c16854dc2b42a42449e9613079f1a95949] # # patch "ui.hh" # from [7b8cd80da4eb57f413e10d25b812e9ae16353fae] # to [ea2c11aaa5de4bc00851ee8bb7a9730f509c93fc] # ============================================================ --- app_state.cc b6b5c4ce81c896c9ec30ae1ce7a2566544ea9604 +++ app_state.cc 1ac11de8b02eac2df5ed4828d67c287808764a57 @@ -61,7 +61,6 @@ app_state::app_state() db.set_app(this); lua.set_app(this); keys.set_key_dir(confdir / "keys"); - set_prog_name(utf8(string("mtn"))); } app_state::~app_state() @@ -360,13 +359,6 @@ void } void -app_state::set_prog_name(utf8 const & name) -{ - prog_name = name; - ui.set_prog_name(name()); -} - -void app_state::add_rcfile(utf8 const & filename) { extra_rcfiles.push_back(filename); ============================================================ --- app_state.hh d29cbc5965798994b564e7841752d1b7159d33b1 +++ app_state.hh 7f0282fa78e9b84649b9793df28cd184c176bd3d @@ -140,7 +140,6 @@ public: void set_diff_args(utf8 const & args); void add_key_to_push(utf8 const & key); void set_recursive(bool r = true); - void set_prog_name(utf8 const & prog_name); void set_stdhooks(bool b); void set_rcfiles(bool b); @@ -154,10 +153,6 @@ public: explicit app_state(); ~app_state(); - // Only use set_prog_name to set this; changes need to be propagated - // to the global ui object. - utf8 prog_name; - private: void load_rcfiles(); void read_options(); ============================================================ --- cmd_merging.cc 3eb23261c6e8c791574c49e100a40f4ccf15e4ab +++ cmd_merging.cc 1814c5fb1a19405e7317492702678a0860532fec @@ -136,7 +136,7 @@ CMD(update, N_("workspace"), "", for (set::const_iterator i = candidates.begin(); i != candidates.end(); ++i) P(i18n_format(" %s") % describe_revision(app, *i)); - P(F("choose one with '%s update -r'") % app.prog_name); + P(F("choose one with '%s update -r'") % ui.prog_name); E(false, F("multiple update candidates remain after selection")); } chosen_rid = *(candidates.begin()); @@ -706,7 +706,7 @@ CMD(pluck, N_("workspace"), N_("[-r FROM "to apply the changes relative to one of its parents, use:\n" " %s pluck -r PARENT -r %s") % to_rid - % app.prog_name % to_rid); + % ui.prog_name % to_rid); from_rid = *parents.begin(); } else if (app.revision_selectors.size() == 2) ============================================================ --- cmd_ws_commit.cc 970eb21298fe1bea992478c5b97455bbd34a2159 +++ cmd_ws_commit.cc 2fb3d9649e5febe36820b0603140fc4686963606 @@ -428,7 +428,7 @@ CMD(checkout, N_("tree"), N_("[DIRECTORY P(F("branch %s has multiple heads:") % app.branch_name); for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) P(i18n_format(" %s") % describe_revision(app, *i)); - P(F("choose one with '%s checkout -r'") % app.prog_name); + P(F("choose one with '%s checkout -r'") % ui.prog_name); E(false, F("branch %s has multiple heads") % app.branch_name); } ident = *(heads.begin()); @@ -842,7 +842,7 @@ CMD(commit, N_("workspace"), N_("[PATH]. if (heads.size() > old_head_size && old_head_size > 0) { P(F("note: this revision creates divergence\n" "note: you may (or may not) wish to run '%s merge'") - % app.prog_name); + % ui.prog_name); } update_any_attrs(app); ============================================================ --- commands.cc 79edb01e23e7bac3b6b0c8096687f6309e2d4ed9 +++ commands.cc e47c715e0d008366d4b473ec02410c88b264ecd1 @@ -15,7 +15,7 @@ #include "charset.hh" #include "inodeprint.hh" #include "cert.hh" - +#include "ui.hh" #include "cmd.hh" #ifndef _WIN32 @@ -486,7 +486,7 @@ notify_if_multiple_heads(app_state & app _("branch '%s' has multiple heads\n" "perhaps consider '%s merge'"), prefixedline); - P(i18n_format(prefixedline) % app.branch_name % app.prog_name); + P(i18n_format(prefixedline) % app.branch_name % ui.prog_name); } } ============================================================ --- database.cc 7f4dd6f538de13dbc1c35c3bd9a2f6966250fa69 +++ database.cc 083ddf93278561d25ed5ad2aa5e63240fb0b1000 @@ -158,7 +158,7 @@ database::check_schema() "wanted schema %s, got %s\n" "try '%s db migrate' to upgrade\n" "(this is irreversible; you may want to make a backup copy first)") - % filename % schema % db_schema_id % __app->prog_name); + % filename % schema % db_schema_id % ui.prog_name); } void ============================================================ --- monotone.cc 17b0f570b6adf772aa4a603e94ba1dfda1992db1 +++ monotone.cc 2cc94ffaf349a01352665203bf5308ed239d20e6 @@ -107,45 +107,6 @@ struct ui_library } }; - -#if 0 // FIXME! need b::po equiv. -// Read arguments from a file. The special file '-' means stdin. -// Returned value must be free()'d, after arg parsing has completed. -static void -my_poptStuffArgFile(poptContext con, utf8 const & filename) -{ - utf8 argstr; - { - data dat; - read_data_for_command_line(filename, dat); - external ext(dat()); - system_to_utf8(ext, argstr); - } - - const char **argv = 0; - int argc = 0; - int rc; - - // Parse the string. It's OK if there are no arguments. - rc = poptParseArgvString(argstr().c_str(), &argc, &argv); - N(rc >= 0 || rc == POPT_ERROR_NOARG, - F("problem parsing arguments from file %s: %s") - % filename % poptStrerror(rc)); - - if (rc != POPT_ERROR_NOARG) - { - // poptStuffArgs does not take an argc argument, but rather requires that - // the argv array be null-terminated. - I(argv[argc] == NULL); - N((rc = poptStuffArgs(con, argv)) >= 0, - F("weird error when stuffing arguments read from %s: %s\n") - % filename % poptStrerror(rc)); - } - - free(argv); -} -#endif - void tokenize_for_command_line(string const & from, vector & to) { @@ -240,61 +201,35 @@ cpp_main(int argc, char ** argv) // Set up secure memory allocation etc botan_library acquire_botan; - // set up some marked strings, so even if our logbuf overflows, we'll get - // this data in a crash. - string cmdline_string; - { - ostringstream cmdline_ss; - for (int i = 0; i < argc; ++i) - { - if (i) - cmdline_ss << ", "; - cmdline_ss << "'" << argv[i] << "'"; - } - cmdline_string = cmdline_ss.str(); - } - MM(cmdline_string); - L(FL("command line: %s\n") % cmdline_string); + // Record where we are. This has to happen before any use of + // boost::filesystem. + save_initial_path(); - string locale_string = (setlocale(LC_ALL, NULL) == NULL ? "n/a" : setlocale(LC_ALL, NULL)); - MM(locale_string); - L(FL("set locale: LC_ALL=%s\n") % locale_string); - - string full_version_string; - get_full_version(full_version_string); - MM(full_version_string); - - // Set up secure memory allocation etc - Botan::Init::initialize(); - Botan::set_default_allocator("malloc"); - // decode all argv values into a UTF-8 array - save_initial_path(); vector args; - utf8 progname; - for (int i = 0; i < argc; ++i) + for (int i = 1; i < argc; ++i) { external ex(argv[i]); utf8 ut; system_to_utf8(ex, ut); - if (i) - args.push_back(ut()); - else - progname = ut; + args.push_back(ut()); } - // find base name of executable - string prog_path = fs::path(progname()).leaf(); - if (prog_path.rfind(".exe") == prog_path.size() - 4) - prog_path = prog_path.substr(0, prog_path.size() - 4); - utf8 prog_name(prog_path); + // find base name of executable, convert to utf8, and save it in the + // global ui object + { + string prog_name = fs::path(argv[0]).leaf(); + if (prog_name.rfind(".exe") == prog_name.size() - 4) + prog_name = prog_name.substr(0, prog_name.size() - 4); + utf8 prog_name_u; + system_to_utf8(prog_name, prog_name_u); + ui.prog_name = prog_name_u(); + I(!ui.prog_name.empty()); + } app_state app; try { - - app.set_prog_name(prog_name); - // set up for parsing. we add a hidden argument that collections all // positional arguments, which we process ourselves in a moment. po::options_description all_options; @@ -729,12 +664,12 @@ cpp_main(int argc, char ** argv) po::options_description cmd_options_desc = commands::command_options(u.which); unsigned count = cmd_options_desc.options().size(); - cout << F("Usage: %s [OPTION...] command [ARG...]") % prog_name << "\n\n"; + cout << F("Usage: %s [OPTION...] command [ARG...]") % ui.prog_name << "\n\n"; cout << option::global_options << "\n"; if (count > 0) { - cout << F("Options specific to '%s %s':") % prog_name % u.which << "\n\n"; + cout << F("Options specific to '%s %s':") % ui.prog_name % u.which << "\n\n"; cout << cmd_options_desc << "\n"; } ============================================================ --- netsync.cc f0700b1fdfefd473485be59bc572f4153ce72bab +++ netsync.cc 816746f3fc709badab6c8082986cbf18fe1e995f @@ -1242,7 +1242,7 @@ session::process_hello_cmd(rsa_keypair_i "I expected %s\n" "'%s unset %s %s' overrides this check") % their_key_hash % expected_key_hash - % app.prog_name % their_key_key.first % their_key_key.second); + % ui.prog_name % their_key_key.first % their_key_key.second); E(false, F("server key changed")); } } ============================================================ --- roster.cc d03806d489e8b30fc4564b9a4f025669770403d6 +++ roster.cc bd80eae12d6628fe93c1963e09201a2957ac1bd8 @@ -28,6 +28,7 @@ #include "parallel_iter.hh" #include "restrictions.hh" #include "safe_map.hh" +#include "ui.hh" #include @@ -2338,8 +2339,8 @@ update_current_roster_from_filesystem(ro "'%s revert FILE' to restore it\n" "or to handle all at once, simply '%s drop --missing'\n" "or '%s revert --missing'") - % missing_files % app.prog_name % app.prog_name % app.prog_name - % app.prog_name % app.prog_name); + % missing_files % ui.prog_name % ui.prog_name % ui.prog_name + % ui.prog_name % ui.prog_name); } void ============================================================ --- ui.cc 75ec26afdc2f781818facabaf95ea615e76f5737 +++ ui.cc 359b41c16854dc2b42a42449e9613079f1a95949 @@ -397,6 +397,7 @@ user_interface::user_interface() : // any real work. see monotone.cc for how this is handled. user_interface::user_interface() : + prog_name("?"), last_write_was_a_tick(false), t_writer(0) {} @@ -530,13 +531,6 @@ user_interface::fatal_exception() this->fatal("exception of unknown type"); } -void -user_interface::set_prog_name(string const & name) -{ - prog_name = name; - I(!prog_name.empty()); -} - string user_interface::output_prefix() { ============================================================ --- ui.hh 7b8cd80da4eb57f413e10d25b812e9ae16353fae +++ ui.hh ea2c11aaa5de4bc00851ee8bb7a9730f509c93fc @@ -104,8 +104,8 @@ public: void ensure_clean_line(); void redirect_log_to(system_path const & filename); - void set_prog_name(std::string const & name); std::string output_prefix(); + std::string prog_name; private: std::set issued_warnings; @@ -118,8 +118,6 @@ private: void write_ticks(); std::string tick_trailer; - std::string prog_name; - friend struct tick_write_dot; friend struct tick_write_count; friend struct ticker;