# # # patch "cmd_merging.cc" # from [dc9c53f929b6ccca1b997bcf7e64237b5340a89b] # to [f67a2523c5c8463ee67273e40ae7f8bf54505ce9] # ============================================================ --- cmd_merging.cc dc9c53f929b6ccca1b997bcf7e64237b5340a89b +++ cmd_merging.cc f67a2523c5c8463ee67273e40ae7f8bf54505ce9 @@ -128,13 +128,10 @@ pick_branch_for_update(revision_id chose return switched_branch; } -CMD(update, "update", "", CMD_REF(workspace), "", - N_("Updates the workspace"), - N_("This command modifies your workspace to be based off of a " - "different revision, preserving uncommitted changes as it does so. " - "If a revision is given, update the workspace to that revision. " - "If not, update the workspace to the head of the branch."), - options::opts::branch | options::opts::revision) +static void +update(app_state & app, commands::command_id const & execid, + args_vector const & args, std::ostream & output, + bool automate) { if (args.size() > 0) throw usage(execid); @@ -155,12 +152,16 @@ CMD(update, "update", "", CMD_REF(worksp N(!null_id(old_rid), F("this workspace is a new project; cannot update")); + if (automate) + output << app.opts.branchname() << "\n"; + // Figure out where we're going revision_id chosen_rid; if (app.opts.revision_selectors.size() == 0) { - P(F("updating along branch '%s'") % app.opts.branchname); + if (!automate) + P(F("updating along branch '%s'") % app.opts.branchname); set candidates; pick_update_candidates(old_rid, app, candidates); N(!candidates.empty(), @@ -174,7 +175,8 @@ CMD(update, "update", "", CMD_REF(worksp for (set::const_iterator i = candidates.begin(); i != candidates.end(); ++i) P(i18n_format(" %s") % describe_revision(app, *i)); - P(F("choose one with '%s update -r'") % ui.prog_name); + if (!automate) + P(F("choose one with '%s update -r'") % ui.prog_name); E(false, F("multiple update candidates remain after selection")); } chosen_rid = *(candidates.begin()); @@ -194,7 +196,13 @@ CMD(update, "update", "", CMD_REF(worksp if (old_rid == chosen_rid) { - P(F("already up to date at %s") % old_rid); + if (automate) + { + output << chosen_rid << "\n"; + output << app.opts.branchname() << "\n"; + } + else + P(F("already up to date at %s") % old_rid); // do still switch the workspace branch, in case they have used // update to switch branches. if (!app.opts.branchname().empty()) @@ -202,7 +210,10 @@ CMD(update, "update", "", CMD_REF(worksp return; } - P(F("selected update target %s") % chosen_rid); + if (automate) + output << chosen_rid << "\n"; + else + P(F("selected update target %s") % chosen_rid); // Fiddle around with branches, in an attempt to guess what the user // wants. @@ -210,6 +221,9 @@ CMD(update, "update", "", CMD_REF(worksp if (switched_branch) P(F("switching to branch %s") % app.opts.branchname()); + if (automate) + output << app.opts.branchname() << "\n"; + // Okay, we have a target, we have a branch, let's do this merge! // We have: @@ -275,20 +289,38 @@ CMD(update, "update", "", CMD_REF(worksp if (!app.opts.branchname().empty()) app.make_branch_sticky(); - if (switched_branch) - P(F("switched branch; next commit will use branch %s") % app.opts.branchname()); - P(F("updated to base revision %s") % chosen_rid); + if (!automate) + { + if (switched_branch) + P(F("switched branch; next commit will use branch %s") % app.opts.branchname()); + P(F("updated to base revision %s") % chosen_rid); + } } +CMD(update, "update", "", CMD_REF(workspace), "", + N_("Updates the workspace"), + N_("This command modifies your workspace to be based off of a " + "different revision, preserving uncommitted changes as it does so. " + "If a revision is given, update the workspace to that revision. " + "If not, update the workspace to the head of the branch."), + options::opts::branch | options::opts::revision) +{ + update(app, execid, args, output, false); +} + +// output: +// \n +// \n +// \n CMD_AUTOMATE(update, "", N_("Updates the workspace"), N_("This command modifies your workspace to be based off of a " "different revision, preserving uncommitted changes as it does so. " "If a revision is given, update the workspace to that revision. " "If not, update the workspace to the head of the branch."), - options::opts::none) + options::opts::branch | options::opts::revision) { - commands::update_cmd.exec(app, execid, args, output); + update(app, execid, args, output, true); } // Subroutine of CMD(merge) and CMD(explicit_merge). Merge LEFT with RIGHT,