# # # patch "commands.cc" # from [2716a19c755c111ad09adc8bcaff6dac9fd3f30f] # to [acff5d944ea645827f84db3abcfcc92a0e2a0397] # # patch "monotone.cc" # from [3553c8e8f16acc2131fd92b227196f0b8b5afe6e] # to [14afd8b0823f1eceae6bf838b90300a8e5ef2f14] # ============================================================ --- commands.cc 2716a19c755c111ad09adc8bcaff6dac9fd3f30f +++ commands.cc acff5d944ea645827f84db3abcfcc92a0e2a0397 @@ -959,8 +959,8 @@ process_commit_message_args(bool & given #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" -CMD(test1, "", CMD_REF(__root__), "", "", "", options::opts::none) {} -CMD(test2, "", CMD_REF(__root__), "", "", "", options::opts::none) {} +CMD(test1, "alias1", CMD_REF(__root__), "", "", "", options::opts::none) {} +CMD(test2, "alias2", CMD_REF(__root__), "", "", "", options::opts::none) {} CMD_HIDDEN(test3, "", CMD_REF(__root__), "", "", "", options::opts::none) {} CMD_GROUP(testg, "", CMD_REF(__root__), "", "", options::opts::none); @@ -991,6 +991,12 @@ UNIT_TEST(commands, complete_command) BOOST_CHECK(id == mkid("testg")); } + // Single-word identifier, non-primary name. + { + command_id id = complete_command(mkargs("alias1")); + BOOST_CHECK(id == mkid("test1")); + } + // Multi-word identifier. { command_id id = complete_command(mkargs("testg testg1")); @@ -1030,6 +1036,14 @@ UNIT_TEST(commands, command_complete_com BOOST_CHECK(*matches.begin() == mkid("test1")); } + // Single-word identifier with one match, non-primary name. + { + command_id id = mkid("alias1"); + set< command_id > matches = CMD_REF(__root__)->complete_command(id); + BOOST_REQUIRE(matches.size() == 1); + BOOST_CHECK(*matches.begin() == mkid("test1")); + } + // Single-word identifier with multiple matches. { command_id id = mkid("test"); @@ -1043,6 +1057,18 @@ UNIT_TEST(commands, command_complete_com BOOST_CHECK(matches == expected); } + // Single-word identifier with multiple matches, non-primary name. + { + command_id id = mkid("alias"); + set< command_id > matches = CMD_REF(__root__)->complete_command(id); + BOOST_REQUIRE(matches.size() == 2); + + set< command_id > expected; + expected.insert(mkid("test1")); + expected.insert(mkid("test2")); + BOOST_CHECK(matches == expected); + } + // Multi-word identifier with one match. { command_id id = mkid("testg testg1"); ============================================================ --- monotone.cc 3553c8e8f16acc2131fd92b227196f0b8b5afe6e +++ monotone.cc 14afd8b0823f1eceae6bf838b90300a8e5ef2f14 @@ -165,7 +165,8 @@ commands::command_id read_options(option for (args_vector::size_type i = 0; i < cmd2.size(); i++) { - I(cmd2[i]().find(opts.args[i]()) == 0); + // Cannot enable the check below due to command name aliases. + // I(cmd2[i]().find(opts.args[i]()) == 0); opts.args.erase(opts.args.begin()); } }