summaryrefslogtreecommitdiff
path: root/src/other_tools/repo_map
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/repo_map
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/repo_map')
-rw-r--r--src/other_tools/repo_map/repos_to_setup_map.cpp47
1 files changed, 42 insertions, 5 deletions
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 69addd88..5aefe3b1 100644
--- a/src/other_tools/repo_map/repos_to_setup_map.cpp
+++ b/src/other_tools/repo_map/repos_to_setup_map.cpp
@@ -102,6 +102,12 @@ void GitCheckout(ExpressionPtr const& repo_desc,
? std::make_optional(
kPragmaSpecialMap.at(pragma_special->get()->String()))
: std::nullopt;
+ // check "absent" pragma
+ auto pragma_absent =
+ repo_desc_pragma ? repo_desc_pragma->get()->At("absent") : std::nullopt;
+ auto pragma_absent_value = pragma_absent and
+ pragma_absent->get()->IsBool() and
+ pragma_absent->get()->Bool();
// populate struct
GitRepoInfo git_repo_info = {
.hash = repo_desc_commit->get()->String(),
@@ -109,7 +115,8 @@ void GitCheckout(ExpressionPtr const& repo_desc,
.branch = repo_desc_branch->get()->String(),
.subdir = subdir.empty() ? "." : subdir.string(),
.origin = repo_name,
- .ignore_special = pragma_special_value == PragmaSpecial::Ignore};
+ .ignore_special = pragma_special_value == PragmaSpecial::Ignore,
+ .absent = pragma_absent_value};
// get the WS root as git tree
commit_git_map->ConsumeAfterKeysReady(
ts,
@@ -192,6 +199,12 @@ void ArchiveCheckout(ExpressionPtr const& repo_desc,
? std::make_optional(
kPragmaSpecialMap.at(pragma_special->get()->String()))
: std::nullopt;
+ // check "absent" pragma
+ auto pragma_absent =
+ repo_desc_pragma ? repo_desc_pragma->get()->At("absent") : std::nullopt;
+ auto pragma_absent_value = pragma_absent and
+ pragma_absent->get()->IsBool() and
+ pragma_absent->get()->Bool();
// populate struct
ArchiveRepoInfo archive_repo_info = {
.archive =
@@ -210,7 +223,8 @@ void ArchiveCheckout(ExpressionPtr const& repo_desc,
.origin_from_distdir = false},
.repo_type = repo_type,
.subdir = subdir.empty() ? "." : subdir.string(),
- .pragma_special = pragma_special_value};
+ .pragma_special = pragma_special_value,
+ .absent = pragma_absent_value};
// get the WS root as git tree
content_git_map->ConsumeAfterKeysReady(
ts,
@@ -283,9 +297,17 @@ void FileCheckout(ExpressionPtr const& repo_desc,
pragma_special_value == PragmaSpecial::ResolveCompletely or
(pragma_to_git and pragma_to_git->get()->IsBool() and
pragma_to_git->get()->Bool())) {
+ // check "absent" pragma
+ auto pragma_absent = repo_desc_pragma
+ ? repo_desc_pragma->get()->At("absent")
+ : std::nullopt;
+ auto pragma_absent_value = pragma_absent and
+ pragma_absent->get()->IsBool() and
+ pragma_absent->get()->Bool();
// get the WS root as git tree
FpathInfo fpath_info = {.fpath = fpath,
- .pragma_special = pragma_special_value};
+ .pragma_special = pragma_special_value,
+ .absent = pragma_absent_value};
fpath_git_map->ConsumeAfterKeysReady(
ts,
{std::move(fpath_info)},
@@ -345,6 +367,13 @@ void DistdirCheckout(ExpressionPtr const& repo_desc,
/*fatal=*/true);
return;
}
+ // check "absent" pragma
+ auto repo_desc_pragma = repo_desc->At("pragma");
+ auto pragma_absent =
+ repo_desc_pragma ? repo_desc_pragma->get()->At("absent") : std::nullopt;
+ auto pragma_absent_value = pragma_absent and
+ pragma_absent->get()->IsBool() and
+ pragma_absent->get()->Bool();
// map of distfile to content
auto distdir_content =
std::make_shared<std::unordered_map<std::string, std::string>>();
@@ -483,7 +512,8 @@ void DistdirCheckout(ExpressionPtr const& repo_desc,
DistdirInfo distdir_info = {.content_id = distdir_content_id,
.content_list = distdir_content,
.repos_to_fetch = dist_repos_to_fetch,
- .origin = repo_name};
+ .origin = repo_name,
+ .absent = pragma_absent_value};
distdir_git_map->ConsumeAfterKeysReady(
ts,
{std::move(distdir_info)},
@@ -586,12 +616,19 @@ void GitTreeCheckout(ExpressionPtr const& repo_desc,
? std::make_optional(
kPragmaSpecialMap.at(pragma_special->get()->String()))
: std::nullopt;
+ // check "absent" pragma
+ auto pragma_absent =
+ repo_desc_pragma ? repo_desc_pragma->get()->At("absent") : std::nullopt;
+ auto pragma_absent_value = pragma_absent and
+ pragma_absent->get()->IsBool() and
+ pragma_absent->get()->Bool();
// populate struct
TreeIdInfo tree_id_info = {
.hash = repo_desc_hash->get()->String(),
.env_vars = std::move(env),
.command = std::move(cmd),
- .ignore_special = pragma_special_value == PragmaSpecial::Ignore};
+ .ignore_special = pragma_special_value == PragmaSpecial::Ignore,
+ .absent = pragma_absent_value};
// get the WS root as git tree
tree_id_git_map->ConsumeAfterKeysReady(
ts,