aboutsummaryrefslogtreecommitdiff
path: root/bpkg/package-query.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bpkg/package-query.cxx')
-rw-r--r--bpkg/package-query.cxx124
1 files changed, 84 insertions, 40 deletions
diff --git a/bpkg/package-query.cxx b/bpkg/package-query.cxx
index 9675d97..4377f5c 100644
--- a/bpkg/package-query.cxx
+++ b/bpkg/package-query.cxx
@@ -136,6 +136,8 @@ namespace bpkg
repository_fragments& chain,
bool prereq)
{
+ assert (!masked_repository_fragment (rf));
+
// Prerequisites are not searched through recursively.
//
assert (!prereq || chain.empty ());
@@ -159,6 +161,9 @@ namespace bpkg
{
const lazy_shared_ptr<repository_fragment>& lrf (pl.repository_fragment);
+ if (masked_repository_fragment (lrf))
+ continue;
+
// First check the repository itself.
//
if (lrf.object_id () == rf->name)
@@ -175,20 +180,26 @@ namespace bpkg
for (const lazy_weak_ptr<repository>& r: cs)
{
- const auto& frs (r.load ()->fragments);
+ if (!masked_repository (r))
+ {
+ const auto& frs (r.load ()->fragments);
- if (find_if (frs.begin (), frs.end (), pr) != frs.end ())
- return lrf.load ();
+ if (find_if (frs.begin (), frs.end (), pr) != frs.end ())
+ return lrf.load ();
+ }
}
if (prereq)
{
for (const lazy_weak_ptr<repository>& r: ps)
{
- const auto& frs (r.load ()->fragments);
+ if (!masked_repository (r))
+ {
+ const auto& frs (r.load ()->fragments);
- if (find_if (frs.begin (), frs.end (), pr) != frs.end ())
- return lrf.load ();
+ if (find_if (frs.begin (), frs.end (), pr) != frs.end ())
+ return lrf.load ();
+ }
}
}
}
@@ -198,14 +209,17 @@ namespace bpkg
//
for (const lazy_weak_ptr<repository>& cr: cs)
{
- for (const auto& fr: cr.load ()->fragments)
+ if (!masked_repository (cr))
{
- // Should we consider prerequisites of our complements as our
- // prerequisites? I'd say not.
- //
- if (shared_ptr<repository_fragment> r =
- find (fr.fragment.load (), ap, chain, false))
- return r;
+ for (const auto& fr: cr.load ()->fragments)
+ {
+ // Should we consider prerequisites of our complements as our
+ // prerequisites? I'd say not.
+ //
+ if (shared_ptr<repository_fragment> r =
+ find (fr.fragment.load (), ap, chain, false))
+ return r;
+ }
}
}
@@ -213,11 +227,14 @@ namespace bpkg
{
for (const lazy_weak_ptr<repository>& pr: ps)
{
- for (const auto& fr: pr.load ()->fragments)
+ if (!masked_repository (pr))
{
- if (shared_ptr<repository_fragment> r =
- find (fr.fragment.load (), ap, chain, false))
- return r;
+ for (const auto& fr: pr.load ()->fragments)
+ {
+ if (shared_ptr<repository_fragment> r =
+ find (fr.fragment.load (), ap, chain, false))
+ return r;
+ }
}
}
}
@@ -239,6 +256,8 @@ namespace bpkg
result<available_package>&& apr,
bool prereq)
{
+ assert (!masked_repository_fragment (r));
+
vector<shared_ptr<available_package>> aps;
for (shared_ptr<available_package> ap: pointer_result (apr))
@@ -258,6 +277,8 @@ namespace bpkg
using result = pair<shared_ptr<available_package>,
shared_ptr<repository_fragment>>;
+ assert (!masked_repository_fragment (r));
+
for (shared_ptr<available_package> ap: pointer_result (apr))
{
if (shared_ptr<repository_fragment> pr = filter (r, ap, prereq))
@@ -345,15 +366,20 @@ namespace bpkg
for (shared_ptr<available_package> ap:
pointer_result (query_available (db, name, c)))
{
- // An available package should come from at least one fetched
- // repository fragment.
+ // All repository fragments the package comes from are equally good,
+ // so we pick the first unmasked one.
//
- assert (!ap->locations.empty ());
+ for (const auto& pl: ap->locations)
+ {
+ const lazy_shared_ptr<repository_fragment>& lrf (
+ pl.repository_fragment);
- // All repository fragments the package comes from are equally good, so
- // we pick the first one.
- //
- r.emplace_back (move (ap), ap->locations[0].repository_fragment);
+ if (!masked_repository_fragment (lrf))
+ {
+ r.emplace_back (move (ap), lrf);
+ break;
+ }
+ }
}
}
@@ -415,6 +441,8 @@ namespace bpkg
const lazy_shared_ptr<repository_fragment>& rf,
bool prereq)
{
+ assert (!masked_repository_fragment (rf));
+
vector<shared_ptr<available_package>> r;
database& db (rf.database ());
@@ -438,6 +466,8 @@ namespace bpkg
bool prereq,
bool revision)
{
+ assert (!masked_repository_fragment (rf));
+
// Filter the result based on the repository fragment to which each
// version belongs.
//
@@ -527,17 +557,22 @@ namespace bpkg
const shared_ptr<selected_package>& sp)
{
available_package_id pid (sp->name, sp->version);
+ const string& cn (sp->repository_fragment.canonical_name ());
+
for (database& ddb: dependent_repo_configs (db))
{
shared_ptr<available_package> ap (ddb.find<available_package> (pid));
if (ap != nullptr && !ap->stub ())
{
- if (shared_ptr<repository_fragment> f = ddb.find<repository_fragment> (
- sp->repository_fragment.canonical_name ()))
- return make_pair (ap,
- lazy_shared_ptr<repository_fragment> (ddb,
- move (f)));
+ if (shared_ptr<repository_fragment> f =
+ ddb.find<repository_fragment> (cn))
+ {
+ if (!masked_repository_fragment (f))
+ return make_pair (ap,
+ lazy_shared_ptr<repository_fragment> (ddb,
+ move (f)));
+ }
}
}
@@ -592,15 +627,20 @@ namespace bpkg
pointer_result (
query_available (db, name, nullopt /* version_constraint */)))
{
- // An available package should come from at least one fetched
- // repository fragment.
+ // All repository fragments the package comes from are equally good,
+ // so we pick the first unmasked one.
//
- assert (!ap->locations.empty ());
+ for (const auto& pl: ap->locations)
+ {
+ const lazy_shared_ptr<repository_fragment>& lrf (
+ pl.repository_fragment);
- // All repository fragments the package comes from are equally good, so
- // we pick the first one.
- //
- r.emplace_back (move (ap), ap->locations[0].repository_fragment);
+ if (!masked_repository_fragment (lrf))
+ {
+ r.emplace_back (move (ap), lrf);
+ break;
+ }
+ }
}
}
@@ -638,14 +678,18 @@ namespace bpkg
// anyway.
//
lazy_shared_ptr<repository_fragment> rf;
+ const string& cn (sp->repository_fragment.canonical_name ());
for (database& ddb: dependent_repo_configs (db))
{
- if (shared_ptr<repository_fragment> f = ddb.find<repository_fragment> (
- sp->repository_fragment.canonical_name ()))
+ if (shared_ptr<repository_fragment> f =
+ ddb.find<repository_fragment> (cn))
{
- rf = lazy_shared_ptr<repository_fragment> (ddb, move (f));
- break;
+ if (!masked_repository_fragment (f))
+ {
+ rf = lazy_shared_ptr<repository_fragment> (ddb, move (f));
+ break;
+ }
}
}