# # # patch "automate.cc" # from [0cf7d9f616bf0c51ba9038a38bbc18a7b0635ce5] # to [498586a8074ba94c32c2ab083e03e9154cd9303e] # # patch "monotone.texi" # from [55b5571894d88207a2251fd6eccfa922534bcbc2] # to [4c3c754ea2f297f7069741926ce1744cf25a913c] # # patch "tests/automate_get_current_revision/__driver__.lua" # from [7fc7f1ab42d64321b50735919feab05536f7d25a] # to [a56d2598ca7be71521f38b0a577baa92fbf55022] # # patch "tests/automate_get_current_revision_id/__driver__.lua" # from [f0f457f58dc21abc321660374cfa48d3fcecc724] # to [571b6285beca23817afbe0e80608c9a59643a178] # ============================================================ --- automate.cc 0cf7d9f616bf0c51ba9038a38bbc18a7b0635ce5 +++ automate.cc 498586a8074ba94c32c2ab083e03e9154cd9303e @@ -1177,11 +1177,13 @@ CMD_AUTOMATE(get_revision, N_("REVID"), // Name: get_current_revision // Arguments: -// 1: list of restriction paths +// 1: zero or more path names // Added in: 7.0 // Purpose: Outputs (an optionally restricted) revision based on // changes in the current workspace - +// Error conditions: If there are no changes in the current workspace or the +// restriction is invalid or has no recorded changes, prints an error message +// to stderr and exits with status 1. A workspace is required. CMD_AUTOMATE(get_current_revision, N_("[PATHS ...]"), N_("Shows change information for a workspace"), "", @@ -1210,6 +1212,9 @@ CMD_AUTOMATE(get_current_revision, N_("[ make_revision(old_rosters, new_roster, rev); make_restricted_revision(old_rosters, new_roster, mask, rev, excluded, execid); + rev.check_sane(); + N(rev.is_nontrivial(), F("no changes to commit")); + calculate_ident(rev, ident); write_revision(rev, dat); ============================================================ --- monotone.texi 55b5571894d88207a2251fd6eccfa922534bcbc2 +++ monotone.texi 4c3c754ea2f297f7069741926ce1744cf25a913c @@ -7408,12 +7408,12 @@ @section Automation @item Error conditions: -If any of restriction paths is unknown prints an error message to stderr -and exits with status 1. +If the command is executed outside of a workspace, there are no changes in the +current workspace or the restriction is invalid or has no recorded changes, +prints an error message to stderr and exits with status 1. @end table - @item mtn automate get_base_revision_id @table @strong ============================================================ --- tests/automate_get_current_revision/__driver__.lua 7fc7f1ab42d64321b50735919feab05536f7d25a +++ tests/automate_get_current_revision/__driver__.lua a56d2598ca7be71521f38b0a577baa92fbf55022 @@ -5,13 +5,17 @@ check(mtn("commit", "--date=2005-05-21T1 check(mtn("commit", "--date=2005-05-21T12:30:51", "--branch=testbranch", "--message=blah-blah"), 0, false, false) --- ensure that bad restriction paths fail -check(mtn("automate", "get_current_revision", "foo-bar"), 1, true, false) +-- ensure clear workspace fails wih error +check(mtn("automate", "get_current_revision"), 1, true, false) check(fsize("stdout") == 0) addfile("foox", "blah\n") addfile("barx", "blah2\n") +-- ensure that bad restriction paths fail +check(mtn("automate", "get_current_revision", "foo-bar"), 1, true, false) +check(fsize("stdout") == 0) + -- ensure that no restriction yields the same as '.' as restriction check(mtn("automate", "get_current_revision"), 0, true, false) no_restrict = get("stdout") ============================================================ --- tests/automate_get_current_revision_id/__driver__.lua f0f457f58dc21abc321660374cfa48d3fcecc724 +++ tests/automate_get_current_revision_id/__driver__.lua 571b6285beca23817afbe0e80608c9a59643a178 @@ -9,10 +9,6 @@ end check(trim(readfile("current")) == trim(readfile("stdout"))) end --- check an empty base revision id - -chk() - -- check pending changes against an empty base addfile("foo", "this is file foo") @@ -21,10 +17,6 @@ commit() commit() --- check no changes against a non-empty base - -chk() - -- check changes against a non-empty base addfile("bar", "this is file bar")