# # # patch "ChangeLog" # from [385666ca736a03b361388550265c1d94096fd462] # to [4bfdcfc9180e484a2dc026a5cdc096a44aedaa00] # # patch "app_state.cc" # from [5125b76d02163ea813bd054a4b6e2c0b17942cf6] # to [da53d196b9e952d489a1deda59bb26a9798bb612] # # patch "app_state.hh" # from [d4a3ea9c7d8f40ea415be31b7019a521b54e7ef9] # to [b52ed48ef2fe80bcc7f5290b4f95d8b33165d9c3] # # patch "commands.cc" # from [44ef6fcd7921bd4be0ee3ea14a043d9727fcc77a] # to [ca6820e06f7822ec5576800cc368ba2b5a4e99f1] # # patch "monotone.cc" # from [9b11ba942536171d28183446bb2fb30338c2a2ee] # to [32e0dec22f6beac4ab8271c51ff29cd7caefb5a3] # ============================================================ --- ChangeLog 385666ca736a03b361388550265c1d94096fd462 +++ ChangeLog 4bfdcfc9180e484a2dc026a5cdc096a44aedaa00 @@ -1,5 +1,31 @@ 2006-03-12 Richard Levitte + Some of the monotone commands don't really need to use the data + in MT/options. As a matter of fact, it's even a really bad idea + for some command, for example 'monotone serve'. We must still + check for the MT directory and read whatever is there, just + don't immediately use the data from MT/options. I've done it by + moving the code that processes the data from MT/options in + app_state::allow_workspace to another method, which is then used + separately. + + * app_state.cc, app_state.hh (app_state::allow_workspace): The + code that processes data from MT/options and uses the information + is now moved... + (app_state::process_options): ... here. + + * commands.cc (struct command, commands::process, CMD, CMT_NO_MT): + Add a per-command flag that says if the particular command needs + to bother with the workspace options or not. CMD_NO_MT is a new + macro to help define commands that don't. + (CMD(serve)): Change into... + (CMD_NO_MT(serve)): ... this. + + * monotone.cc (cpp_main): Changed the comment so it matches + reality. + +2006-03-12 Richard Levitte + * ChangeLog: Fixup after merge lossage. 2006-03-11 Matthew Gregan ============================================================ --- app_state.cc 5125b76d02163ea813bd054a4b6e2c0b17942cf6 +++ app_state.cc da53d196b9e952d489a1deda59bb26a9798bb612 @@ -70,25 +70,10 @@ if (found_workspace) { + // We read the options, but we don't process them here. That's + // done with process_options(). read_options(); - if (!options[database_option]().empty()) - { - system_path dbname = system_path(options[database_option]); - db.set_filename(dbname); - } - - if (!options[keydir_option]().empty()) - { - system_path keydir = system_path(options[keydir_option]); - set_key_dir(keydir); - } - - if (branch_name().empty()) - branch_name = options[branch_option]; - L(FL("branch name is '%s'\n") % branch_name()); - internalize_rsa_keypair_id(options[key_option], signing_key); - if (global_sanity.filename.empty()) { bookkeeping_path dump_path; @@ -104,6 +89,29 @@ } void +app_state::process_options() +{ + if (found_workspace) { + if (!options[database_option]().empty()) + { + system_path dbname = system_path(options[database_option]); + db.set_filename(dbname); + } + + if (!options[keydir_option]().empty()) + { + system_path keydir = system_path(options[keydir_option]); + set_key_dir(keydir); + } + + if (branch_name().empty()) + branch_name = options[branch_option]; + L(FL("branch name is '%s'\n") % branch_name()); + internalize_rsa_keypair_id(options[key_option], signing_key); + } +} + +void app_state::require_workspace(std::string const & explanation) { N(found_workspace, ============================================================ --- app_state.hh d4a3ea9c7d8f40ea415be31b7019a521b54e7ef9 +++ app_state.hh b52ed48ef2fe80bcc7f5290b4f95d8b33165d9c3 @@ -92,6 +92,7 @@ boost::shared_ptr > > verifiers; void allow_workspace(); + void process_options(); void require_workspace(std::string const & explanation = ""); void create_workspace(system_path const & dir); ============================================================ --- commands.cc 44ef6fcd7921bd4be0ee3ea14a043d9727fcc77a +++ commands.cc ca6820e06f7822ec5576800cc368ba2b5a4e99f1 @@ -110,13 +110,16 @@ string cmdgroup; string params; string desc; + bool use_workspace_options; command_opts options; command(string const & n, string const & g, string const & p, string const & d, + bool u, command_opts const & o) - : name(n), cmdgroup(g), params(p), desc(d), options(o) + : name(n), cmdgroup(g), params(p), desc(d), use_workspace_options(u), + options(o) { cmds[n] = this; } virtual ~command() {} virtual void exec(app_state & app, vector const & args) = 0; @@ -246,6 +249,12 @@ if (cmds.find(cmd) != cmds.end()) { L(FL("executing command '%s'\n") % cmd); + + // at this point we process the data from MT/options if + // the command needs it. + if (cmds[cmd]->use_workspace_options) + app.process_options(); + cmds[cmd]->exec(app, args); return 0; } @@ -273,7 +282,7 @@ #define CMD(C, group, params, desc, opts) \ struct cmd_ ## C : public command \ { \ - cmd_ ## C() : command(#C, group, params, desc, \ + cmd_ ## C() : command(#C, group, params, desc, true, \ command_opts() % opts) \ {} \ virtual void exec(app_state & app, \ @@ -283,6 +292,19 @@ void cmd_ ## C::exec(app_state & app, \ vector const & args) \ +#define CMD_NO_MT(C, group, params, desc, opts) \ +struct cmd_ ## C : public command \ +{ \ + cmd_ ## C() : command(#C, group, params, desc, false, \ + command_opts() % opts) \ + {} \ + virtual void exec(app_state & app, \ + vector const & args); \ +}; \ +static cmd_ ## C C ## _cmd; \ +void cmd_ ## C::exec(app_state & app, \ + vector const & args) \ + #define ALIAS(C, realcommand) \ CMD(C, realcommand##_cmd.cmdgroup, realcommand##_cmd.params, \ realcommand##_cmd.desc + "\nAlias for " #realcommand, \ @@ -2086,9 +2108,9 @@ include_pattern, exclude_pattern, app); } -CMD(serve, N_("network"), N_("PATTERN ..."), - N_("serve the branches specified by PATTERNs to connecting clients"), - OPT_BIND % OPT_PIDFILE % OPT_EXCLUDE) +CMD_NO_MT(serve, N_("network"), N_("PATTERN ..."), + N_("serve the branches specified by PATTERNs to connecting clients"), + OPT_BIND % OPT_PIDFILE % OPT_EXCLUDE) { if (args.size() < 1) throw usage(name); ============================================================ --- monotone.cc 9b11ba942536171d28183446bb2fb30338c2a2ee +++ monotone.cc 32e0dec22f6beac4ab8271c51ff29cd7caefb5a3 @@ -567,8 +567,11 @@ } // at this point we allow a workspace (meaning search for it - // and if found read MT/options) but don't require it. certain - // commands may subsequently require a workspace or fail + // and if found read MT/options, but don't use the data quite + // yet, and read all the monotonercs). Processing the data + // from MT/options happens later. + // Certain commands may subsequently require a workspace or fail + // if we didn't find one at this point. app.allow_workspace();