aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-01-30 13:57:43 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2017-01-30 21:52:43 -0800
commite461467affad578d2e13a5c8f18cc37ee3007938 (patch)
tree31e6c8239a6e581fe480ce26e3d283d2e8c3a19d
parent9c87fcbd8b7e1cdee148d33ed272ae5ecc83fb60 (diff)
downloadvcpkg-e461467affad578d2e13a5c8f18cc37ee3007938.tar.gz
vcpkg-e461467affad578d2e13a5c8f18cc37ee3007938.zip
[Dependencies] User-requested vs autos-elected info is now in a separate enum
-rw-r--r--toolsrc/include/vcpkg_Dependencies.h12
-rw-r--r--toolsrc/src/commands_remove.cpp26
-rw-r--r--toolsrc/src/vcpkg_Dependencies.cpp6
3 files changed, 26 insertions, 18 deletions
diff --git a/toolsrc/include/vcpkg_Dependencies.h b/toolsrc/include/vcpkg_Dependencies.h
index 5b0bf3187..b987a6b38 100644
--- a/toolsrc/include/vcpkg_Dependencies.h
+++ b/toolsrc/include/vcpkg_Dependencies.h
@@ -6,6 +6,12 @@
namespace vcpkg::Dependencies
{
+ enum class request_type
+ {
+ USER_REQUESTED,
+ AUTO_SELECTED
+ };
+
enum class install_plan_type
{
BUILD_AND_INSTALL,
@@ -29,13 +35,13 @@ namespace vcpkg::Dependencies
enum class remove_plan_type
{
NOT_INSTALLED,
- REMOVE_AUTO_SELECTED,
- REMOVE_USER_REQUESTED
+ REMOVE
};
struct remove_plan_action
{
- remove_plan_type type;
+ remove_plan_type plan_type;
+ request_type request_type;
std::unique_ptr<StatusParagraph> status_pgh;
};
diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp
index b28fe3283..2fc560275 100644
--- a/toolsrc/src/commands_remove.cpp
+++ b/toolsrc/src/commands_remove.cpp
@@ -114,13 +114,13 @@ namespace vcpkg::Commands::Remove
for (const package_spec_with_remove_plan& i : plan)
{
- if (i.plan.type == remove_plan_type::NOT_INSTALLED)
+ if (i.plan.plan_type == remove_plan_type::NOT_INSTALLED)
{
not_installed.push_back(&i);
continue;
}
- if (i.plan.type == remove_plan_type::REMOVE_AUTO_SELECTED || i.plan.type == remove_plan_type::REMOVE_USER_REQUESTED)
+ if (i.plan.plan_type == remove_plan_type::REMOVE)
{
remove.push_back(&i);
continue;
@@ -145,15 +145,17 @@ namespace vcpkg::Commands::Remove
System::println("The following packages will be removed:\n%s",
Strings::Joiner::on("\n").join(remove, [](const package_spec_with_remove_plan* p)
{
- switch (p->plan.type)
+ if (p->plan.request_type == Dependencies::request_type::AUTO_SELECTED)
{
- case remove_plan_type::REMOVE_USER_REQUESTED:
- return " " + p->spec.toString();
- case remove_plan_type::REMOVE_AUTO_SELECTED:
- return " * " + p->spec.toString();
- default:
- Checks::unreachable();
+ return " * " + p->spec.toString();
}
+
+ if (p->plan.request_type == Dependencies::request_type::USER_REQUESTED)
+ {
+ return " " + p->spec.toString();
+ }
+
+ Checks::unreachable();
}));
}
}
@@ -178,7 +180,7 @@ namespace vcpkg::Commands::Remove
const bool has_non_user_requested_packages = std::find_if(remove_plan.cbegin(), remove_plan.cend(), [](const package_spec_with_remove_plan& package)-> bool
{
- return package.plan.type == remove_plan_type::REMOVE_AUTO_SELECTED;
+ return package.plan.plan_type == remove_plan_type::REMOVE_AUTO_SELECTED;
}) != remove_plan.cend();
if (has_non_user_requested_packages && !isRecursive)
@@ -191,11 +193,11 @@ namespace vcpkg::Commands::Remove
for (const package_spec_with_remove_plan& action : remove_plan)
{
- if (action.plan.type == remove_plan_type::NOT_INSTALLED)
+ if (action.plan.plan_type == remove_plan_type::NOT_INSTALLED)
{
System::println(System::color::success, "Package %s is not installed", action.spec);
}
- else if (action.plan.type == remove_plan_type::REMOVE_AUTO_SELECTED || action.plan.type == remove_plan_type::REMOVE_USER_REQUESTED)
+ else if (action.plan.plan_type == remove_plan_type::REMOVE_AUTO_SELECTED || action.plan.plan_type == remove_plan_type::REMOVE_USER_REQUESTED)
{
const std::string display_name = action.spec.display_name();
System::println("Removing package %s... ", display_name);
diff --git a/toolsrc/src/vcpkg_Dependencies.cpp b/toolsrc/src/vcpkg_Dependencies.cpp
index b0047a772..669cdfc20 100644
--- a/toolsrc/src/vcpkg_Dependencies.cpp
+++ b/toolsrc/src/vcpkg_Dependencies.cpp
@@ -93,7 +93,7 @@ namespace vcpkg::Dependencies
auto it = status_db.find(spec);
if (it == status_db.end() || (*it)->state == install_state_t::not_installed)
{
- was_examined.emplace(spec, remove_plan_action{remove_plan_type::NOT_INSTALLED, nullptr});
+ was_examined.emplace(spec, remove_plan_action{remove_plan_type::NOT_INSTALLED, request_type::USER_REQUESTED, nullptr});
continue;
}
@@ -114,8 +114,8 @@ namespace vcpkg::Dependencies
examine_stack.push_back(an_installed_package.get()->package.spec);
}
- const remove_plan_type type = specs_as_set.find(spec) != specs_as_set.end() ? remove_plan_type::REMOVE_USER_REQUESTED : remove_plan_type::REMOVE_AUTO_SELECTED;
- was_examined.emplace(spec, remove_plan_action{type, std::make_unique<StatusParagraph>(std::move(**it))});
+ const request_type request_type = specs_as_set.find(spec) != specs_as_set.end() ? request_type::USER_REQUESTED : request_type::AUTO_SELECTED;
+ was_examined.emplace(spec, remove_plan_action{remove_plan_type::REMOVE, request_type,std::make_unique<StatusParagraph>(std::move(**it))});
}
std::vector<package_spec_with_remove_plan> ret;