# # # patch "cmd.hh" # from [08f1cf48c648d5c1963e32971d73b53b54b9486a] # to [2859b4bf8f7e098484eabb78f3ad80a52ca33e25] # # patch "cmd_db.cc" # from [8f22eb0807bc554d247bfa4f57ae80468133e43d] # to [6446b538ba18b5affc287104b4771a83b8affdab] # # patch "commands.cc" # from [b2959febb7e9533ccd52f2fe3f30db5cdf58960c] # to [c171f10bf256a2a1c94536f8cf942b77baea82c8] # # patch "revision.cc" # from [61e9ab7efb8f5bf36815c4c2bd04077fe38bb97b] # to [c4c178a6e314921aa37997f7f6fc9b56d5fa51de] # # patch "sha1.cc" # from [77161d5428c58c00bdb6909f01d5e94c7a87daa7] # to [0652e123e555bff72a7bae1e7eb9e2d737eb3a8a] # ============================================================ --- cmd.hh 08f1cf48c648d5c1963e32971d73b53b54b9486a +++ cmd.hh 2859b4bf8f7e098484eabb78f3ad80a52ca33e25 @@ -35,6 +35,7 @@ namespace commands utf8 m_primary_name; names_set m_names; command * m_parent; + bool m_hidden; utf8 m_params; utf8 m_abstract; utf8 m_desc; @@ -46,6 +47,7 @@ namespace commands command(std::string const & primary_name, std::string const & other_names, command * parent, + bool hidden, std::string const & params, std::string const & abstract, std::string const & desc, @@ -59,6 +61,7 @@ namespace commands utf8 const & primary_name(void) const; names_set const & names(void) const; command * parent(void) const; + bool hidden(void) const; virtual std::string params(void) const; virtual std::string abstract(void) const; virtual std::string desc(void) const; @@ -136,13 +139,13 @@ namespace commands { \ #define CMD_REF(C) ((commands::command *)&(commands::C ## _cmd)) -#define CMD(C, aliases, parent, params, abstract, desc, opts) \ +#define _CMD2(C, aliases, parent, hidden, params, abstract, desc, opts) \ namespace commands { \ class cmd_ ## C : public command \ { \ public: \ - cmd_ ## C() : command(#C, aliases, parent, params, abstract, \ - desc, true, \ + cmd_ ## C() : command(#C, aliases, parent, hidden, params, \ + abstract, desc, true, \ options::options_type() | opts) \ {} \ virtual void exec(app_state & app, \ @@ -155,6 +158,12 @@ void commands::cmd_ ## C::exec(app_state std::string const & name, \ args_vector const & args) +#define CMD(C, aliases, parent, params, abstract, desc, opts) \ + _CMD2(C, aliases, parent, false, params, abstract, desc, opts) + +#define CMD_HIDDEN(C, aliases, parent, params, abstract, desc, opts) \ + _CMD2(C, aliases, parent, true, params, abstract, desc, opts) + // Use this for commands that want to define a params() function // instead of having a static description. (Good for "automate" // and possibly "list".) @@ -163,8 +172,9 @@ namespace commands { class cmd_ ## C : public command \ { \ public: \ - cmd_ ## C() : command(#C, aliases, parent, "", abstract, desc, \ - true, options::options_type() | opts) \ + cmd_ ## C() : command(#C, aliases, parent, false, "", abstract, \ + desc, true, \ + options::options_type() | opts) \ {} \ virtual void exec(app_state & app, \ std::string const & name, \ @@ -184,8 +194,9 @@ namespace commands { class cmd_ ## C : public command \ { \ public: \ - cmd_ ## C() : command(#C, aliases, parent, "", abstract, desc, \ - true, options::options_type() | opts) \ + cmd_ ## C() : command(#C, aliases, parent, false, "", abstract, \ + desc, true, \ + options::options_type() | opts) \ {} \ virtual void exec(app_state & app, \ std::string const & name, \ @@ -219,8 +230,8 @@ namespace commands { class cmd_ ## C : public command \ { \ public: \ - cmd_ ## C() : command(#C, aliases, parent, params, abstract, \ - desc, false, \ + cmd_ ## C() : command(#C, aliases, parent, false, params, \ + abstract, desc, false, \ options::options_type() | opts) \ {} \ virtual void exec(app_state & app, \ @@ -233,8 +244,7 @@ void commands::cmd_ ## C::exec(app_state std::string const & name, \ args_vector const & args) \ -CMD_FWD_DECL(public); -CMD_FWD_DECL(hidden); +CMD_FWD_DECL(__root__); CMD_FWD_DECL(automation); CMD_FWD_DECL(database); ============================================================ --- cmd_db.cc 8f22eb0807bc554d247bfa4f57ae80468133e43d +++ cmd_db.cc 6446b538ba18b5affc287104b4771a83b8affdab @@ -210,11 +210,11 @@ CMD(complete, "", CMD_REF(informative), throw usage(ident()); } -CMD(test_migration_step, "", CMD_REF(hidden), "SCHEMA", - N_("Runs one step of migration on the specified database"), - N_("This command migrates the given database from the specified schema " - "in SCHEMA to its successor."), - options::opts::none) +CMD_HIDDEN(test_migration_step, "", CMD_REF(database), "SCHEMA", + N_("Runs one step of migration on the specified database"), + N_("This command migrates the given database from the specified " + "schema in SCHEMA to its successor."), + options::opts::none) { if (args.size() != 1) throw usage(ident()); ============================================================ --- commands.cc b2959febb7e9533ccd52f2fe3f30db5cdf58960c +++ commands.cc c171f10bf256a2a1c94536f8cf942b77baea82c8 @@ -40,59 +40,57 @@ using std::vector; using std::strlen; using std::vector; -CMD_GROUP(the_root, "", NULL, N_(""), N_(""), options::opts::none); -CMD_GROUP(public, "", CMD_REF(the_root), N_(""), N_(""), options::opts::none); -CMD_GROUP(hidden, "", CMD_REF(the_root), N_(""), N_(""), options::opts::none); +CMD_GROUP(__root__, "", NULL, N_(""), N_(""), options::opts::none); // // Definition of top-level commands, used to classify the real commands // in logical groups. // -CMD_GROUP(automation, "", CMD_REF(public), +CMD_GROUP(automation, "", CMD_REF(__root__), N_("Commands that aid in scripted execution"), N_(""), options::opts::none); -CMD_GROUP(database, "", CMD_REF(public), +CMD_GROUP(database, "", CMD_REF(__root__), N_("Commands that manipulate the database"), N_(""), options::opts::none); -CMD_GROUP(debug, "", CMD_REF(public), +CMD_GROUP(debug, "", CMD_REF(__root__), N_("Commands that aid in program debugging"), N_(""), options::opts::none); -CMD_GROUP(informative, "", CMD_REF(public), +CMD_GROUP(informative, "", CMD_REF(__root__), N_("Commands for information retrieval"), N_(""), options::opts::none); -CMD_GROUP(key_and_cert, "", CMD_REF(public), +CMD_GROUP(key_and_cert, "", CMD_REF(__root__), N_("Commands to manage keys and certificates"), N_(""), options::opts::none); -CMD_GROUP(network, "", CMD_REF(public), +CMD_GROUP(network, "", CMD_REF(__root__), N_("Commands that access the network"), N_(""), options::opts::none); -CMD_GROUP(packet_io, "", CMD_REF(public), +CMD_GROUP(packet_io, "", CMD_REF(__root__), N_("Commands for packet reading and writing"), N_(""), options::opts::none); -CMD_GROUP(rcs, "", CMD_REF(public), +CMD_GROUP(rcs, "", CMD_REF(__root__), N_("Commands for interaction with RCS and CVS"), N_(""), options::opts::none); -CMD_GROUP(review, "", CMD_REF(public), +CMD_GROUP(review, "", CMD_REF(__root__), N_("Commands to review revisions"), N_(""), options::opts::none); -CMD_GROUP(tree, "", CMD_REF(public), +CMD_GROUP(tree, "", CMD_REF(__root__), N_("Commands to manipulate the tree"), N_(""), options::opts::none); -CMD_GROUP(variables, "", CMD_REF(public), +CMD_GROUP(variables, "", CMD_REF(__root__), N_("Commands to manage persistent variables"), N_(""), options::opts::none); -CMD_GROUP(workspace, "", CMD_REF(public), +CMD_GROUP(workspace, "", CMD_REF(__root__), N_("Commands that deal with the workspace"), N_(""), options::opts::none); @@ -156,6 +154,7 @@ namespace commands { command::command(std::string const & primary_name, std::string const & other_names, command * parent, + bool hidden, std::string const & params, std::string const & abstract, std::string const & desc, @@ -163,6 +162,7 @@ namespace commands { options::options_type const & opts) : m_primary_name(utf8(primary_name)), m_parent(parent), + m_hidden(hidden), m_params(utf8(params)), m_abstract(utf8(abstract)), m_desc(utf8(desc)), @@ -197,8 +197,7 @@ namespace commands { { command_id i; - // XXX public must go away - if (this != CMD_REF(the_root) && this != CMD_REF(public)) + if (this != CMD_REF(__root__)) { i = parent()->ident(); i.push_back(primary_name()); @@ -225,6 +224,12 @@ namespace commands { return m_parent; } + bool + command::hidden(void) const + { + return m_hidden; + } + std::string command::params() const { @@ -380,7 +385,7 @@ namespace commands complete_command(args_vector const & args, args_vector & rest) { - command * root = CMD_REF(public); + command * root = CMD_REF(__root__); I(root != NULL); vector< utf8 > utf8args(args.begin(), args.end()); @@ -563,7 +568,7 @@ namespace commands void explain_usage(command_id const & ident, ostream & out) { vector< utf8 > rest; // XXX - if (CMD_REF(public)->find_child_by_components(ident, rest) != CMD_REF(public)) + if (CMD_REF(__root__)->find_child_by_components(ident, rest) != CMD_REF(__root__)) explain_cmd_usage("", out); // XXX else { @@ -571,7 +576,7 @@ namespace commands // TODO Wrap long lines in these messages. out << "Top-level commands:\n\n"; - explain_children(CMD_REF(public)->children(), out); + explain_children(CMD_REF(__root__)->children(), out); out << '\n'; out << "For information on a specific command, type " "'mtn help '.\n"; @@ -596,7 +601,7 @@ namespace commands args_vector const & args) { vector< utf8 > rest; - command * cmd = CMD_REF(public)->find_child_by_components(ident, rest); + command * cmd = CMD_REF(__root__)->find_child_by_components(ident, rest); I(rest.size() == 0); if (cmd != NULL) { @@ -693,10 +698,10 @@ CMD(help, "", CMD_REF(informative), N_(" */ } -CMD(crash, "", CMD_REF(hidden), "{ N | E | I | exception | signal }", - N_("Triggers the specified kind of crash"), - N_(""), - options::opts::none) +CMD_HIDDEN(crash, "", CMD_REF(__root__), "{ N | E | I | exception | signal }", + N_("Triggers the specified kind of crash"), + N_(""), + options::opts::none) { if (args.size() != 1) throw usage(ident()); @@ -906,18 +911,18 @@ process_commit_message_args(bool & given #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" -CMD(__test1, "", CMD_REF(hidden), "", "", "", options::opts::none) {} +CMD(__test1, "", CMD_REF(__root__), "", "", "", options::opts::none) {} CMD(__test2, "__test2.1", - CMD_REF(hidden), "", "", "", options::opts::none) {} + CMD_REF(__root__), "", "", "", options::opts::none) {} CMD(__test3, "__test3.1 __test3.2", - CMD_REF(hidden), "", "", "", options::opts::none) {} + CMD_REF(__root__), "", "", "", options::opts::none) {} -CMD(test_visible, "", CMD_REF(public), "", "", "", options::opts::none) {} -CMD(test_invisible, "", CMD_REF(hidden), "", "", "", options::opts::none) {} +CMD(test_visible, "", CMD_REF(__root__), "", "", "", options::opts::none) {} +CMD(test_invisible, "", CMD_REF(__root__), "", "", "", options::opts::none) {} -CMD_GROUP(test_group, "", CMD_REF(public), "", "", options::opts::none); +CMD_GROUP(test_group, "", CMD_REF(__root__), "", "", options::opts::none); CMD(test_subcmd, "", CMD_REF(test_group), "", "", "", options::opts::none) {} static void @@ -946,7 +951,7 @@ UNIT_TEST(commands, complete_command) using commands::command; using commands::init_children; - command * root = CMD_REF(public); + command * root = CMD_REF(__root__); BOOST_REQUIRE(root != NULL); command * group = CMD_REF(test_group); BOOST_REQUIRE(group != NULL); ============================================================ --- revision.cc 61e9ab7efb8f5bf36815c4c2bd04077fe38bb97b +++ revision.cc c4c178a6e314921aa37997f7f6fc9b56d5fa51de @@ -1773,10 +1773,10 @@ regenerate_caches(app_state & app) P(F("finished regenerating cached rosters and heights")); } -CMD(rev_height, "", CMD_REF(hidden), N_("REV"), - N_("Shows a revision's height"), - N_(""), - options::opts::none) +CMD_HIDDEN(rev_height, "", CMD_REF(informative), N_("REV"), + N_("Shows a revision's height"), + N_(""), + options::opts::none) { if (args.size() != 1) throw usage(ident()); ============================================================ --- sha1.cc 77161d5428c58c00bdb6909f01d5e94c7a87daa7 +++ sha1.cc 0652e123e555bff72a7bae1e7eb9e2d737eb3a8a @@ -92,10 +92,10 @@ void hook_botan_sha1() Botan::global_state().add_engine(new Monotone_SHA1_Engine); } -CMD(benchmark_sha1, "", CMD_REF(hidden), "", - N_("Benchmarks SHA-1 cores"), - N_(""), - options::opts::none) +CMD_HIDDEN(benchmark_sha1, "", CMD_REF(debug), "", + N_("Benchmarks SHA-1 cores"), + N_(""), + options::opts::none) { P(F("Benchmarking %s SHA-1 cores") % registry().size()); int mebibytes = 100;