# # # patch "automate.cc" # from [a25464bad18217cff5bf90efd6fe3371f6dd2f6c] # to [4255b14ad2e82300f70b1f65ed602b3f43d7e7bb] # # patch "cmd_automate.cc" # from [7a2255f0d65c582171920c9bb6d112bb5c16d7af] # to [b0f5891cf1cf068c16a39edeaf38c255b6210a0c] # # patch "cmd_files.cc" # from [0a5292106bbf14f1457573bc976fbf74d4bd60fe] # to [eb2fdb6ef974ea7c3203863fb2704cdf4fed08f1] # # patch "cmd_list.cc" # from [5ee878c767f661cad7404c436e9b5446d2c1122f] # to [aa095825907151ba4f39a9182aabdf306d561a6a] # # patch "tests/automate_genkey/__driver__.lua" # from [322e3a85da0e722034431a1ffca4c7faee7b2b7f] # to [04c4a76116eb2a18077d9c5633e429d141db11b1] # ============================================================ --- automate.cc a25464bad18217cff5bf90efd6fe3371f6dd2f6c +++ automate.cc 4255b14ad2e82300f70b1f65ed602b3f43d7e7bb @@ -63,8 +63,8 @@ AUTOMATE(heads, N_("[BRANCH]"), options: // no heads.) AUTOMATE(heads, N_("[BRANCH]"), options::opts::none) { - if (args.size() > 1) - throw usage(help_name); + N(args.size() < 2, + F("wrong argument count")); if (args.size() ==1 ) { // branchname was explicitly given, use that @@ -87,9 +87,9 @@ AUTOMATE(ancestors, N_("REV1 [REV2 [REV3 // stdout, prints an error message to stderr, and exits with status 1. AUTOMATE(ancestors, N_("REV1 [REV2 [REV3 [...]]]"), options::opts::none) { - if (args.size() == 0) - throw usage(help_name); - + N(args.size() > 0, + F("wrong argument count")); + set ancestors; vector frontier; for (vector::const_iterator i = args.begin(); i != args.end(); ++i) @@ -134,8 +134,8 @@ AUTOMATE(descendents, N_("REV1 [REV2 [RE // stdout, prints an error message to stderr, and exits with status 1. AUTOMATE(descendents, N_("REV1 [REV2 [REV3 [...]]]"), options::opts::none) { - if (args.size() == 0) - throw usage(help_name); + N(args.size() > 0, + F("wrong argument count")); set descendents; vector frontier; @@ -214,8 +214,8 @@ AUTOMATE(attributes, N_("FILE"), options // format version, if the file is unknown, escalates AUTOMATE(attributes, N_("FILE"), options::opts::none) { - if (args.size() != 1) - throw usage(help_name); + N(args.size() > 0, + F("wrong argument count")); // this command requires a workspace to be run on app.require_workspace(); @@ -355,9 +355,9 @@ AUTOMATE(ancestry_difference, N_("NEW_RE // stdout, prints an error message to stderr, and exits with status 1. AUTOMATE(ancestry_difference, N_("NEW_REV [OLD_REV1 [OLD_REV2 [...]]]"), options::opts::none) { - if (args.size() == 0) - throw usage(help_name); - + N(args.size() > 0, + F("wrong argument count")); + revision_id a; set bs; vector::const_iterator i = args.begin(); @@ -394,8 +394,8 @@ AUTOMATE(leaves, "", options::opts::none // Error conditions: None. AUTOMATE(leaves, "", options::opts::none) { - if (args.size() != 0) - throw usage(help_name); + N(args.size() == 0, + F("no arguments needed")); // this might be more efficient in SQL, but for now who cares. set leaves; @@ -422,8 +422,9 @@ AUTOMATE(parents, N_("REV"), options::op // prints an error message to stderr, and exits with status 1. AUTOMATE(parents, N_("REV"), options::opts::none) { - if (args.size() != 1) - throw usage(help_name); + N(args.size() == 1, + F("wrong argument count")); + revision_id rid(idx(args, 0)()); N(app.db.revision_exists(rid), F("No such revision %s") % rid); set parents; @@ -446,8 +447,9 @@ AUTOMATE(children, N_("REV"), options::o // prints an error message to stderr, and exits with status 1. AUTOMATE(children, N_("REV"), options::opts::none) { - if (args.size() != 1) - throw usage(help_name); + N(args.size() == 1, + F("wrong argument count")); + revision_id rid(idx(args, 0)()); N(app.db.revision_exists(rid), F("No such revision %s") % rid); set children; @@ -480,8 +482,8 @@ AUTOMATE(graph, "", options::opts::none) // Error conditions: None. AUTOMATE(graph, "", options::opts::none) { - if (args.size() != 0) - throw usage(help_name); + N(args.size() == 0, + F("no arguments needed")); multimap edges_mmap; map > child_to_parents; @@ -523,8 +525,8 @@ AUTOMATE(select, N_("SELECTOR"), options // Error conditions: None. AUTOMATE(select, N_("SELECTOR"), options::opts::none) { - if (args.size() != 1) - throw usage(help_name); + N(args.size() == 1, + F("wrong argument count")); vector > sels(selectors::parse_selector(args[0](), app)); @@ -705,8 +707,8 @@ AUTOMATE(inventory, "", options::opts::n AUTOMATE(inventory, "", options::opts::none) { - if (args.size() != 0) - throw usage(help_name); + N(args.size() == 0, + F("no arguments needed")); app.require_workspace(); @@ -892,8 +894,8 @@ AUTOMATE(get_revision, N_("[REVID]"), op // prints an error message to stderr and exits with status 1. AUTOMATE(get_revision, N_("[REVID]"), options::opts::none) { - if (args.size() > 1) - throw usage(help_name); + N(args.size() < 2, + F("wrong argument count")); temp_node_id_source nis; revision_data dat; @@ -936,8 +938,8 @@ AUTOMATE(get_base_revision_id, "", optio // prints an error message to stderr, and exits with status 1. AUTOMATE(get_base_revision_id, "", options::opts::none) { - if (args.size() > 0) - throw usage(help_name); + N(args.size() == 0, + F("no arguments needed")); app.require_workspace(); @@ -957,8 +959,8 @@ AUTOMATE(get_current_revision_id, "", op // prints an error message to stderr, and exits with status 1. AUTOMATE(get_current_revision_id, "", options::opts::none) { - if (args.size() > 0) - throw usage(help_name); + N(args.size() == 0, + F("no arguments needed")); app.require_workspace(); @@ -1022,8 +1024,8 @@ AUTOMATE(get_manifest_of, N_("[REVID]"), // invalid prints an error message to stderr and exits with status 1. AUTOMATE(get_manifest_of, N_("[REVID]"), options::opts::none) { - if (args.size() > 1) - throw usage(help_name); + N(args.size() < 2, + F("wrong argument count")); manifest_data dat; manifest_id mid; @@ -1066,8 +1068,8 @@ AUTOMATE(packet_for_rdata, N_("REVID"), // invalid prints an error message to stderr and exits with status 1. AUTOMATE(packet_for_rdata, N_("REVID"), options::opts::none) { - if (args.size() != 1) - throw usage(help_name); + N(args.size() == 1, + F("wrong argument count")); packet_writer pw(output); @@ -1092,8 +1094,8 @@ AUTOMATE(packets_for_certs, N_("REVID"), // invalid prints an error message to stderr and exits with status 1. AUTOMATE(packets_for_certs, N_("REVID"), options::opts::none) { - if (args.size() != 1) - throw usage(help_name); + N(args.size() == 1, + F("wrong argument count")); packet_writer pw(output); @@ -1119,8 +1121,8 @@ AUTOMATE(packet_for_fdata, N_("FILEID"), // prints an error message to stderr and exits with status 1. AUTOMATE(packet_for_fdata, N_("FILEID"), options::opts::none) { - if (args.size() != 1) - throw usage(help_name); + N(args.size() == 1, + F("wrong argument count")); packet_writer pw(output); @@ -1146,8 +1148,8 @@ AUTOMATE(packet_for_fdelta, N_("OLD_FILE // invalid prints an error message to stderr and exits with status 1. AUTOMATE(packet_for_fdelta, N_("OLD_FILE NEW_FILE"), options::opts::none) { - if (args.size() != 2) - throw usage(help_name); + N(args.size() == 2, + F("wrong argument count")); packet_writer pw(output); @@ -1180,8 +1182,8 @@ AUTOMATE(common_ancestors, N_("REV1 [REV // with status 1. AUTOMATE(common_ancestors, N_("REV1 [REV2 [REV3 [...]]]"), options::opts::none) { - if (args.size() == 0) - throw usage(help_name); + N(args.size() > 0, + F("wrong argument count")); set ancestors, common_ancestors; vector frontier; @@ -1243,8 +1245,8 @@ AUTOMATE(branches, "", options::opts::no // None. AUTOMATE(branches, "", options::opts::none) { - if (args.size() > 0) - throw usage(help_name); + N(args.size() == 0, + F("no arguments needed")); vector names; @@ -1291,6 +1293,9 @@ AUTOMATE(tags, N_("[BRANCH_PATTERN]"), o // A run-time exception is thrown for illegal patterns. AUTOMATE(tags, N_("[BRANCH_PATTERN]"), options::opts::none) { + N(args.size() < 2, + F("wrong argument count")); + utf8 incl("*"); bool filtering(false); @@ -1298,8 +1303,6 @@ AUTOMATE(tags, N_("[BRANCH_PATTERN]"), o incl = idx(args, 0); filtering = true; } - else if (args.size() > 1) - throw usage(name); globish_matcher match(incl, utf8()); basic_io::printer prt; @@ -1387,8 +1390,8 @@ AUTOMATE(genkey, N_("KEYID PASSPHRASE"), // prints an error message to stderr and exits with status 1. AUTOMATE(genkey, N_("KEYID PASSPHRASE"), options::opts::none) { - if (args.size() != 2) - throw usage(help_name); + N(args.size() == 2, + F("wrong argument count")); rsa_keypair_id ident; internalize_rsa_keypair_id(idx(args, 0), ident); @@ -1446,8 +1449,8 @@ AUTOMATE(get_option, N_("OPTION"), optio // AUTOMATE(get_option, N_("OPTION"), options::opts::none) { - if (!app.opts.unknown && (args.size() < 1)) - throw usage(help_name); + N(args.size() == 1, + F("wrong argument count")); // this command requires a workspace to be run on app.require_workspace(); @@ -1492,8 +1495,8 @@ AUTOMATE(get_content_changed, N_("REV FI // AUTOMATE(get_content_changed, N_("REV FILE"), options::opts::none) { - if (args.size() != 2) - throw usage(help_name); + N(args.size() == 2, + F("wrong argument count")); roster_t new_roster; revision_id ident; @@ -1552,8 +1555,8 @@ AUTOMATE(get_corresponding_path, N_("REV // file "foo" AUTOMATE(get_corresponding_path, N_("REV1 FILE REV2"), options::opts::none) { - if (args.size() != 3) - throw usage(help_name); + N(args.size() == 3, + F("wrong argument count")); roster_t new_roster, old_roster; revision_id ident, old_ident; ============================================================ --- cmd_automate.cc 7a2255f0d65c582171920c9bb6d112bb5c16d7af +++ cmd_automate.cc b0f5891cf1cf068c16a39edeaf38c255b6210a0c @@ -74,8 +74,8 @@ AUTOMATE(interface_version, "", options: // Error conditions: None. AUTOMATE(interface_version, "", options::opts::none) { - if (args.size() != 0) - throw usage(help_name); + N(args.size() == 0, + F("no arguments needed")); output << interface_version << "\n"; } @@ -329,8 +329,9 @@ AUTOMATE(stdio, "", options::opts::autom AUTOMATE(stdio, "", options::opts::automate_stdio_size) { - if (args.size() != 0) - throw usage(help_name); + N(args.size() == 0, + F("no arguments needed")); + automate_ostream os(output, app.opts.automate_stdio_size); automate_reader ar(std::cin); vector > params; ============================================================ --- cmd_files.cc 0a5292106bbf14f1457573bc976fbf74d4bd60fe +++ cmd_files.cc eb2fdb6ef974ea7c3203863fb2704cdf4fed08f1 @@ -250,7 +250,7 @@ AUTOMATE(get_file, N_("FILEID"), options AUTOMATE(get_file, N_("FILEID"), options::opts::none) { N(args.size() == 1, - F("no argument given")); + F("wrong argument count")); file_id ident(idx(args, 0)()); dump_file(output, app, ident); @@ -273,7 +273,7 @@ AUTOMATE(get_file_of, N_("FILENAME"), op AUTOMATE(get_file_of, N_("FILENAME"), options::opts::revision) { N(args.size() == 1, - F("no argument given")); + F("wrong argument count")); revision_id rid; if (app.opts.revision_selectors.size() == 0) ============================================================ --- cmd_list.cc 5ee878c767f661cad7404c436e9b5446d2c1122f +++ cmd_list.cc aa095825907151ba4f39a9182aabdf306d561a6a @@ -560,8 +560,9 @@ AUTOMATE(keys, "", options::opts::none) // Error conditions: None. AUTOMATE(keys, "", options::opts::none) { - if (args.size() != 0) - throw usage(help_name); + N(args.size() == 0, + F("no arguments needed")); + vector dbkeys; vector kskeys; // public_hash, private_hash, public_location, private_location @@ -651,8 +652,8 @@ AUTOMATE(certs, N_("REV"), options::opts // and exits with status 1. AUTOMATE(certs, N_("REV"), options::opts::none) { - if (args.size() != 1) - throw usage(help_name); + N(args.size() == 1, + F("wrong argument count")); vector certs; ============================================================ --- tests/automate_genkey/__driver__.lua 322e3a85da0e722034431a1ffca4c7faee7b2b7f +++ tests/automate_genkey/__driver__.lua 04c4a76116eb2a18077d9c5633e429d141db11b1 @@ -19,7 +19,7 @@ check(mtn("automate", "genkey", "address@hidden check(mtn("automate", "genkey", "address@hidden", "foopass"), 1, false, false) -- Should fail, missing parameters -check(mtn("automate", "genkey", "address@hidden"), 2, false, false) +check(mtn("automate", "genkey", "address@hidden"), 1, false, false) -- Should work, we'll check the output below check(mtn("automate", "genkey", "address@hidden", "foopass"), 0, true, false)