# # # add_dir "tests/automate_checkout" # # add_file "tests/automate_checkout/__driver__.lua" # content [6411182532fa4a87ba078b04b28f527caac07dd9] # # patch "NEWS" # from [39cb8d9ae42dd5158968a02dc2cd1b7e82d7ab3a] # to [868462b935af78cc11137cd49624d8ac0e746c9c] # # patch "cmd_ws_commit.cc" # from [d82e5cd563864f041d8ea6d814f4edf21a5dca12] # to [bd3f5ed76e0988ced41364f2cb419c390bb8be87] # # patch "monotone.texi" # from [9b19901a805fadfc4cd2b26430c81d981e5c1558] # to [b8af75f3cda3b4abf12590536ef63ae6b3314fdc] # ============================================================ --- NEWS 39cb8d9ae42dd5158968a02dc2cd1b7e82d7ab3a +++ NEWS 868462b935af78cc11137cd49624d8ac0e746c9c @@ -171,6 +171,8 @@ Xxx Xxx 99 99:99:99 UTC 2010 all matches and an accompanying short description of the particular expansion are displayed. + - New automate command 'checkout' + - New automate commands 'put_public_key', 'get_public_key' and 'drop_public_key'. (closes monotone bug #30345) @@ -180,7 +182,7 @@ Xxx Xxx 99 99:99:99 UTC 2010 - A new 'manpage' command has been added which dumps the monotone command help including all global and command specific options in standard troff format. If this command is used interactively, its - output is automatically processed through nroff and less, in case + output is automatically processed through nroff and less, in case both are available on your system. If not, you can change the default command by overwriting the 'get_man_page_formatter_command' hook. ============================================================ --- monotone.texi 9b19901a805fadfc4cd2b26430c81d981e5c1558 +++ monotone.texi b8af75f3cda3b4abf12590536ef63ae6b3314fdc @@ -10445,6 +10445,36 @@ @section Automation @end table address@hidden mtn automate checkout [--[no-]move-conflicting-paths] address@hidden @var{directory} + address@hidden @strong address@hidden Arguments: + +Same as @command{mtn checkout}; directory to create workspace in. + address@hidden Added in: + +FIXME + address@hidden Purpose: + +Create a new workspace containing the given revision; see address@hidden in @ref{Workspace}. + address@hidden Sample output: + +None. + address@hidden Output format: + +None. + address@hidden Error conditions: + +see @command{checkout} in @ref{Workspace}. + address@hidden table + @item mtn automate read_packets @var{packet-data} @table @strong ============================================================ --- cmd_ws_commit.cc d82e5cd563864f041d8ea6d814f4edf21a5dca12 +++ cmd_ws_commit.cc bd3f5ed76e0988ced41364f2cb419c390bb8be87 @@ -1034,13 +1034,9 @@ CMD(status, "status", "", CMD_REF(inform cout << summary_external; } -CMD(checkout, "checkout", "co", CMD_REF(tree), N_("[DIRECTORY]"), - N_("Checks out a revision from the database into a directory"), - N_("If a revision is given, that's the one that will be checked out. " - "Otherwise, it will be the head of the branch (given or implicit). " - "If no directory is given, the branch name will be used as directory."), - options::opts::branch | options::opts::revision | - options::opts::move_conflicting_paths) +static void +checkout_common(app_state & app, + args_vector const & args) { revision_id revid; system_path dir; @@ -1049,9 +1045,6 @@ CMD(checkout, "checkout", "co", CMD_REF( project_t project(db); transaction_guard guard(db, false); - if (args.size() > 1 || app.opts.revision.size() > 1) - throw usage(execid); - if (app.opts.revision.empty()) { // use branch head revision @@ -1143,6 +1136,37 @@ CMD(checkout, "checkout", "co", CMD_REF( guard.commit(); } +CMD(checkout, "checkout", "co", CMD_REF(tree), N_("[DIRECTORY]"), + N_("Checks out a revision from the database into a directory"), + N_("If a revision is given, that's the one that will be checked out. " + "Otherwise, it will be the head of the branch (given or implicit). " + "If no directory is given, the branch name will be used as directory."), + options::opts::branch | options::opts::revision | + options::opts::move_conflicting_paths) +{ + if (args.size() > 1 || app.opts.revision.size() > 1) + throw usage(execid); + + checkout_common(app, args); +} + +CMD_AUTOMATE(checkout, N_("[DIRECTORY]"), + N_("Checks out a revision from the database into a directory"), + N_("If a revision is given, that's the one that will be checked out. " + "Otherwise, it will be the head of the branch (given or implicit). " + "If no directory is given, the branch name will be used as directory."), + options::opts::branch | options::opts::revision | + options::opts::move_conflicting_paths) +{ + E(args.size() < 2, origin::user, + F("wrong argument count")); + + E(app.opts.revision.size() < 2, origin::user, + F("wrong revision count")); + + checkout_common(app, args); +} + CMD_GROUP(attr, "attr", "", CMD_REF(workspace), N_("Manages file attributes"), N_("This command is used to set, get or drop file attributes.")); ============================================================ --- /dev/null +++ tests/automate_checkout/__driver__.lua 6411182532fa4a87ba078b04b28f527caac07dd9 @@ -0,0 +1,41 @@ +-- Test 'automate checkout' +include("/common/automate_stdio.lua") + +mtn_setup() + +mkdir("work_1") +rename("_MTN", "work_1/_MTN") +chdir("work_1") + +---------- +-- create a revision to checkout + +addfile("file_1", "file_1") +addfile("file_2", "file_2") +addfile("file_3", "file_3") +commit() +rev1 = base_revision() + +-- normal automate +check(mtn("automate", "checkout", "--branch", "testbranch", "../work_2"), 0, false, false) + +-- automate stdio +progress = run_stdio(make_stdio_cmd({"checkout", "../work_3"}, {{"branch", "testbranch"}}), 0, 0, 'p') + +-- Command error cases + +-- Too many arguments +check(mtn("automate", "checkout", "foo", "bar"), 1, false, true) +check(qgrep("wrong argument count", "stderr")) + +-- Too many revisions +writefile("file_1", "file_1, 2") +commit() +rev2 = base_revision() +check(mtn("automate", "checkout", "-r", rev1, "-r", rev2), 1, false, true) +check(qgrep("wrong revision count", "stderr")) + +-- other errors are handled by the same code as 'mtn checkout', so don't +-- need to be tested here. + +-- end of file