diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2025-04-08 16:49:12 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2025-04-08 17:03:35 +0200 |
commit | 8d5cdccd1b7ef53e95edab2a704a42a41d73165d (patch) | |
tree | 6bd9d801c8b2db7cde4f5e887c14a2a73bb35d29 /src | |
parent | 35eaf8c3b2b12f0411f443e879427d8eff3f4d19 (diff) | |
download | justbuild-8d5cdccd1b7ef53e95edab2a704a42a41d73165d.tar.gz |
Tree-overlay utils: also report the path within the original tree
... instead of only the file name. Having the full path into the
tree makes it more easy for the user to understand the root cause
of a conflict.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/execution_engine/tree_operations/tree_operations_utils.cpp | 18 | ||||
-rw-r--r-- | src/buildtool/execution_engine/tree_operations/tree_operations_utils.hpp | 5 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/buildtool/execution_engine/tree_operations/tree_operations_utils.cpp b/src/buildtool/execution_engine/tree_operations/tree_operations_utils.cpp index 3943d5f4..8c1b0844 100644 --- a/src/buildtool/execution_engine/tree_operations/tree_operations_utils.cpp +++ b/src/buildtool/execution_engine/tree_operations/tree_operations_utils.cpp @@ -263,7 +263,9 @@ auto TreeOperationsUtils::ComputeTreeOverlay( IExecutionApi const& api, Artifact::ObjectInfo const& base_tree_info, Artifact::ObjectInfo const& other_tree_info, - bool disjoint) noexcept -> expected<Artifact::ObjectInfo, std::string> { + bool disjoint, + std::filesystem::path const& where) noexcept + -> expected<Artifact::ObjectInfo, std::string> { // Ensure that both objects are actually trees. Ensures(IsTreeObject(base_tree_info.type) and IsTreeObject(other_tree_info.type)); @@ -311,8 +313,11 @@ auto TreeOperationsUtils::ComputeTreeOverlay( if (IsTreeObject(base_entry.info.type) and IsTreeObject(it->second.info.type)) { // If both objects are trees, recursively compute tree overlay. - auto tree_info = ComputeTreeOverlay( - api, base_entry.info, it->second.info, disjoint); + auto tree_info = ComputeTreeOverlay(api, + base_entry.info, + it->second.info, + disjoint, + where / base_name); if (not tree_info) { return unexpected{tree_info.error()}; } @@ -323,11 +328,8 @@ auto TreeOperationsUtils::ComputeTreeOverlay( // If both objects are not trees, actual conflict detected. if (disjoint) { return unexpected{ - fmt::format("Conflict detected in tree-overlay computation {} " - "vs {}:\n{} points to different objects: {} vs {}", - base_tree_info.ToString(), - other_tree_info.ToString(), - nlohmann::json(base_name).dump(), + fmt::format("Conflict at path {}:\ndifferent objects {} vs {}", + nlohmann::json((where / base_name).string()).dump(), base_entry.info.ToString(), it->second.info.ToString())}; } diff --git a/src/buildtool/execution_engine/tree_operations/tree_operations_utils.hpp b/src/buildtool/execution_engine/tree_operations/tree_operations_utils.hpp index 62c405f4..bd818793 100644 --- a/src/buildtool/execution_engine/tree_operations/tree_operations_utils.hpp +++ b/src/buildtool/execution_engine/tree_operations/tree_operations_utils.hpp @@ -15,6 +15,7 @@ #ifndef INCLUDED_SRC_BUILDTOOL_EXECUTION_ENGINE_TREE_OPERATIONS_TREE_OPERATIONS_UTILS_HPP #define INCLUDED_SRC_BUILDTOOL_EXECUTION_ENGINE_TREE_OPERATIONS_TREE_OPERATIONS_UTILS_HPP +#include <filesystem> #include <string> #include "src/buildtool/common/artifact.hpp" @@ -39,7 +40,9 @@ class TreeOperationsUtils final { IExecutionApi const& api, Artifact::ObjectInfo const& base_tree_info, Artifact::ObjectInfo const& other_tree_info, - bool disjoint) noexcept -> expected<Artifact::ObjectInfo, std::string>; + bool disjoint, + std::filesystem::path const& where = std::filesystem::path{}) noexcept + -> expected<Artifact::ObjectInfo, std::string>; }; #endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_ENGINE_TREE_OPERATIONS_TREE_OPERATIONS_UTILS_HPP |