# # old_revision [d6517813b56675ff4a5e6c67dc391fff3dc1fc36] # # add_dir "tests/automate_get_current_revision" # # add_file "tests/automate_get_current_revision/__driver__.lua" # content [dc822a42c1e122836b812958cb6aa5e8f2f76cd2] # # patch "NEWS" # from [757241af97eb81545a0aed186345ae1f3eb43b82] # to [5ec365e12d5019e6aa57168d9774b9d261319fff] # # patch "automate.cc" # from [047ae5ab7138ac06ededf854e74597c9b72b0954] # to [3b00aaab59f25242202fb0768290952122e17583] # # patch "monotone.texi" # from [e32c720dfae2e30a04cf0e14c306d5c7e25304ce] # to [93f947bdd8181f8c36ac6a04c926be4d0f45a3c5] # ============================================================ --- tests/automate_get_current_revision/__driver__.lua dc822a42c1e122836b812958cb6aa5e8f2f76cd2 +++ tests/automate_get_current_revision/__driver__.lua dc822a42c1e122836b812958cb6aa5e8f2f76cd2 @@ -0,0 +1,59 @@ + +mtn_setup() + +addfile("zoo", "blah\n") +check(mtn("commit", "--date=2005-05-21T12:30:51", + "--branch=testbranch", "--message=blah-blah"), 0, false, false) + +-- ensure that bad restriction paths fails +check(mtn("automate", "get_current_revision", "foo-bar"), 1, true, false) +check(fsize("stdout") == 0) + +addfile("foox", "blah\n") +addfile("barx", "blah2\n") + +-- ensure that no resrtiction yields the same as '.' as restriction +check(mtn("automate", "get_current_revision"), 0, true, false) +no_restrict = get("stdout") + +check(mtn("automate", "get_current_revision", "."), 0, true, false) +with_restrict = get("stdout") +check( no_restrict == with_restrict) + +check(mtn("automate", "get_current_revision", "foox"), 0, true, false) +foo_restrict = get("stdout") +check( qgrep("foox", "stdout") ) +check( not qgrep("barx", "stdout") ) +check( not qgrep("zoo", "stdout") ) + + +check(mtn("automate", "get_current_revision", "barx"), 0, true, false) +check( qgrep("barx", "stdout") ) +check( not qgrep("foox", "stdout") ) +check( not qgrep("zoo", "stdout") ) + +-- check subdirectory restrictions +mkdir("ttt") +mkdir("ttt/yyy") +mkdir("ttt/xxx") + +addfile("ttt/yyy/zzz", "blah\n") +addfile("ttt/xxx/vvv", "blah\n") + +check(mtn("automate", "get_current_revision", "ttt/"), 0, true, false) +check( qgrep("ttt", "stdout") ) +check( qgrep("zzz", "stdout") ) +check( qgrep("vvv", "stdout") ) +check( not qgrep("foox", "stdout") ) +check( not qgrep("barx", "stdout") ) + +check(mtn("automate", "get_current_revision", "--depth=0", "ttt", "ttt/xxx", "ttt/xxx/vvv"), 0, true, false) +check( qgrep("ttt/xxx/vvv", "stdout") ) +-- XXX: check node_restriction for +-- looks like yyy gets into revision even if we explicitly +-- forbidden recursion +-- check( not qgrep("yyy", "stdout") ) +check( not qgrep("zzz", "stdout") ) +check( not qgrep("foox", "stdout") ) +check( not qgrep("barx", "stdout") ) + ============================================================ --- NEWS 757241af97eb81545a0aed186345ae1f3eb43b82 +++ NEWS 5ec365e12d5019e6aa57168d9774b9d261319fff @@ -53,6 +53,9 @@ directories. The typical case of listing files that need attention now runs at least four times faster. + - 'automate get_current_revision' retrieves restricted revision + represented by current workspace + Wed Dec 12 21:21:15 UTC 2007 0.38 release. ============================================================ --- automate.cc 047ae5ab7138ac06ededf854e74597c9b72b0954 +++ automate.cc 3b00aaab59f25242202fb0768290952122e17583 @@ -1194,6 +1194,47 @@ CMD_AUTOMATE(get_revision, N_("[REVID]") output.write(dat.inner()().data(), dat.inner()().size()); } +// Name: get_current_revision +// Arguments: +// 1: list of restriction paths +// Added in: 7.0 + +CMD_AUTOMATE(get_current_revision, N_("[PATHS ...]"), + N_("Shows change information for a workspace"), + "", + options::opts::exclude | options::opts::depth) +{ + temp_node_id_source nis; + revision_data dat; + revision_id ident; + + roster_t new_roster; + parent_map old_rosters; + revision_t rev; + cset excluded; + + app.require_workspace(); + app.work.get_parent_rosters(old_rosters); + app.work.get_current_roster_shape(new_roster, nis); + + node_restriction mask(args_to_paths(args), + args_to_paths(app.opts.exclude_patterns), + app.opts.depth, + old_rosters, new_roster, app); + + app.work.update_current_roster_from_filesystem(new_roster, mask); + + make_revision(old_rosters, new_roster, rev); + make_restricted_revision(old_rosters, new_roster, mask, rev, + excluded, execid); + calculate_ident(rev, ident); + write_revision(rev, dat); + + L(FL("dumping revision %s") % ident); + output.write(dat.inner()().data(), dat.inner()().size()); +} + + // Name: get_base_revision_id // Arguments: none // Added in: 2.0 ============================================================ --- monotone.texi e32c720dfae2e30a04cf0e14c306d5c7e25304ce +++ monotone.texi 93f947bdd8181f8c36ac6a04c926be4d0f45a3c5 @@ -7376,8 +7376,40 @@ @section Automation @end table address@hidden mtn automate get_current_revision [--exclude @var{excl}] address@hidden address@hidden ...] address@hidden @strong address@hidden Arguments: +One or more @var{path} arguments restrict the revision to these paths, +otherwise all changes in workspace are taken into account. + +Options @var{excl} and @var{depth} work just like in @var{mtn commit}. + address@hidden Added in: + +7.0 + address@hidden Purpose: + +Prints change information for the restricted workspace revision. + address@hidden Sample output: + +See @var{automate get_revision} + address@hidden Output format: + +See @var{automate get_revision} + address@hidden Error conditions: + +If any of restriction paths is unknown prints an error message to stderr +and exits with status 1. + address@hidden table + + @item mtn automate get_base_revision_id @table @strong