# # # add_dir "tests/cancelled_arguments" # # add_file "tests/cancelled_arguments/__driver__.lua" # content [38cc1430e21199426677870046ae84a89d00d27a] # # patch "option.cc" # from [5f78f36e5c5a6ba6000ed6bba4354965cd96636a] # to [7cbfe2a7b498d4b39f0509a71ce3573025362a02] # # patch "options_list.hh" # from [d9c478583ace2d86646cb78d3e721b213f61d6b8] # to [01eda7c2be3b5cf9d133e24a99b4d510dd354c17] # ============================================================ --- tests/cancelled_arguments/__driver__.lua 38cc1430e21199426677870046ae84a89d00d27a +++ tests/cancelled_arguments/__driver__.lua 38cc1430e21199426677870046ae84a89d00d27a @@ -0,0 +1,14 @@ +mtn_setup() + +addfile("foo", "bar") +commit() +writefile("foo", "foo") +commit() + +check(mtn("log"), 0, true, false) +rename("stdout", "nodiffs") +check(mtn("log", "--diffs"), 0, true, false) +rename("stdout", "diffs") +check(mtn("log", "--diffs", "--no-diffs"), 0, true, false) +check(samefile("nodiffs", "stdout")) +check(not samefile("diffs", "stdout")) \ No newline at end of file ============================================================ --- option.cc 5f78f36e5c5a6ba6000ed6bba4354965cd96636a +++ option.cc 7cbfe2a7b498d4b39f0509a71ce3573025362a02 @@ -279,11 +279,11 @@ get_by_name(std::set co i != options.end(); ++i) { if (!i->longname.empty()) - by_name.insert(make_pair(i->longname, *i)); + I(by_name.insert(make_pair(i->longname, *i)).second); if (!i->shortname.empty()) - by_name.insert(make_pair(i->shortname, *i)); + I(by_name.insert(make_pair(i->shortname, *i)).second); if (!i->cancelname.empty()) - by_name.insert(make_pair(i->cancelname, *i)); + I(by_name.insert(make_pair(i->cancelname, *i)).second); } return by_name; } @@ -465,6 +465,9 @@ static string usagestr(concrete_option c if (out.empty()) return out; + if (opt.has_arg) + out += " "; + if (!opt.cancelname.empty()) { if (!out.empty()) @@ -472,10 +475,7 @@ static string usagestr(concrete_option c out += "--" + opt.cancelname; } - if (opt.has_arg) - return out + " "; - else - return out; + return out; } void ============================================================ --- options_list.hh d9c478583ace2d86646cb78d3e721b213f61d6b8 +++ options_list.hh 01eda7c2be3b5cf9d133e24a99b4d510dd354c17 @@ -378,7 +378,7 @@ OPTION(au_diff_options, with_header, fal } #endif -SIMPLE_OPTION(diffs, "diffs", bool, gettext_noop("print diffs along with logs")) +SIMPLE_OPTION(diffs, "diffs/no-diffs", bool, gettext_noop("print diffs along with logs")) OPTSET(drop_attr) OPTVAR(drop_attr, std::set, attrs_to_drop, ) @@ -390,7 +390,7 @@ OPTION(drop_attr, drop_attr, true, "drop } #endif -SIMPLE_OPTION(dryrun, "dry-run", bool, +SIMPLE_OPTION(dryrun, "dry-run/no-dry-run", bool, gettext_noop("don't perform the operation, just show what would have happened")) SIMPLE_OPTION(drop_bad_certs, "drop-bad-certs", bool, @@ -457,7 +457,7 @@ GLOBAL_SIMPLE_OPTION(help, "help,h", boo GLOBAL_SIMPLE_OPTION(help, "help,h", bool, gettext_noop("display help message")) -SIMPLE_OPTION(show_hidden_commands, "hidden", bool, +SIMPLE_OPTION(show_hidden_commands, "hidden/no-hidden", bool, gettext_noop("show hidden commands")) OPTSET(include) @@ -564,22 +564,22 @@ OPT(next, "next", long, -1, } #endif -SIMPLE_OPTION(no_files, "no-files", bool, +SIMPLE_OPTION(no_files, "no-files/files", bool, gettext_noop("exclude files when printing logs")) -SIMPLE_OPTION(no_graph, "no-graph", bool, +SIMPLE_OPTION(no_graph, "no-graph/graph", bool, gettext_noop("do not use ASCII graph to display ancestry")) -SIMPLE_OPTION(no_ignore, "no-respect-ignore", bool, +SIMPLE_OPTION(no_ignore, "no-respect-ignore/respect-ignore", bool, gettext_noop("do not ignore any files")) -SIMPLE_OPTION(no_merges, "no-merges", bool, +SIMPLE_OPTION(no_merges, "no-merges/merges", bool, gettext_noop("exclude merges when printing logs")) GLOBAL_SIMPLE_OPTION(norc, "norc/yesrc", bool, gettext_noop("do not load ~/.monotone/monotonerc or _MTN/monotonerc lua files")) -GLOBAL_SIMPLE_OPTION(nostd, "nostd", bool, +GLOBAL_SIMPLE_OPTION(nostd, "nostd/stdhooks", bool, gettext_noop("do not load standard lua hooks")) SIMPLE_OPTION(pidfile, "pid-file", system_path, @@ -595,7 +595,7 @@ GOPT(quiet, "quiet", bool, false, } #endif -GLOBAL_SIMPLE_OPTION(extra_rcfiles, "rcfile", args_vector, +GLOBAL_SIMPLE_OPTION(extra_rcfiles, "rcfile/clear-rcfiles", args_vector, gettext_noop("load extra rc file")) GOPT(reallyquiet, "reallyquiet", bool, false, @@ -617,7 +617,7 @@ GOPT(timestamps, "timestamps", bool, fal } #endif -SIMPLE_OPTION(recursive, "recursive,R", bool, +SIMPLE_OPTION(recursive, "recursive,R/no-recursive", bool, gettext_noop("also operate on the contents of any listed directories")) OPTSET(revision)