# # # add_file "tests/t_automate_get_base_revision_id.at" # content [0aaff1cba946082d4298658a49b80b6e01064e1b] # # add_file "tests/t_automate_get_current_revision_id.at" # content [bd046be3d8637125f18bc2b5e4565db6bf9268a2] # # patch "ChangeLog" # from [e5e21ba2f2af6fd75881b1ea5a15aaccbb36491e] # to [6abb7332c17c15bb195af3f2a87acba5923c00e8] # # patch "automate.cc" # from [9248451312ddd082473819116fee83d3fa9e0082] # to [98ecc36c35fa4e784477961ca856cecfb38f30bd] # # patch "cmd_automate.cc" # from [acbb3a98cf8ec9bb10420059f9b244f8035dd9d1] # to [bf13b71b0bfaf0c50f5e06eb0dd2d1685335250a] # # patch "monotone.texi" # from [38c702dc5a3d95d4f2523b9da30ded6ffefcb30f] # to [a8090f78bdbff0e198d5ab8da6d20439e67c71e4] # # patch "testsuite.at" # from [ffc6462ba32d1734b0d5c7fcd87b06521fcd4c5a] # to [bee416aa1fa28565d5dd0c3308bc1b7d0e1b58aa] # ============================================================ --- tests/t_automate_get_base_revision_id.at 0aaff1cba946082d4298658a49b80b6e01064e1b +++ tests/t_automate_get_base_revision_id.at 0aaff1cba946082d4298658a49b80b6e01064e1b @@ -0,0 +1,29 @@ +# -*- Autoconf -*- + +AT_SETUP([automate get_base_revision_id]) +MTN_SETUP + +# check an empty base revision id + +AT_CHECK(MTN automate get_base_revision_id, [], [stdout], [ignore]) +AT_CHECK(cmp _MTN/revision stdout, [0], [], []) + +ADD_FILE(foo, [this is file foo +]) + +# check a non-empty base reivision id + +COMMIT(testbranch) + +AT_CHECK(MTN automate get_base_revision_id, [], [stdout], [ignore]) +AT_CHECK(cmp _MTN/revision stdout, [0], [], []) + +# check that pending changes don't affect the base revision id + +ADD_FILE(foo, [this is foo +]) + +AT_CHECK(MTN automate get_base_revision_id, [], [stdout], [ignore]) +AT_CHECK(cmp _MTN/revision stdout, [0], [], []) + +AT_CLEANUP ============================================================ --- tests/t_automate_get_current_revision_id.at bd046be3d8637125f18bc2b5e4565db6bf9268a2 +++ tests/t_automate_get_current_revision_id.at bd046be3d8637125f18bc2b5e4565db6bf9268a2 @@ -0,0 +1,42 @@ +# -*- Autoconf -*- + +AT_SETUP([automate get_current_revision_id]) +MTN_SETUP + +# check an empty base revision id + +AT_CHECK(MTN automate get_current_revision_id, [], [stdout], [ignore]) +AT_CHECK(cp stdout current, [], [], []) +AT_CHECK(MTN automate get_revision | MTN identify, [], [stdout], [ignore]) +AT_CHECK(cmp current stdout, [0], [], []) + +# check pending changes against an empty base + +ADD_FILE(foo, [this is file foo +]) + +AT_CHECK(MTN automate get_current_revision_id, [], [stdout], [ignore]) +AT_CHECK(cp stdout current, [], [], []) +AT_CHECK(MTN automate get_revision | MTN identify, [], [stdout], [ignore]) +AT_CHECK(cmp current stdout, [0], [], []) + +COMMIT(testbranch) + +# check no changes against a non-empty base + +AT_CHECK(MTN automate get_current_revision_id, [], [stdout], [ignore]) +AT_CHECK(cp stdout current, [], [], []) +AT_CHECK(MTN automate get_revision | MTN identify, [], [stdout], [ignore]) +AT_CHECK(cmp current stdout, [0], [], []) + +# check changes against a non-empty base + +ADD_FILE(bar, [this is file bar +]) + +AT_CHECK(MTN automate get_current_revision_id, [], [stdout], [ignore]) +AT_CHECK(cp stdout current, [], [], []) +AT_CHECK(MTN automate get_revision | MTN identify, [], [stdout], [ignore]) +AT_CHECK(cmp current stdout, [0], [], []) + +AT_CLEANUP ============================================================ --- ChangeLog e5e21ba2f2af6fd75881b1ea5a15aaccbb36491e +++ ChangeLog 6abb7332c17c15bb195af3f2a87acba5923c00e8 @@ -1,3 +1,15 @@ +2006-05-12 Derek Scherger + + * automate.cc (automate_get_base_revision_id, + automate_get_current_revision_id): new functions + (automate_command): call them + * cmd_automate.cc (automate): fix indentation and add entries for + new commands + * monotone.texi: document new commands + * tests/t_automate_get_base_revision_id.at: + * tests/t_automate_get_current_revision_id.at: new tests + * testsuite.at: call them + 2006-05-09 Derek Scherger * packet.cc (consume_file_delta): remove redundant file delta ============================================================ --- automate.cc 9248451312ddd082473819116fee83d3fa9e0082 +++ automate.cc 98ecc36c35fa4e784477961ca856cecfb38f30bd @@ -992,6 +992,65 @@ output.write(dat.inner()().data(), dat.inner()().size()); } +// Name: get_base_revision_id +// Arguments: none +// Added in: 2.0 +// Purpose: Prints the revision id the current workspace is based on. This is +// the value stored in _MTN/revision +// Error conditions: If no workspace book keeping _MTN directory is found, +// prints an error message to stderr, and exits with status 1. +static void +automate_get_base_revision_id(std::vector args, + std::string const & help_name, + app_state & app, + std::ostream & output) +{ + if (args.size() > 0) + throw usage(help_name); + + app.require_workspace(); + + revision_id rid; + get_revision_id(rid); + output << rid << std::endl; +} + +// Name: get_current_revision_id +// Arguments: none +// Added in: 2.0 +// Purpose: Prints the revision id of the current workspace. This is the +// id of the revision that would be committed by an unrestricted commit calculated +// from _MTN/revision, _MTN/work and any edits to files in the workspace. +// Error conditions: If no workspace book keeping _MTN directory is found, +// prints an error message to stderr, and exits with status 1. +static void +automate_get_current_revision_id(std::vector args, + std::string const & help_name, + app_state & app, + std::ostream & output) +{ + if (args.size() > 0) + throw usage(help_name); + + app.require_workspace(); + + roster_t old_roster, new_roster; + revision_id old_revision_id, new_revision_id; + revision_set rev; + temp_node_id_source nis; + + app.require_workspace(); + get_base_and_current_roster_shape(old_roster, new_roster, nis, app); + update_current_roster_from_filesystem(new_roster, app); + + get_revision_id(old_revision_id); + make_revision_set(old_revision_id, old_roster, new_roster, rev); + + calculate_ident(rev, new_revision_id); + + output << new_revision_id << std::endl; +} + // Name: get_manifest_of // Arguments: // 1: a revision id (optional, determined from the workspace if not given) @@ -1642,6 +1701,10 @@ automate_certs(args, root_cmd_name, app, output); else if (cmd() == "get_revision") automate_get_revision(args, root_cmd_name, app, output); + else if (cmd() == "get_base_revision_id") + automate_get_base_revision_id(args, root_cmd_name, app, output); + else if (cmd() == "get_current_revision_id") + automate_get_current_revision_id(args, root_cmd_name, app, output); else if (cmd() == "get_manifest_of") automate_get_manifest_of(args, root_cmd_name, app, output); else if (cmd() == "get_file") ============================================================ --- cmd_automate.cc acbb3a98cf8ec9bb10420059f9b244f8035dd9d1 +++ cmd_automate.cc bf13b71b0bfaf0c50f5e06eb0dd2d1685335250a @@ -6,29 +6,31 @@ CMD(automate, N_("automation"), N_("interface_version\n" - "heads [BRANCH]\n" - "ancestors REV1 [REV2 [REV3 [...]]]\n" - "attributes [FILE]\n" - "parents REV\n" - "descendents REV1 [REV2 [REV3 [...]]]\n" - "children REV\n" - "graph\n" - "erase_ancestors [REV1 [REV2 [REV3 [...]]]]\n" - "toposort [REV1 [REV2 [REV3 [...]]]]\n" - "ancestry_difference NEW_REV [OLD_REV1 [OLD_REV2 [...]]]\n" - "leaves\n" - "inventory\n" - "stdio\n" - "certs REV\n" - "select SELECTOR\n" - "get_file FILEID\n" - "get_manifest_of [REVID]\n" - "get_revision [REVID]\n" - "packet_for_rdata REVID\n" - "packets_for_certs REVID\n" - "packet_for_fdata FILEID\n" - "packet_for_fdelta OLD_FILE NEW_FILE\n" - "keys\n"), + "heads [BRANCH]\n" + "ancestors REV1 [REV2 [REV3 [...]]]\n" + "attributes [FILE]\n" + "parents REV\n" + "descendents REV1 [REV2 [REV3 [...]]]\n" + "children REV\n" + "graph\n" + "erase_ancestors [REV1 [REV2 [REV3 [...]]]]\n" + "toposort [REV1 [REV2 [REV3 [...]]]]\n" + "ancestry_difference NEW_REV [OLD_REV1 [OLD_REV2 [...]]]\n" + "leaves\n" + "inventory\n" + "stdio\n" + "certs REV\n" + "select SELECTOR\n" + "get_file FILEID\n" + "get_manifest_of [REVID]\n" + "get_revision [REVID]\n" + "get_base_revision_id\n" + "get_current_revision_id\n" + "packet_for_rdata REVID\n" + "packets_for_certs REVID\n" + "packet_for_fdata FILEID\n" + "packet_for_fdelta OLD_FILE NEW_FILE\n" + "keys\n"), N_("automation interface"), OPT_NONE) { ============================================================ --- monotone.texi 38c702dc5a3d95d4f2523b9da30ded6ffefcb30f +++ monotone.texi a8090f78bdbff0e198d5ab8da6d20439e67c71e4 @@ -6130,6 +6130,80 @@ @end table + + address@hidden mtn automate get_base_revision_id + address@hidden @strong address@hidden Arguments: + +None. + address@hidden Added in: + +2.0 + address@hidden Purpose: + +Prints the revision id the current workspace is based on. This is the +value stored in _MTN/revision + address@hidden Sample output: + address@hidden +28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61 address@hidden verbatim + address@hidden Output format: + +One line containing the base revision ID of the current workspace. + address@hidden Error conditions: + +If no workspace book keeping _MTN directory is found, prints an error +message to stderr, and exits with status 1. + address@hidden table + + + address@hidden mtn automate get_current_revision_id + address@hidden @strong address@hidden Arguments: + +None. + address@hidden Added in: + +2.0 + address@hidden Purpose: + +Prints the revision id of the current workspace. This is the id +of the revision that would be committed by an unrestricted commit +calculated from _MTN/revision, _MTN/work and any edits to files in the +workspace. + address@hidden Sample output: + address@hidden +28ce076c69eadb9b1ca7bdf9d40ce95fe2f29b61 address@hidden verbatim + address@hidden Output format: + +One line containing the current revision id ID of the current workspace. + address@hidden Error conditions: + +If no workspace book keeping _MTN directory is found, prints an error +message to stderr, and exits with status 1. + + address@hidden table + + @item mtn automate get_manifest_of @item mtn automate get_manifest_of @var{revid} ============================================================ --- testsuite.at ffc6462ba32d1734b0d5c7fcd87b06521fcd4c5a +++ testsuite.at bee416aa1fa28565d5dd0c3308bc1b7d0e1b58aa @@ -884,3 +884,5 @@ m4_include(tests/t_no_log_password.at) m4_include(tests/t_quiet.at) m4_include(tests/t_escaped_selectors.at) +m4_include(tests/t_automate_get_base_revision_id.at) +m4_include(tests/t_automate_get_current_revision_id.at)