# # add_file "tests/t_automate_get_manifest.at" # # patch "automate.cc" # from [3173f16beca784ac8dabc7af82bacb9a14b20662] # to [dffb37bed13f8c61c701bbfdca29ed63ace5ae63] # # patch "tests/t_automate_get_manifest.at" # from [] # to [88eec4f7a9f3e30322a9ff7897f95f5ed43aa1d8] # # patch "testsuite.at" # from [e37b92e5720d349ff3b304850fec7678d97756a6] # to [e20185b74f9d18fd817bc5cb6bb43b4230f933da] # ======================================================================== --- automate.cc 3173f16beca784ac8dabc7af82bacb9a14b20662 +++ automate.cc dffb37bed13f8c61c701bbfdca29ed63ace5ae63 @@ -961,7 +961,50 @@ output.write(dat.inner()().data(), dat.inner()().size()); } +// Name: get_manifest +// Arguments: +// 1: a revision id (optional, determined from working directory if non-existant) +// Added in: 1.0 +// Purpose: Prints the contents of the manifest associated with the given revision ID. +// +// Output format: A basic_io string containing the manifest. +// +// Error conditions: If the revision ID specified is unknown or invalid prints an +// error message to stderr and exits with status 1. +static void +automate_get_manifest(std::vector args, + std::string const & help_name, + app_state & app, + std::ostream & output) +{ + if (args.size() > 1) + throw usage(help_name); + data dat; + manifest_id mid; + roster_t old_roster, new_roster; + + if (args.size() == 0) + { + revision_set rs; + app.require_working_copy(); + get_unrestricted_working_revision_and_rosters(app, rs, old_roster, new_roster); + } + else + { + revision_id rid = revision_id(idx(args, 0)()); + N(app.db.revision_exists(rid), + F("no revision %s found in database") % rid); + app.db.get_roster(rid, new_roster); + } + + calculate_ident(new_roster, mid); + write_manifest_of_roster(new_roster, dat); + L(F("dumping manifest %s\n") % mid); + output.write(dat().data(), dat().size()); +} + + // Name: get_file // Arguments: // 1: a file id @@ -1342,6 +1385,8 @@ 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_manifest") + automate_get_manifest(args, root_cmd_name, app, output); else if (cmd() == "get_file") automate_get_file(args, root_cmd_name, app, output); else if (cmd() == "keys") ======================================================================== --- tests/t_automate_get_manifest.at +++ tests/t_automate_get_manifest.at 88eec4f7a9f3e30322a9ff7897f95f5ed43aa1d8 @@ -0,0 +1,43 @@ +# -*- Autoconf -*- + +AT_SETUP([automate get_manifest]) +NEED_UNB64 +MONOTONE_SETUP + +AT_DATA(expected, [dir "" + + file "foo" +content @<:@4cbd040533a2f43fc6691d773d510cda70f4126a@:>@ +]) + +AT_DATA(empty, []) + +ADD_FILE(foo, [blah +]) +AT_CHECK(MONOTONE commit --date=2005-05-21T12:30:51 --branch=testbranch --message=blah-blah, [], [ignore], [ignore]) +BASE_R=`BASE_REVISION` + +# check that a correct usage produces correctly formatted output +AT_CHECK(MONOTONE automate get_manifest $BASE_R, [], [stdout], [ignore]) +AT_CHECK(CANONICALISE(stdout)) +AT_CHECK(cmp expected stdout) + +# should work even if we don't specify the manifest ID +AT_CHECK(MONOTONE automate get_manifest, [], [stdout], [ignore]) +AT_CHECK(CANONICALISE(stdout)) +AT_CHECK(cmp expected stdout) + +# ensure that missing revisions fail +NOSUCHREV=0000000000000000000000000000000000000000 +AT_CHECK(MONOTONE automate get_manifest $NOSUCHREV, [1], [stdout], [ignore]) +AT_CHECK(CANONICALISE(stdout)) +AT_CHECK(cmp empty stdout) + +# ensure that revisions are not being completed +# (the above commit will have created rev 3cf83369cfadbf5ba4ea3a50796fba18ec245489) +TRUNCATEDREV=3cf83369cfadbf5ba4ea3a50796fba18ec2454 +AT_CHECK(MONOTONE automate get_revision $TRUNCATEDREV, [1], [stdout], [ignore]) +AT_CHECK(CANONICALISE(stdout)) +AT_CHECK(cmp empty stdout) + +AT_CLEANUP ======================================================================== --- testsuite.at e37b92e5720d349ff3b304850fec7678d97756a6 +++ testsuite.at e20185b74f9d18fd817bc5cb6bb43b4230f933da @@ -729,6 +729,7 @@ m4_include(tests/t_setup_existing_path.at) m4_include(tests/t_mt_ignore.at) m4_include(tests/t_automate_get_file.at) +m4_include(tests/t_automate_get_manifest.at) m4_include(tests/t_automate_get_revision.at) m4_include(tests/t_unreadable_db.at) m4_include(tests/t_restriction_with_exclude.at)