aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-03 18:29:59 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-03 18:29:59 +0100
commit6b447b15064e6b7786e99c5da174b3a3793341c9 (patch)
treef8997b94697231b5478f077cbde3026a98633102
parenteb9015130abc4431341dacafa64555ec83debabc (diff)
downloadpaludis-6b447b15064e6b7786e99c5da174b3a3793341c9.tar.gz
paludis-6b447b15064e6b7786e99c5da174b3a3793341c9.tar.xz
honour the command line reinstall options
-rw-r--r--src/clients/cave/cmd_resolve.cc46
1 files changed, 36 insertions, 10 deletions
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index bb57a88..3f78048 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -238,8 +238,7 @@ namespace
" (default if --everything)")
("unless-same", 's', "Unless the target is the same (version, option flags)")
("unless-same-version", 'v', "Unless the target is the same version")
- ("if-necessary", 'i', "If necessary")
- ("never", 'n', "Never"),
+ ("if-necessary", 'i', "If necessary"),
"auto"
),
a_reinstall(&g_reinstall_options, "reinstall", 'r',
@@ -251,8 +250,7 @@ namespace
("unless-same", 's', "Unless the target is the same (version, option flags)"
" (default if --complete)")
("unless-same-version", 'v', "Unless the target is the same version")
- ("if-necessary", 'i', "If necessary")
- ("never", 'n', "Never"),
+ ("if-necessary", 'i', "If necessary"),
"if-necessary"
),
a_reinstall_scm(&g_reinstall_options, "reinstall-scm", 's',
@@ -477,16 +475,43 @@ namespace
resolver->dump(std::cerr, cmdline.a_dump_dependencies.specified());
}
+ UseInstalled use_installed_from_cmdline(const args::EnumArg & a, const bool is_set)
+ {
+ if (a.argument() == "auto")
+ return is_set ? ui_if_possible : ui_never;
+ else if (a.argument() == "always")
+ return ui_never;
+ else if (a.argument() == "unless-transient")
+ return ui_only_if_transient;
+ else if (a.argument() == "unless-same")
+ return ui_if_same;
+ else if (a.argument() == "unless-same-version")
+ return ui_if_same_version;
+ else if (a.argument() == "if-necessary")
+ return ui_if_possible;
+ else
+ throw args::DoHelp("Don't understand argument '" + a.argument() + "' to '--" + a.long_name() + "'");
+ }
+
struct UseInstalledVisitor
{
+ const ResolveCommandLine & cmdline;
+ const bool from_set;
+
+ UseInstalledVisitor(const ResolveCommandLine & c, const bool f) :
+ cmdline(c),
+ from_set(f)
+ {
+ }
+
UseInstalled visit(const DependencyReason &) const
{
- return ui_if_same;
+ return use_installed_from_cmdline(cmdline.a_reinstall, false);
}
UseInstalled visit(const TargetReason &) const
{
- return ui_never;
+ return use_installed_from_cmdline(cmdline.a_reinstall_targets, from_set);
}
UseInstalled visit(const PresetReason &) const
@@ -494,16 +519,17 @@ namespace
return ui_if_possible;
}
- UseInstalled visit(const SetReason &) const
+ UseInstalled visit(const SetReason & r) const
{
- return ui_if_same;
+ UseInstalledVisitor v(cmdline, true);
+ return r.reason_for_set()->accept_returning<UseInstalled>(v);
}
};
- UseInstalled use_installed_fn(const ResolveCommandLine &, const PackageDepSpec &,
+ UseInstalled use_installed_fn(const ResolveCommandLine & cmdline, const PackageDepSpec &,
const std::tr1::shared_ptr<const Reason> & reason)
{
- UseInstalledVisitor v;
+ UseInstalledVisitor v(cmdline, false);
return reason->accept_returning<UseInstalled>(v);
}
}