From 8d5cdccd1b7ef53e95edab2a704a42a41d73165d Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 8 Apr 2025 16:49:12 +0200 Subject: 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. --- .../tree_operations/tree_operations_utils.cpp | 18 ++++++++++-------- .../tree_operations/tree_operations_utils.hpp | 5 ++++- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src') 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 { + bool disjoint, + std::filesystem::path const& where) noexcept + -> expected { // 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 #include #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; + bool disjoint, + std::filesystem::path const& where = std::filesystem::path{}) noexcept + -> expected; }; #endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_ENGINE_TREE_OPERATIONS_TREE_OPERATIONS_UTILS_HPP -- cgit v1.2.3