# # old_revision [9b264ec9247ce99cd1fdc5293e869c1a60b01c4c] # # patch "automate.cc" # from [9a700bfc52a6a21e3b5d2d930ad634d455dafcae] # to [1ca44a73bf87274762a68c436f3b6b628b94d4aa] # ============================================================ --- automate.cc 9a700bfc52a6a21e3b5d2d930ad634d455dafcae +++ automate.cc 1ca44a73bf87274762a68c436f3b6b628b94d4aa @@ -517,6 +517,41 @@ CMD_AUTOMATE(select, N_("SELECTOR"), output << *i << '\n'; } +// Name: select_cert +// Arguments: +// 1: selector +// Added in: 8.1 +// Purpose: Prints all the certs for revisions that match the given selector. +// Output format: A list of pairs [cert_id, revision_id], both in hexadecimal, each followed by a +// newline. There is no particular order of values. +// Error conditions: None. +CMD_AUTOMATE(select_cert, N_("SELECTOR"), + N_("Lists certs for revisions that match a selector"), + "", + options::opts::none) +{ + N(args.size() == 1, + F("wrong argument count")); + + database db(app); + project_t project(db); + set completions; + expand_selector(app.opts, app.lua, project, idx(args, 0)(), completions); + + + for (set::const_iterator i = completions.begin(); + i != completions.end(); ++i) + { + std::vector cert_ids; + project.get_revision_cert_hashes(*i, cert_ids); + for(std::vector::const_iterator ii = cert_ids.begin(); + ii != cert_ids.end(); ++ii ) + { + output << *i << ' ' << *ii << '\n'; + } + } +} + struct node_info { bool exists; @@ -1499,6 +1534,37 @@ CMD_AUTOMATE(packets_for_certs, N_("REVI pw.consume_revision_cert(*i); } +// Name: packet_for_cert +// Arguments: +// 1: a cert id +// Added in: 8.1 +// Purpose: Prints the cert associated/ +// +// Output format: certs in "monotone read" compatible packet format +// +// Error conditions: If the cert id specified is unknown or +// invalid prints an error message to stderr and exits with status 1. +CMD_AUTOMATE(packet_for_cert, N_("CERTID"), + N_("Prints the certs in packet format"), + "", + options::opts::none) +{ + N(args.size() == 1, + F("wrong argument count")); + + database db(app); + //project_t project(db); + packet_writer pw(output); + + id c_id(decode_hexenc(idx(args, 0)())); + revision cert; + + //N(db.cert_exists(c_id), F("no such cert '%s'") % c_id); + db.get_revision_cert(c_id, cert); + + pw.consume_revision_cert(cert); +} + // Name: packet_for_fdata // Arguments: // 1: a file id