# # # patch "ChangeLog" # from [247413032721a84e71cd34acca7fb2500b623934] # to [4b9781e0324bedb528c504a7d7e803871c2e185c] # # patch "app_state.cc" # from [39ee6b031773ef782d71f16687987918c7d1a41e] # to [da582b88452d7a7f2b94fc389ea0d402d12b81cc] # # patch "app_state.hh" # from [a6cba0558a4c377dda413b557c10781cd33668c1] # to [a0038d821575d970098ae369bcad85586ad4e868] # # patch "commands.cc" # from [d129ff6c35bb6b3fb65a41c32b94e1d6233b12e5] # to [40263fe4929d57fb3a37a7c4efcbdd5dc45d588e] # # patch "monotone.cc" # from [1801c2b628b186e15a9ff6aec52607b1735185ab] # to [3ce745694b161a9c0e3a0d22af01a23f5db4a26c] # # patch "tests/basic_invocation_and_options/__driver__.lua" # from [9f5fde123d08c98d315fd296942c7da7f256fe85] # to [5c891c1bb290ee1c005cb084baf4e9e9ef650feb] # # patch "tests/check_that_--xargs_and_-(at)_behave_correctly/__driver__.lua" # from [993f961fc99620804e7fa9108831080c375dafa9] # to [4aad8d9f5694a0e08f5c133a795871825f6bdf7b] # # patch "tests/empty_environment/__driver__.lua" # from [99ac24ed4638a090c2f0867c2652f3356cebd470] # to [ef14b54a081141191e3eabdb7880844a5bf947f9] # # patch "tests/test_the_help_command/__driver__.lua" # from [5f63518108dcb12f51f0c79a0b1143ec0e67168b] # to [3696e97ef0a6066f245210bb27f24c5f27dc7e1d] # ============================================================ --- ChangeLog 247413032721a84e71cd34acca7fb2500b623934 +++ ChangeLog 4b9781e0324bedb528c504a7d7e803871c2e185c @@ -1,5 +1,18 @@ 2006-07-06 Timothy Brownawell + Make 'mtn help' and 'mtn --help' exit with status 0 instead of 2. + * app_state.{cc,hh}: requested_help is now in app_state + * monotone.cc: requested_help is now in app_state. Also, check this + when catching a usage, and exit with 0 instead of 2 if it's set. + * commands.cc (CMD(help)): Set app.requested_help. + * tests/basic_invocation_and_options/__driver__.lua: + * tests/check_that_--xargs_and_-(at)_behave_correctly/__driver__.lua: + * tests/empty_environment/__driver__.lua: + * tests/test_the_help_command/__driver__.lua: + Update to expect the new exit code. + +2006-07-06 Timothy Brownawell + * tests/common/cvs.lua: Sleep after running CVS. * tester.lua: Adjust command handling somewhat, so the above works. * tests/*cvs*/__driver__.lua: Remove any sleep(1) lines. This is now ============================================================ --- app_state.cc 39ee6b031773ef782d71f16687987918c7d1a41e +++ app_state.cc da582b88452d7a7f2b94fc389ea0d402d12b81cc @@ -53,7 +53,8 @@ bind_stdio(false), use_transport_auth(true), missing(false), unknown(false), confdir(get_default_confdir()), - have_set_key_dir(false), no_files(false) + have_set_key_dir(false), no_files(false), + requested_help(false) { db.set_app(this); lua.set_app(this); ============================================================ --- app_state.hh a6cba0558a4c377dda413b557c10781cd33668c1 +++ app_state.hh a0038d821575d970098ae369bcad85586ad4e868 @@ -85,6 +85,7 @@ bool have_set_key_dir; std::set attrs_to_drop; bool no_files; + bool requested_help; // Set if the value of the flag was explicitly given on the command // line. ============================================================ --- commands.cc d129ff6c35bb6b3fb65a41c32b94e1d6233b12e5 +++ commands.cc 40263fe4929d57fb3a37a7c4efcbdd5dc45d588e @@ -246,12 +246,16 @@ CMD(help, N_("informative"), N_("command [ARGS...]"), N_("display command help"), OPT_NONE) { if (args.size() < 1) - throw usage(""); + { + app.requested_help = true; + throw usage(""); + } string full_cmd = complete_command(idx(args, 0)()); if ((*cmds).find(full_cmd) == (*cmds).end()) throw usage(""); + app.requested_help = true; throw usage(full_cmd); } ============================================================ --- monotone.cc 1801c2b628b186e15a9ff6aec52607b1735185ab +++ monotone.cc 3ce745694b161a9c0e3a0d22af01a23f5db4a26c @@ -324,14 +324,13 @@ // process main program options int opt; - bool requested_help = false; set used_local_options; poptSetOtherOptionHelp(ctx(), _("[OPTION...] command [ARGS...]\n")); + app_state app; try { - app_state app; app.set_prog_name(prog_name); @@ -400,7 +399,7 @@ else if (string(argstr) == "count") ui.set_tick_writer(new tick_write_count); else - requested_help = true; + app.requested_help = true; break; case OPT_KEY_NAME: @@ -581,8 +580,10 @@ break; case OPT_HELP: + app.requested_help = true; + break; + default: - requested_help = true; break; } } @@ -603,7 +604,7 @@ // stop here if they asked for help - if (requested_help) + if (app.requested_help) { throw usage(cmd); // cmd may be empty, and that's fine. } @@ -672,7 +673,10 @@ cout << endl; commands::explain_usage(u.which, cout); global_sanity.clean_shutdown = true; - return 2; + if (app.requested_help) + return 0; + else + return 2; } } catch (informative_failure & inf) ============================================================ --- tests/basic_invocation_and_options/__driver__.lua 9f5fde123d08c98d315fd296942c7da7f256fe85 +++ tests/basic_invocation_and_options/__driver__.lua 5c891c1bb290ee1c005cb084baf4e9e9ef650feb @@ -1,14 +1,14 @@ mtn_setup() check(raw_mtn("--norc"), 2, false) -check(raw_mtn("--help"), 2, false) +check(raw_mtn("--help"), 0, false) check(raw_mtn("--version"), 0, false) +check(raw_mtn("--nostd", "--help"), 0, false) +check(raw_mtn("--norc", "--help"), 0, false) +check(raw_mtn("--debug", "--help"), 0, false, false) +check(raw_mtn("--quiet", "--help"), 0, false) +check(raw_mtn("--db=foo.db", "--help"), 0, false) +check(raw_mtn("--db", "foo.db", "--help"), 0, false) +check(raw_mtn("address@hidden", "--help"), 0, false) +check(raw_mtn("--key", "address@hidden", "--help"), 0, false) -check(raw_mtn("--nostd", "--help"), 2, false) -check(raw_mtn("--norc", "--help"), 2, false) -check(raw_mtn("--debug", "--help"), 2, false, false) -check(raw_mtn("--quiet", "--help"), 2, false) -check(raw_mtn("--db=foo.db", "--help"), 2, false) -check(raw_mtn("--db", "foo.db", "--help"), 2, false) -check(raw_mtn("address@hidden", "--help"), 2, false) -check(raw_mtn("--key", "address@hidden", "--help"), 2, false) ============================================================ --- tests/check_that_--xargs_and_-(at)_behave_correctly/__driver__.lua 993f961fc99620804e7fa9108831080c375dafa9 +++ tests/check_that_--xargs_and_-(at)_behave_correctly/__driver__.lua 4aad8d9f5694a0e08f5c133a795871825f6bdf7b @@ -1,30 +1,30 @@ mtn_setup() -- Generate the general expected output, as we're testing using the -- output of 'list --help' -check(raw_mtn("list", "--help"), 2, true, false) +check(raw_mtn("list", "--help"), 0, true, false) rename("stdout", "expout") -- Check that --xargs works at all writefile("at_test.input", "--help") -check(raw_mtn("list", "--xargs=at_test.input"), 2, {"expout"}, false) +check(raw_mtn("list", "--xargs=at_test.input"), 0, {"expout"}, false) -- The rest of the checks use the short form, -@ -- Check that -@ works at all writefile("at_test.input", "--help") -check(raw_mtn("list", "-@", "at_test.input"), 2, {"expout"}, false) +check(raw_mtn("list", "-@", "at_test.input"), 0, {"expout"}, false) -- Check that -@ works when injected in the middle of the arguments -- (i.e. that it's prepended correctly) writefile("at_test.input", "list") -check(raw_mtn("-@", "at_test.input", "--help"), 2, {"expout"}, false) +check(raw_mtn("-@", "at_test.input", "--help"), 0, {"expout"}, false) -- Check that -@ works when used more than once writefile("at_test.input1", "list") writefile("at_test.input2", "--help") -check(raw_mtn("-@", "at_test.input1", "-@", "at_test.input2"), 2, {"expout"}, false) +check(raw_mtn("-@", "at_test.input1", "-@", "at_test.input2"), 0, {"expout"}, false) -- Check that -@ works with an argument file with no content check(raw_mtn("list"), 2, true, false) ============================================================ --- tests/empty_environment/__driver__.lua 99ac24ed4638a090c2f0867c2652f3356cebd470 +++ tests/empty_environment/__driver__.lua ef14b54a081141191e3eabdb7880844a5bf947f9 @@ -22,7 +22,7 @@ copy(zlib, "cygz.dll") end -check(noenv_mtn("--help"), 2, false, false) +check(noenv_mtn("--help"), 0, false, false) writefile("testfile", "blah blah") check(noenv_mtn("add", "testfile"), 0, false, false) check(noenv_mtn("commit", "--branch=testbranch", "--message=foo"), 0, false, false) ============================================================ --- tests/test_the_help_command/__driver__.lua 5f63518108dcb12f51f0c79a0b1143ec0e67168b +++ tests/test_the_help_command/__driver__.lua 3696e97ef0a6066f245210bb27f24c5f27dc7e1d @@ -1,7 +1,7 @@ mtn_setup() -check(mtn("help", "mv"), 2, true, 0) +check(mtn("help", "mv"), 0, true, 0) rename("stdout", "out") -check(mtn("--help", "mv"), 2, true, 0) +check(mtn("--help", "mv"), 0, true, 0) check(samefile("stdout", "out"))