Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg] Fix regression in error messages with registries/versioning #15709

Merged
merged 5 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion toolsrc/include/vcpkg/paragraphs.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ namespace vcpkg::Paragraphs
LoadResults try_load_all_registry_ports(const VcpkgPaths& paths);

std::vector<SourceControlFileLocation> load_all_registry_ports(const VcpkgPaths& paths);
std::vector<SourceControlFileLocation> load_overlay_ports(const VcpkgPaths& paths, const fs::path& dir);
std::vector<SourceControlFileLocation> load_overlay_ports(const Files::Filesystem& fs, const fs::path& dir);
}
26 changes: 14 additions & 12 deletions toolsrc/include/vcpkg/portfileprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,14 @@ namespace vcpkg::PortFileProvider
const std::unordered_map<std::string, SourceControlFileLocation>& ports;
};

struct PathsPortFileProvider : Util::ResourceBase, PortFileProvider
{
explicit PathsPortFileProvider(const vcpkg::VcpkgPaths& paths, const std::vector<std::string>& overlay_ports);
ExpectedS<const SourceControlFileLocation&> get_control_file(const std::string& src_name) const override;
std::vector<const SourceControlFileLocation*> load_all_control_files() const override;

private:
const VcpkgPaths& paths;
std::vector<fs::path> overlay_ports;
mutable std::unordered_map<std::string, SourceControlFileLocation> cache;
};

struct IVersionedPortfileProvider
{
virtual View<VersionT> get_port_versions(StringView port_name) const = 0;
virtual ~IVersionedPortfileProvider() = default;

virtual ExpectedS<const SourceControlFileLocation&> get_control_file(
const Versions::VersionSpec& version_spec) const = 0;
virtual void load_all_control_files(std::map<std::string, const SourceControlFileLocation*>& out) const = 0;
};

struct IBaselineProvider
Expand All @@ -59,6 +48,19 @@ namespace vcpkg::PortFileProvider
{
virtual ~IOverlayProvider() = default;
virtual Optional<const SourceControlFileLocation&> get_control_file(StringView port_name) const = 0;
virtual void load_all_control_files(std::map<std::string, const SourceControlFileLocation*>& out) const = 0;
};

struct PathsPortFileProvider : Util::ResourceBase, PortFileProvider
{
explicit PathsPortFileProvider(const vcpkg::VcpkgPaths& paths, const std::vector<std::string>& overlay_ports);
ExpectedS<const SourceControlFileLocation&> get_control_file(const std::string& src_name) const override;
std::vector<const SourceControlFileLocation*> load_all_control_files() const override;

private:
std::unique_ptr<IBaselineProvider> m_baseline;
std::unique_ptr<IVersionedPortfileProvider> m_versioned;
std::unique_ptr<IOverlayProvider> m_overlay;
};

std::unique_ptr<IBaselineProvider> make_baseline_provider(const vcpkg::VcpkgPaths& paths);
Expand Down
2 changes: 0 additions & 2 deletions toolsrc/include/vcpkg/registries.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ namespace vcpkg
View<std::string> packages() const { return packages_; }
const RegistryImplementation& implementation() const { return *implementation_; }

static std::unique_ptr<RegistryImplementation> builtin_registry(std::string&& baseline = {});

friend RegistrySet; // for experimental_set_builtin_registry_baseline

private:
Expand Down
10 changes: 10 additions & 0 deletions toolsrc/src/vcpkg-test/dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ struct MockVersionedPortfileProvider : PortFileProvider::IVersionedPortfileProvi
}
return it2->second;
}

virtual void load_all_control_files(std::map<std::string, const SourceControlFileLocation*>&) const override
{
Checks::unreachable(VCPKG_LINE_INFO);
}
};

using Versions::Constraint;
Expand Down Expand Up @@ -190,6 +195,11 @@ struct MockOverlayProvider : PortFileProvider::IOverlayProvider, Util::ResourceB
return it->second;
}

virtual void load_all_control_files(std::map<std::string, const SourceControlFileLocation*>&) const override
{
Checks::unreachable(VCPKG_LINE_INFO);
}

private:
std::map<std::string, SourceControlFileLocation, std::less<>> mappings;
};
Expand Down
3 changes: 1 addition & 2 deletions toolsrc/src/vcpkg/commands.portsdiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ namespace vcpkg::Commands::PortsDiff
System::cmd_execute_and_capture_output(cmd, System::get_clean_environment());
System::cmd_execute_and_capture_output(System::Command(git_exe).string_arg("reset"),
System::get_clean_environment());
const auto ports_at_commit =
Paragraphs::load_overlay_ports(paths, temp_checkout_path / ports_dir_name_as_string);
const auto ports_at_commit = Paragraphs::load_overlay_ports(fs, temp_checkout_path / ports_dir_name_as_string);
std::map<std::string, VersionT> names_and_versions;
for (auto&& port : ports_at_commit)
{
Expand Down
6 changes: 2 additions & 4 deletions toolsrc/src/vcpkg/paragraphs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ namespace vcpkg::Paragraphs
error_info->name = fs::u8string(path.filename());
error_info->error = Strings::format(
"Failed to load manifest file for port: %s\n", fs::u8string(path_to_manifest), ec.message());
return error_info;
}

return res;
Expand Down Expand Up @@ -491,13 +492,10 @@ namespace vcpkg::Paragraphs
return std::move(results.paragraphs);
}

std::vector<SourceControlFileLocation> load_overlay_ports(const VcpkgPaths& paths, const fs::path& directory)
std::vector<SourceControlFileLocation> load_overlay_ports(const Files::Filesystem& fs, const fs::path& directory)
{
LoadResults ret;

std::vector<std::string> port_names;

const auto& fs = paths.get_filesystem();
auto port_dirs = fs.get_files_non_recursive(directory);
Util::sort(port_dirs);

Expand Down
Loading