diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-09-22 17:19:33 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-11-02 12:06:50 +0100 |
commit | cd7c3224480b0a8e9c93f22c10caea8fb987be07 (patch) | |
tree | 7dd1e711fb83082503e38388cfd9ff96a3b393d9 | |
parent | c8724482c2f06d88947f83a16935445b7561afd1 (diff) | |
download | justbuild-cd7c3224480b0a8e9c93f22c10caea8fb987be07.tar.gz |
content git map: Move handling of --fetch-absent flag from checkout to the map itself
-rw-r--r-- | src/other_tools/just_mr/setup.cpp | 1 | ||||
-rw-r--r-- | src/other_tools/repo_map/repos_to_setup_map.cpp | 4 | ||||
-rw-r--r-- | src/other_tools/root_maps/content_git_map.cpp | 25 | ||||
-rw-r--r-- | src/other_tools/root_maps/content_git_map.hpp | 1 |
4 files changed, 20 insertions, 11 deletions
diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp index 5fb5512f..b98fbc25 100644 --- a/src/other_tools/just_mr/setup.cpp +++ b/src/other_tools/just_mr/setup.cpp @@ -130,6 +130,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config, &import_to_git_map, &resolve_symlinks_map, &critical_git_op_map, + common_args.fetch_absent, common_args.jobs); auto fpath_git_map = CreateFilePathGitMap(just_cmd_args.subcmd_name, &critical_git_op_map, diff --git a/src/other_tools/repo_map/repos_to_setup_map.cpp b/src/other_tools/repo_map/repos_to_setup_map.cpp index 7de7e2ff..a72903d1 100644 --- a/src/other_tools/repo_map/repos_to_setup_map.cpp +++ b/src/other_tools/repo_map/repos_to_setup_map.cpp @@ -151,7 +151,6 @@ void ArchiveCheckout(ExpressionPtr const& repo_desc, std::string const& repo_name, std::string const& repo_type, gsl::not_null<ContentGitMap*> const& content_git_map, - bool fetch_absent, gsl::not_null<TaskSystem*> const& ts, ReposToSetupMap::SetterPtr const& setter, ReposToSetupMap::LoggerPtr const& logger) { @@ -226,7 +225,7 @@ void ArchiveCheckout(ExpressionPtr const& repo_desc, .repo_type = repo_type, .subdir = subdir.empty() ? "." : subdir.string(), .pragma_special = pragma_special_value, - .absent = not fetch_absent and pragma_absent_value}; + .absent = pragma_absent_value}; // get the WS root as git tree content_git_map->ConsumeAfterKeysReady( ts, @@ -774,7 +773,6 @@ auto CreateReposToSetupMap(std::shared_ptr<Configuration> const& config, key, repo_type_str, content_git_map, - fetch_absent, ts, setter, wrapped_logger); diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp index a82670ea..19c8644a 100644 --- a/src/other_tools/root_maps/content_git_map.cpp +++ b/src/other_tools/root_maps/content_git_map.cpp @@ -49,6 +49,7 @@ void ResolveContentTree( bool is_cache_hit, std::optional<PragmaSpecial> const& pragma_special, bool absent, + bool fetch_absent, gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map, gsl::not_null<TaskSystem*> const& ts, ContentGitMap::SetterPtr const& ws_setter, @@ -70,7 +71,7 @@ void ResolveContentTree( // set the workspace root auto root = nlohmann::json::array( {FileRoot::kGitTreeMarker, *resolved_tree_id}); - if (not absent) { + if (fetch_absent or not absent) { root.emplace_back(StorageConfig::GitRoot().string()); } (*ws_setter)(std::pair(std::move(root), true)); @@ -88,6 +89,7 @@ void ResolveContentTree( tree_id_file, is_cache_hit, absent, + fetch_absent, ws_setter, logger](auto const& hashes) { if (not hashes[0]) { @@ -121,7 +123,7 @@ void ResolveContentTree( // set the workspace root auto root = nlohmann::json::array( {FileRoot::kGitTreeMarker, resolved_tree.id}); - if (not absent) { + if (fetch_absent or not absent) { root.emplace_back(StorageConfig::GitRoot().string()); } (*ws_setter)(std::pair(std::move(root), is_cache_hit)); @@ -139,7 +141,7 @@ void ResolveContentTree( // set the workspace root as-is auto root = nlohmann::json::array({FileRoot::kGitTreeMarker, tree_hash}); - if (not absent) { + if (fetch_absent or not absent) { root.emplace_back(StorageConfig::GitRoot().string()); } (*ws_setter)(std::pair(std::move(root), is_cache_hit)); @@ -153,15 +155,17 @@ auto CreateContentGitMap( gsl::not_null<ImportToGitMap*> const& import_to_git_map, gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map, gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map, + bool fetch_absent, std::size_t jobs) -> ContentGitMap { auto gitify_content = [content_cas_map, import_to_git_map, resolve_symlinks_map, - critical_git_op_map](auto ts, - auto setter, - auto logger, - auto /* unused */, - auto const& key) { + critical_git_op_map, + fetch_absent](auto ts, + auto setter, + auto logger, + auto /* unused */, + auto const& key) { auto archive_tree_id_file = StorageUtils::GetArchiveTreeIDFile( key.repo_type, key.archive.content); if (FileSystemManager::Exists(archive_tree_id_file)) { @@ -193,6 +197,7 @@ auto CreateContentGitMap( content = key.archive.content, pragma_special = key.pragma_special, absent = key.absent, + fetch_absent, resolve_symlinks_map, ts, setter, @@ -233,6 +238,7 @@ auto CreateContentGitMap( true, /*is_cache_hit*/ pragma_special, absent, + fetch_absent, resolve_symlinks_map, ts, setter, @@ -259,6 +265,7 @@ auto CreateContentGitMap( subdir = key.subdir, pragma_special = key.pragma_special, absent = key.absent, + fetch_absent, import_to_git_map, resolve_symlinks_map, ts, @@ -303,6 +310,7 @@ auto CreateContentGitMap( subdir, pragma_special, absent, + fetch_absent, resolve_symlinks_map, ts, setter, @@ -365,6 +373,7 @@ auto CreateContentGitMap( false, /*is_cache_hit*/ pragma_special, absent, + fetch_absent, resolve_symlinks_map, ts, setter, diff --git a/src/other_tools/root_maps/content_git_map.hpp b/src/other_tools/root_maps/content_git_map.hpp index db0950f0..c5b02454 100644 --- a/src/other_tools/root_maps/content_git_map.hpp +++ b/src/other_tools/root_maps/content_git_map.hpp @@ -31,6 +31,7 @@ using ContentGitMap = gsl::not_null<ImportToGitMap*> const& import_to_git_map, gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map, gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map, + bool fetch_absent, std::size_t jobs) -> ContentGitMap; #endif // INCLUDED_SRC_OTHER_TOOLS_ROOT_MAPS_CONTENT_GIT_MAP_HPP |