aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-05 18:51:35 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-05 18:51:35 +0000
commit8f2a1c843d2a1f1dc8c473bd1d6ce1884a78f046 (patch)
tree0f26b311de0063a273852a80fb8818b50bdf5ccd
parentf407bdab289b221e3da55154eb8a2d23da9709db (diff)
downloadpaludis-8f2a1c843d2a1f1dc8c473bd1d6ce1884a78f046.tar.gz
paludis-8f2a1c843d2a1f1dc8c473bd1d6ce1884a78f046.tar.xz
Call update-world twice if mixing removes and adds
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc53
-rw-r--r--src/clients/cave/resolve_common.cc20
2 files changed, 41 insertions, 32 deletions
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index 1e6c616..016ce6d 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -89,7 +89,6 @@ namespace
args::ArgsGroup g_general_options;
args::SwitchArg a_pretend;
args::SwitchArg a_set;
- args::SwitchArg a_block;
ResolveCommandLineExecutionOptions execution_options;
ResolveCommandLineProgramOptions program_options;
@@ -99,7 +98,6 @@ namespace
g_general_options(main_options_section(), "General Options", "General options."),
a_pretend(&g_general_options, "pretend", '\0', "Only carry out the pretend action", false),
a_set(&g_general_options, "set", '\0', "Our target is a set rather than package specs", false),
- a_block(&g_general_options, "block", '\0', "Our target contains block rather than package specs", false),
execution_options(this),
program_options(this),
import_options(this)
@@ -712,23 +710,24 @@ namespace
}
};
- int execute_update_world(
+ void update_world(
const std::tr1::shared_ptr<Environment> & env,
- const ResolverLists &,
- const ExecuteResolutionCommandLine & cmdline)
+ const ExecuteResolutionCommandLine & cmdline,
+ const bool removes)
{
- if (cmdline.execution_options.a_preserve_world.specified())
- return 0;
-
- cout << endl << c::bold_green() << "Updating world" << c::normal() << endl << endl;
-
std::string command(cmdline.program_options.a_update_world_program.argument());
if (command.empty())
command = "$CAVE update-world";
+ if (removes)
+ command.append(" --remove");
+
bool any(false);
if (cmdline.a_set.specified())
{
+ if (removes)
+ return;
+
command.append(" --set");
for (args::ArgsHandler::ParametersConstIterator a(cmdline.begin_parameters()),
a_end(cmdline.end_parameters()) ;
@@ -748,9 +747,6 @@ namespace
}
else
{
- if (cmdline.a_block.specified())
- command.append(" --remove");
-
for (args::ArgsHandler::ParametersConstIterator a(cmdline.begin_parameters()),
a_end(cmdline.end_parameters()) ;
a != a_end ; ++a)
@@ -759,8 +755,17 @@ namespace
if (aa.empty())
continue;
- if (cmdline.a_block.specified())
+ if ('!' == aa.at(0))
+ {
+ if (! removes)
+ continue;
aa.erase(0, 1);
+ }
+ else
+ {
+ if (removes)
+ continue;
+ }
PackageDepSpec spec(parse_user_package_dep_spec(aa, env.get(), UserPackageDepSpecOptions()));
if (package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>(
@@ -779,7 +784,7 @@ namespace
)))
{
any = true;
- if (cmdline.a_block.specified())
+ if (removes)
cout << "* Removing '" << spec << "'" << endl;
else
cout << "* Adding '" << spec << "'" << endl;
@@ -787,7 +792,7 @@ namespace
}
else
{
- if (cmdline.a_block.specified())
+ if (removes)
cout << "* Not removing '" << spec << "'" << endl;
else
cout << "* Not adding '" << spec << "'" << endl;
@@ -801,8 +806,20 @@ namespace
if (0 != run_command(cmd))
throw ActionAbortedError("Updating world failed");
}
+ }
+
+ void execute_update_world(
+ const std::tr1::shared_ptr<Environment> & env,
+ const ResolverLists &,
+ const ExecuteResolutionCommandLine & cmdline)
+ {
+ if (cmdline.execution_options.a_preserve_world.specified())
+ return;
+
+ cout << endl << c::bold_green() << "Updating world" << c::normal() << endl << endl;
- return 0;
+ update_world(env, cmdline, true);
+ update_world(env, cmdline, false);
}
struct Populator
@@ -1096,7 +1113,7 @@ namespace
if (0 != retcode)
return retcode;
- retcode |= execute_update_world(env, lists, cmdline);
+ execute_update_world(env, lists, cmdline);
return retcode;
}
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 5fb8d9c..bb7b462 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -415,8 +415,7 @@ namespace
const ResolveCommandLineResolutionOptions &,
const std::tr1::shared_ptr<const Sequence<std::string> > & targets,
PackageDepSpecList & allowed_to_remove_specs,
- bool & is_set,
- bool & is_block)
+ bool & is_set)
{
Context context("When adding targets from commandline:");
@@ -461,8 +460,6 @@ namespace
if (seen_sets)
is_set = true;
- if (seen_blockers)
- is_block = true;
}
UseExisting use_existing_from_cmdline(const args::EnumArg & a, const bool is_set)
@@ -1010,8 +1007,7 @@ namespace
const ResolveCommandLineProgramOptions & program_options,
const std::tr1::shared_ptr<const Map<std::string, std::string> > & keys_if_import,
const std::tr1::shared_ptr<const Sequence<std::string> > & targets,
- const bool is_set,
- const bool is_block) PALUDIS_ATTRIBUTE((noreturn));
+ const bool is_set) PALUDIS_ATTRIBUTE((noreturn));
void perform_resolution(
const std::tr1::shared_ptr<Environment> &,
@@ -1021,8 +1017,7 @@ namespace
const ResolveCommandLineProgramOptions & program_options,
const std::tr1::shared_ptr<const Map<std::string, std::string> > & keys_if_import,
const std::tr1::shared_ptr<const Sequence<std::string> > & targets,
- const bool is_set,
- const bool is_block)
+ const bool is_set)
{
Context context("When performing chosen resolution:");
@@ -1051,9 +1046,6 @@ namespace
if (is_set)
command.append(" --set");
- if (is_block)
- command.append(" --block");
-
for (args::ArgsSection::GroupsConstIterator g(program_options.begin()), g_end(program_options.end()) ;
g != g_end ; ++g)
{
@@ -1217,7 +1209,7 @@ paludis::cave::resolve_common(
ScopedSelectionCache selection_cache(env.get());
std::tr1::shared_ptr<Resolver> resolver(new Resolver(env.get(), resolver_functions));
- bool is_set(false), is_block(false);
+ bool is_set(false);
std::list<SuggestRestart> restarts;
try
@@ -1232,7 +1224,7 @@ paludis::cave::resolve_common(
try
{
add_resolver_targets(env, resolver, resolution_options, targets,
- allowed_to_remove_specs, is_set, is_block);
+ allowed_to_remove_specs, is_set);
resolver->resolve();
break;
}
@@ -1261,7 +1253,7 @@ paludis::cave::resolve_common(
if (0 == retcode)
perform_resolution(env, *resolver->lists(), resolution_options,
- execution_options, program_options, keys_if_import, targets, is_set, is_block);
+ execution_options, program_options, keys_if_import, targets, is_set);
}
catch (...)
{