summaryrefslogtreecommitdiff
path: root/src/other_tools/root_maps/content_git_map.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-09-08 18:15:01 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-09-13 16:14:43 +0200
commit669d1d8714b258ffd19f1610028374233a143f4b (patch)
treeef3774508075f028637844fac2095a5dc2cbce08 /src/other_tools/root_maps/content_git_map.cpp
parentf48e1ebe7f08159004bf9a88d5a9e474ff32dbb1 (diff)
downloadjustbuild-669d1d8714b258ffd19f1610028374233a143f4b.tar.gz
just-mr: Implement 'absent' roots
...via an 'absent' pragma in repository descriptions. For 'git'-type repositories, first interrogates a 'just serve' remote, if given, before reverting to fetching from the network.
Diffstat (limited to 'src/other_tools/root_maps/content_git_map.cpp')
-rw-r--r--src/other_tools/root_maps/content_git_map.cpp42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp
index 64c3db75..9930984e 100644
--- a/src/other_tools/root_maps/content_git_map.cpp
+++ b/src/other_tools/root_maps/content_git_map.cpp
@@ -46,6 +46,7 @@ void ResolveContentTree(
std::string const& tree_hash,
bool is_cache_hit,
std::optional<PragmaSpecial> const& pragma_special,
+ bool absent,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
gsl::not_null<TaskSystem*> const& ts,
ContentGitMap::SetterPtr const& ws_setter,
@@ -65,12 +66,12 @@ void ResolveContentTree(
return;
}
// set the workspace root
- (*ws_setter)(std::pair(
- nlohmann::json::array({FileRoot::kGitTreeMarker,
- *resolved_tree_id,
- StorageConfig::GitRoot().string()}),
- true // it is definitely a cache hit
- ));
+ auto root = nlohmann::json::array(
+ {FileRoot::kGitTreeMarker, *resolved_tree_id});
+ if (not absent) {
+ root.emplace_back(StorageConfig::GitRoot().string());
+ }
+ (*ws_setter)(std::pair(std::move(root), true));
}
else {
// resolve tree
@@ -84,6 +85,7 @@ void ResolveContentTree(
tree_hash,
tree_id_file,
is_cache_hit,
+ absent,
ws_setter,
logger](auto const& hashes) {
if (not hashes[0]) {
@@ -115,12 +117,12 @@ void ResolveContentTree(
return;
}
// set the workspace root
- (*ws_setter)(
- std::pair(nlohmann::json::array(
- {FileRoot::kGitTreeMarker,
- resolved_tree.id,
- StorageConfig::GitRoot().string()}),
- is_cache_hit));
+ auto root = nlohmann::json::array(
+ {FileRoot::kGitTreeMarker, resolved_tree.id});
+ if (not absent) {
+ root.emplace_back(StorageConfig::GitRoot().string());
+ }
+ (*ws_setter)(std::pair(std::move(root), is_cache_hit));
},
[logger, content](auto const& msg, bool fatal) {
(*logger)(fmt::format("While resolving symlinks for "
@@ -133,11 +135,12 @@ void ResolveContentTree(
}
else {
// set the workspace root as-is
- (*ws_setter)(std::pair(
- nlohmann::json::array({FileRoot::kGitTreeMarker,
- tree_hash,
- StorageConfig::GitRoot().string()}),
- is_cache_hit));
+ auto root =
+ nlohmann::json::array({FileRoot::kGitTreeMarker, tree_hash});
+ if (not absent) {
+ root.emplace_back(StorageConfig::GitRoot().string());
+ }
+ (*ws_setter)(std::pair(std::move(root), is_cache_hit));
}
}
@@ -187,6 +190,7 @@ auto CreateContentGitMap(
subdir = key.subdir,
content = key.archive.content,
pragma_special = key.pragma_special,
+ absent = key.absent,
resolve_symlinks_map,
ts,
setter,
@@ -226,6 +230,7 @@ auto CreateContentGitMap(
*subtree_hash,
true, /*is_cache_hit*/
pragma_special,
+ absent,
resolve_symlinks_map,
ts,
setter,
@@ -251,6 +256,7 @@ auto CreateContentGitMap(
content_id = key.archive.content,
subdir = key.subdir,
pragma_special = key.pragma_special,
+ absent = key.absent,
import_to_git_map,
resolve_symlinks_map,
ts,
@@ -294,6 +300,7 @@ auto CreateContentGitMap(
content_id,
subdir,
pragma_special,
+ absent,
resolve_symlinks_map,
ts,
setter,
@@ -355,6 +362,7 @@ auto CreateContentGitMap(
*subtree_hash,
false, /*is_cache_hit*/
pragma_special,
+ absent,
resolve_symlinks_map,
ts,
setter,