From 636d69c1b740d8975bb7c7a3b518c280ac224545 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 16 Jun 2023 18:17:07 +0300 Subject: Add --mask-repository pkg-build option --- bpkg/pkg-build-collect.cxx | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'bpkg/pkg-build-collect.cxx') diff --git a/bpkg/pkg-build-collect.cxx b/bpkg/pkg-build-collect.cxx index 86dcb24..036e5b6 100644 --- a/bpkg/pkg-build-collect.cxx +++ b/bpkg/pkg-build-collect.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -153,7 +154,23 @@ namespace bpkg // If adjustment or orphan, then new and old are the same. // - if (available == nullptr || available->locations.empty ()) + // Note that in the common case a package version doesn't come from too + // many repositories (8). + // + small_vector, 8> locations; + + if (available != nullptr) // Not adjustment? + { + locations.reserve (available->locations.size ()); + + for (const package_location& pl: available->locations) + { + if (!rep_masked_fragment (pl.repository_fragment)) + locations.push_back (pl); + } + } + + if (locations.empty ()) { assert (selected != nullptr); @@ -169,7 +186,7 @@ namespace bpkg } else { - const package_location& pl (available->locations[0]); + const package_location& pl (locations[0]); if (pl.repository_fragment.object_id () == "") // Special root? { @@ -189,7 +206,7 @@ namespace bpkg // Note that such repository fragments are always preferred over // others (see below). // - for (const package_location& pl: available->locations) + for (const package_location& pl: locations) { const repository_location& rl ( pl.repository_fragment.load ()->location); @@ -1127,7 +1144,7 @@ namespace bpkg void build_packages:: enter (package_name name, build_package pkg) { - assert (!pkg.action); + assert (!pkg.action && pkg.repository_fragment == nullptr); database& db (pkg.db); // Save before the move() call. auto p (map_.emplace (package_key {db, move (name)}, @@ -1157,6 +1174,9 @@ namespace bpkg tracer trace ("collect_build"); + assert (pkg.repository_fragment == nullptr || + !rep_masked_fragment (pkg.repository_fragment)); + // See the above notes. // bool recursive (dep_chain != nullptr); -- cgit v1.1