`update` needs to use package_spec
MODIFY
include/vcpkg_Commands.h
include/vcpkg_Commands.h
#include "vcpkg_paths.h"
#include "StatusParagraphs.h"
#include <array>
+#include "version_t.h"
namespace vcpkg::Commands
{
@@ -56,6 +57,15 @@ namespace vcpkg::Commands
namespace Update
{
+ struct outdated_package
+ {
+ static bool compare_by_name(const outdated_package& left, const outdated_package& right);
+
+ package_spec spec;
+ version_diff_t version_diff;
+ };
+
+ std::vector<outdated_package> find_outdated_packages(const vcpkg_paths& paths, const StatusParagraphs& status_db);
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
}

MODIFY
include/version_t.h
include/version_t.h
@@ -25,15 +25,4 @@ namespace vcpkg
std::string toString() const;
};
-
- struct name_and_version_diff_t
- {
- static bool compare_by_name(const name_and_version_diff_t& left, const name_and_version_diff_t& right)
- {
- return left.name < right.name;
- }
-
- std::string name;
- version_diff_t version_diff;
- };
}

MODIFY
src/commands_portsdiff.cpp
src/commands_portsdiff.cpp
namespace vcpkg::Commands::PortsDiff
{
+ struct updated_port
+ {
+ static bool compare_by_name(const updated_port& left, const updated_port& right)
+ {
+ return left.port < right.port;
+ }
+
+ std::string port;
+ version_diff_t version_diff;
+ };
+
template <class T>
struct set_element_presence
{
@@ -27,11 +38,11 @@ namespace vcpkg::Commands::PortsDiff
std::vector<T> only_right;
};
- static std::vector<name_and_version_diff_t> find_updated_ports(const std::vector<std::string>& ports,
+ static std::vector<updated_port> find_updated_ports(const std::vector<std::string>& ports,
const std::map<std::string, version_t>& previous_names_and_versions,
const std::map<std::string, version_t>& current_names_and_versions)
{
- std::vector<name_and_version_diff_t> output;
+ std::vector<updated_port> output;
for (const std::string& name : ports)
{
const version_t& previous_version = previous_names_and_versions.at(name);
@@ -128,14 +139,14 @@ namespace vcpkg::Commands::PortsDiff
}
const std::vector<std::string>& common_ports = setp.both;
- const std::vector<name_and_version_diff_t> updated_ports = find_updated_ports(common_ports, previous_names_and_versions, current_names_and_versions);
+ const std::vector<updated_port> updated_ports = find_updated_ports(common_ports, previous_names_and_versions, current_names_and_versions);
if (!updated_ports.empty())
{
System::println("\nThe following %d ports were updated:\n", updated_ports.size());
- for (const name_and_version_diff_t& p : updated_ports)
+ for (const updated_port& p : updated_ports)
{
- System::println("%-20s %-16s", p.name, p.version_diff.toString());
+ System::println("%-20s %-16s", p.port, p.version_diff.toString());
}
}

MODIFY
src/commands_update.cpp
src/commands_update.cpp
namespace vcpkg::Commands::Update
{
- std::vector<name_and_version_diff_t> find_outdated_packages(const vcpkg_paths& paths, const StatusParagraphs& status_db)
+ bool outdated_package::compare_by_name(const outdated_package& left, const outdated_package& right)
+ {
+ return left.spec.name() < right.spec.name();
+ }
+
+ std::vector<outdated_package> find_outdated_packages(const vcpkg_paths& paths, const StatusParagraphs& status_db)
{
const std::vector<SourceParagraph> source_paragraphs = Paragraphs::load_all_ports(paths.ports);
const std::map<std::string, version_t> src_names_to_versions = Paragraphs::extract_port_names_and_versions(source_paragraphs);
const std::vector<StatusParagraph*> installed_packages = get_installed_ports(status_db);
- std::vector<name_and_version_diff_t> output;
+ std::vector<outdated_package> output;
for (const StatusParagraph* pgh : installed_packages)
{
auto it = src_names_to_versions.find(pgh->package.spec.name());
@@ -24,7 +29,7 @@ namespace vcpkg::Commands::Update
}
if (it->second != pgh->package.version)
{
- output.push_back({ pgh->package.displayname(), version_diff_t(pgh->package.version, it->second) });
+ output.push_back({ pgh->package.spec, version_diff_t(pgh->package.version, it->second) });
}
}
@@ -39,8 +44,8 @@ namespace vcpkg::Commands::Update
const StatusParagraphs status_db = database_load_check(paths);
- const auto outdated_packages = ImmutableSortedVector<name_and_version_diff_t>::create(find_outdated_packages(paths, status_db),
- &name_and_version_diff_t::compare_by_name);
+ const auto outdated_packages = ImmutableSortedVector<outdated_package>::create(find_outdated_packages(paths, status_db),
+ &outdated_package::compare_by_name);
if (outdated_packages.empty())
{
@@ -51,7 +56,7 @@ namespace vcpkg::Commands::Update
System::println("The following packages differ from their port versions:");
for (auto&& package : outdated_packages)
{
- System::println(" %-27s %s", package.name, package.version_diff.toString());
+ System::println(" %-27s %s", package.spec.display_name(), package.version_diff.toString());
}
System::println("\nTo update these packages, run\n vcpkg remove --purge <pkgs>...\n vcpkg install <pkgs>...");
}

`update` needs to use package_spec