# # # patch "automate.cc" # from [e61d4525484552eb8eac7a56cc1270ab921e79a7] # to [ac1ee1778db44574934d4f33ecc6d2d4314830bd] # # patch "cmd.cc" # from [d05a3e8b9fff0b10340e90eb50a4cfcae5f7e1ca] # to [1f3f8ffa73ba004b54bce43df573d61e5a55c0e0] # # patch "cmd_automate.cc" # from [a73f7f3582b7341889daff6d03a27dfc5e1f0290] # to [580588418ece14e8bf1c1b4db3db02829127c565] # # patch "cmd_merging.cc" # from [d87f80673f250737ffde253dcb1884da98c03f4b] # to [1dac535deebfa500d093cf57494e620c65f6f2c6] # # patch "cmd_ws_commit.cc" # from [6eafae7a1ae356aae0765ec5ea2e230c14c34681] # to [d5b67e56feba5368cc5c7bfdd90d510e979c4661] # # patch "migrate_work.cc" # from [21dbcf76b5fa84b60c02577da6c589887c0cc5ba] # to [2a8658dad954b975e65d3ceaf5df608007bfe841] # # patch "work.cc" # from [f72a10818deea7e7140ff2a4be92289238577854] # to [481ece16aab1f54d77ae8816bd39ba8c7e79c801] # # patch "work.hh" # from [48bdba225cedd327acdfd13db63226e76df1ecec] # to [37d90e812bd3f1eff977682b7e363036b4da4f5f] # ============================================================ --- automate.cc e61d4525484552eb8eac7a56cc1270ab921e79a7 +++ automate.cc ac1ee1778db44574934d4f33ecc6d2d4314830bd @@ -1841,7 +1841,7 @@ CMD_AUTOMATE(get_option, N_("OPTION"), F("wrong argument count")); workspace work(app); - work.print_ws_option(args[0], output); + work.print_option(args[0], output); } // Name: get_content_changed ============================================================ --- cmd.cc d05a3e8b9fff0b10340e90eb50a4cfcae5f7e1ca +++ cmd.cc 1f3f8ffa73ba004b54bce43df573d61e5a55c0e0 @@ -111,8 +111,8 @@ namespace commands { // the command needs it. if (cmd->use_workspace_options()) { - workspace::check_ws_format(); - workspace::get_ws_options(app.opts); + workspace::check_format(); + workspace::get_options(app.opts); } cmd->exec(app, ident, args); ============================================================ --- cmd_automate.cc a73f7f3582b7341889daff6d03a27dfc5e1f0290 +++ cmd_automate.cc 580588418ece14e8bf1c1b4db3db02829127c565 @@ -418,8 +418,8 @@ CMD_AUTOMATE(stdio, "", // Re-read the ws options file, rather than just copying // the options from the previous apts.opts object, because // the file may have changed due to user activity. - workspace::check_ws_format(); - workspace::get_ws_options(app.opts); + workspace::check_format(); + workspace::get_options(app.opts); } opts = options::opts::globals() | cmd->opts(); @@ -539,8 +539,8 @@ LUAEXT(mtn_automate, ) // Re-read the ws options file, rather than just copying // the options from the previous apts.opts object, because // the file may have changed due to user activity. - workspace::check_ws_format(); - workspace::get_ws_options(app_p->opts); + workspace::check_format(); + workspace::get_options(app_p->opts); } opts.instantiate(&app_p->opts).from_command_line(args, false); ============================================================ --- cmd_merging.cc d87f80673f250737ffde253dcb1884da98c03f4b +++ cmd_merging.cc 1dac535deebfa500d093cf57494e620c65f6f2c6 @@ -214,7 +214,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. - work.set_ws_options(app.opts, true); + work.set_options(app.opts, true); return; } @@ -303,7 +303,7 @@ CMD(update, "update", "", CMD_REF(worksp work.put_work_rev(remaining); work.update_any_attrs(db); work.maybe_update_inodeprints(db); - work.set_ws_options(app.opts, true); + work.set_options(app.opts, true); if (switched_branch) P(F("switched branch; next commit will use branch %s") % app.opts.branchname()); ============================================================ --- cmd_ws_commit.cc 6eafae7a1ae356aae0765ec5ea2e230c14c34681 +++ cmd_ws_commit.cc d5b67e56feba5368cc5c7bfdd90d510e979c4661 @@ -1301,7 +1301,7 @@ CMD(commit, "commit", "ci", CMD_REF(work } // the workspace should remember the branch we just committed to. - work.set_ws_options(app.opts, true); + work.set_options(app.opts, true); // the work revision is now whatever changes remain on top of the revision // we just checked in. @@ -1491,7 +1491,7 @@ CMD_NO_WORKSPACE(migrate_workspace, "mig } workspace work(app, false); - work.migrate_ws_format(); + work.migrate_format(); } CMD(refresh_inodeprints, "refresh_inodeprints", "", CMD_REF(tree), "", ============================================================ --- migrate_work.cc 21dbcf76b5fa84b60c02577da6c589887c0cc5ba +++ migrate_work.cc 2a8658dad954b975e65d3ceaf5df608007bfe841 @@ -23,7 +23,7 @@ using boost::lexical_cast; using std::exception; using boost::lexical_cast; -// This file's primary entry point is workspace::migrate_ws_format. It is +// This file's primary entry point is workspace::migrate_format. It is // responsible for migrating workspace directories from metadata formats // used by older versions of monotone. This file also defines the other // workspace:: functions related to metadata format. Whenever a new @@ -48,11 +48,11 @@ static const char first_version_supporti // of _MTN/format. Format 0 is even older, and is indicated by the // metadata directory being named "MT", not "_MTN". All these little // details are handled by the following two functions. Note that -// write_ws_format is a public interface, but get_ws_format is not -// (the corresponding public interface is check_ws_format, below). +// write_format is a public interface, but get_workspace_format is not +// (the corresponding public interface is check_format, below). static unsigned int -get_ws_format() +get_workspace_format() { unsigned int format; bookkeeping_path f_path = bookkeeping_root / "format"; @@ -89,7 +89,7 @@ void } void -workspace::write_ws_format() +workspace::write_format() { bookkeeping_path f_path = bookkeeping_root / "format"; // one or other side of this conditional will always be dead code, but @@ -108,17 +108,17 @@ workspace::write_ws_format() } } -// This function is the public face of get_ws_format. It produces +// This function is the public face of get_workspace_format. It produces // suitable error messages if the workspace's format number is not // equal to current_workspace_format. void -workspace::check_ws_format() +workspace::check_format() { if (!workspace::found) return; - unsigned int format = get_ws_format(); + unsigned int format = get_workspace_format(); // Don't give user false expectations about format 0. E(format > 0, origin::system, @@ -139,7 +139,7 @@ workspace::check_ws_format() % format % current_workspace_format % prog_name % first_version_supporting_current_format); - // keep this message in sync with the copy in migrate_ws_format + // keep this message in sync with the copy in migrate_format E(format <= current_workspace_format, origin::system, F("this version of monotone only understands workspace metadata\n" "in formats 0 through %d. your workspace is in format %d.\n" @@ -241,9 +241,9 @@ void // This function is the public face of the migrate_X_to_X+1 functions. void -workspace::migrate_ws_format() +workspace::migrate_format() { - unsigned int format = get_ws_format(); + unsigned int format = get_workspace_format(); // When adding new migrations, note the organization of the first block of // case entries in this switch statement. There are entries each of the @@ -251,7 +251,7 @@ workspace::migrate_ws_format() // migrate__to_ function, AND DROPS THROUGH. Thus, when we // encounter a workspace in format K < C, the migrate_K_to_K+1, // migrate_K+1_to_K+2, ..., migrate_C-1_to_C functions will all be called. - // The last entry drops through to the write_ws_format() line. + // The last entry drops through to the write_format() line. switch (format) { @@ -259,7 +259,7 @@ workspace::migrate_ws_format() case 1: migrate_1_to_2(); // We are now in the current format. - write_ws_format(); + write_format(); break; case current_workspace_format: @@ -269,7 +269,7 @@ workspace::migrate_ws_format() default: I(format > current_workspace_format); - // keep this message in sync with the copy in check_ws_format + // keep this message in sync with the copy in check_format E(false, origin::system, F("this version of monotone only understands workspace metadata\n" "in formats 0 through %d. your workspace is in format %d.\n" ============================================================ --- work.cc f72a10818deea7e7140ff2a4be92289238577854 +++ work.cc 481ece16aab1f54d77ae8816bd39ba8c7e79c801 @@ -139,8 +139,8 @@ workspace::create_workspace(options cons mkdir_p(bookkeeping_root); workspace::found = true; - workspace::set_ws_options(opts, true); - workspace::write_ws_format(); + workspace::set_options(opts, true); + workspace::write_format(); data empty; bookkeeping_path ul_path; @@ -168,7 +168,7 @@ workspace::workspace(app_state & app, bo { require_workspace(); if (writeback_options) - set_ws_options(app.opts, false); + set_options(app.opts, false); } workspace::workspace(app_state & app, i18n_format const & explanation, @@ -177,7 +177,7 @@ workspace::workspace(app_state & app, i1 { require_workspace(explanation); if (writeback_options) - set_ws_options(app.opts, false); + set_options(app.opts, false); } workspace::workspace(options const & opts, lua_hooks & lua, @@ -186,7 +186,7 @@ workspace::workspace(options const & opt { require_workspace(explanation); if (writeback_options) - set_ws_options(opts, false); + set_options(opts, false); } // routines for manipulating the bookkeeping directory @@ -363,10 +363,10 @@ read_options_file(any_path const & optsp static void read_options_file(any_path const & optspath, - system_path & database_option, - branch_name & branch_option, - rsa_keypair_id & key_option, - system_path & keydir_option) + system_path & workspace_database, + branch_name & workspace_branch, + rsa_keypair_id & workspace_key, + system_path & workspace_keydir) { data dat; try @@ -390,13 +390,13 @@ read_options_file(any_path const & optsp parser.str(val); if (opt == "database") - database_option = system_path(val, origin::workspace); + workspace_database = system_path(val, origin::workspace); else if (opt == "branch") - branch_option = branch_name(val, origin::workspace); + workspace_branch = branch_name(val, origin::workspace); else if (opt == "key") - internalize_rsa_keypair_id(utf8(val, origin::workspace), key_option); + internalize_rsa_keypair_id(utf8(val, origin::workspace), workspace_key); else if (opt == "keydir") - keydir_option = system_path(val, origin::workspace); + workspace_keydir = system_path(val, origin::workspace); else W(F("unrecognized key '%s' in options file %s - ignored") % opt % optspath); @@ -407,24 +407,24 @@ write_options_file(bookkeeping_path cons static void write_options_file(bookkeeping_path const & optspath, - system_path const & database_option, - branch_name const & branch_option, - rsa_keypair_id const & key_option, - system_path const & keydir_option) + system_path const & workspace_database, + branch_name const & workspace_branch, + rsa_keypair_id const & workspace_key, + system_path const & workspace_keydir) { basic_io::stanza st; - if (!database_option.as_internal().empty()) - st.push_str_pair(symbol("database"), database_option.as_internal()); - if (!branch_option().empty()) - st.push_str_pair(symbol("branch"), branch_option()); - if (!key_option().empty()) + if (!workspace_database.as_internal().empty()) + st.push_str_pair(symbol("database"), workspace_database.as_internal()); + if (!workspace_branch().empty()) + st.push_str_pair(symbol("branch"), workspace_branch()); + if (!workspace_key().empty()) { utf8 key; - externalize_rsa_keypair_id(key_option, key); + externalize_rsa_keypair_id(workspace_key, key); st.push_str_pair(symbol("key"), key()); } - if (!keydir_option.as_internal().empty()) - st.push_str_pair(symbol("keydir"), keydir_option.as_internal()); + if (!workspace_keydir.as_internal().empty()) + st.push_str_pair(symbol("keydir"), workspace_keydir.as_internal()); basic_io::printer pr; pr.print_stanza(st); @@ -439,62 +439,64 @@ void } void -workspace::get_ws_options(options & opts) +workspace::get_options(options & opts) { if (!workspace::found) return; - system_path database_option; - branch_name branch_option; - rsa_keypair_id key_option; - system_path keydir_option; + system_path workspace_database; + branch_name workspace_branch; + rsa_keypair_id workspace_key; + system_path workspace_keydir; bookkeeping_path o_path; get_options_path(o_path); read_options_file(o_path, - database_option, branch_option, key_option, keydir_option); + workspace_database, workspace_branch, + workspace_key, workspace_keydir); // Workspace options are not to override the command line. if (!opts.dbname_given) { - opts.dbname = database_option; + opts.dbname = workspace_database; } - if (!opts.key_dir_given && !opts.conf_dir_given && !keydir_option.empty()) + if (!opts.key_dir_given && !opts.conf_dir_given && !workspace_keydir.empty()) { // if empty/missing, we want to keep the default - opts.key_dir = keydir_option; + opts.key_dir = workspace_keydir; opts.key_dir_given = true; } - if (opts.branchname().empty() && !branch_option().empty()) + if (opts.branchname().empty() && !workspace_branch().empty()) { - opts.branchname = branch_option; + opts.branchname = workspace_branch; branch_is_sticky = true; } L(FL("branch name is '%s'") % opts.branchname); if (!opts.key_given) - opts.signing_key = key_option; + opts.signing_key = workspace_key; } void workspace::get_database_option(system_path const & workspace, - system_path & database_option) + system_path & workspace_database) { - branch_name branch_option; - rsa_keypair_id key_option; - system_path keydir_option; + branch_name workspace_branch; + rsa_keypair_id workspace_key; + system_path workspace_keydir; system_path o_path = (workspace / bookkeeping_root_component / options_file_name); read_options_file(o_path, - database_option, branch_option, key_option, keydir_option); + workspace_database, workspace_branch, + workspace_key, workspace_keydir); } void -workspace::set_ws_options(options const & opts, bool branch_is_sticky) +workspace::set_options(options const & opts, bool branch_is_sticky) { E(workspace::found, origin::user, F("workspace required but not found")); @@ -503,58 +505,61 @@ workspace::set_ws_options(options const // If any of the incoming options was empty, we want to leave that option // as is in _MTN/options, not write out an empty option. - system_path database_option; - branch_name branch_option; - rsa_keypair_id key_option; - system_path keydir_option; + system_path workspace_database; + branch_name workspace_branch; + rsa_keypair_id workspace_key; + system_path workspace_keydir; if (file_exists(o_path)) read_options_file(o_path, - database_option, branch_option, key_option, keydir_option); + 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... + // 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... if (!opts.dbname.as_internal().empty() && get_path_status(opts.dbname.as_internal()) == path::file) - database_option = opts.dbname; + workspace_database = opts.dbname; if (!opts.key_dir.as_internal().empty() && get_path_status(opts.key_dir.as_internal()) == path::directory) - keydir_option = opts.key_dir; + workspace_keydir = opts.key_dir; if ((branch_is_sticky || workspace::branch_is_sticky) && !opts.branchname().empty()) - branch_option = opts.branchname; + workspace_branch = opts.branchname; if (opts.key_given) - key_option = opts.signing_key; + workspace_key = opts.signing_key; write_options_file(o_path, - database_option, branch_option, key_option, keydir_option); + workspace_database, workspace_branch, + workspace_key, workspace_keydir); } void -workspace::print_ws_option(utf8 const & opt, std::ostream & output) +workspace::print_option(utf8 const & opt, std::ostream & output) { E(workspace::found, origin::user, F("workspace required but not found")); bookkeeping_path o_path; get_options_path(o_path); - system_path database_option; - branch_name branch_option; - rsa_keypair_id key_option; - system_path keydir_option; + system_path workspace_database; + branch_name workspace_branch; + rsa_keypair_id workspace_key; + system_path workspace_keydir; read_options_file(o_path, - database_option, branch_option, key_option, keydir_option); + workspace_database, workspace_branch, + workspace_key, workspace_keydir); if (opt() == "database") - output << database_option << '\n'; + output << workspace_database << '\n'; else if (opt() == "branch") - output << branch_option << '\n'; + output << workspace_branch << '\n'; else if (opt() == "key") - output << key_option << '\n'; + output << workspace_key << '\n'; else if (opt() == "keydir") - output << keydir_option << '\n'; + output << workspace_keydir << '\n'; else E(false, origin::user, F("'%s' is not a recognized workspace option") % opt); } ============================================================ --- work.hh 48bdba225cedd327acdfd13db63226e76df1ecec +++ work.hh 37d90e812bd3f1eff977682b7e363036b4da4f5f @@ -89,7 +89,14 @@ private: static bool found; private: - // This is used by get_ws_options and set_ws_options. + // This is used by get_options and set_options. The branch option is set + // to sticky (meaning it will be persisted in the workspace options) in + // several cases: + // - when update switches to a different branch + // - when commit switches to a different branch + // - when creating a new workspace + // - when the given branch option is empty and the workspace branch option + // is not, to retain the previous workspace branch option static bool branch_is_sticky; // This is used by a lot of instance methods. @@ -203,27 +210,27 @@ public: // _MTN/options. it keeps a list of name/value pairs which are considered // "persistent options", associated with a particular workspace and // implied unless overridden on the command line. - static void get_ws_options(options & opts); + static void get_options(options & opts); static void get_database_option(system_path const & workspace_root, system_path & database_option); - static void set_ws_options(options const & opts, bool branch_is_sticky); - static void print_ws_option(utf8 const & opt, std::ostream & output); + static void set_options(options const & opts, bool branch_is_sticky); + static void print_option(utf8 const & opt, std::ostream & output); // the "workspace format version" is a nonnegative integer value, stored // in _MTN/format as an unadorned decimal number. at any given time // monotone supports actual use of only one workspace format. - // check_ws_format throws an error if the workspace exists but its format + // check_format throws an error if the workspace exists but its format // number is not equal to the currently supported format number. it is // automatically called for all commands defined with CMD() (not - // CMD_NO_WORKSPACE()). migrate_ws_format is called only on explicit user + // CMD_NO_WORKSPACE()). migrate_format is called only on explicit user // request (mtn ws migrate) and will convert a workspace from any older - // format to the new one. finally, write_ws_format is called only when a + // format to the new one. finally, write_format is called only when a // workspace is created, and simply writes the current workspace format // number to _MTN/format. unlike most routines in this class, these // functions are defined in their own file, work_migration.cc. - static void check_ws_format(); - static void write_ws_format(); - void migrate_ws_format(); + static void check_format(); + static void write_format(); + void migrate_format(); // the "local dump file' is a debugging file, stored in _MTN/debug. if we // crash, we save some debugging information here.