From cd315fecaf4c7473950c1610e06417634b416954 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 16 Aug 2021 18:54:15 +0300 Subject: Optimize rep-fetch for dir and git repos quering projects info in single call --- bpkg/manifest-utility.cxx | 55 +++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'bpkg/manifest-utility.cxx') diff --git a/bpkg/manifest-utility.cxx b/bpkg/manifest-utility.cxx index 6ca9e18..a4cee94 100644 --- a/bpkg/manifest-utility.cxx +++ b/bpkg/manifest-utility.cxx @@ -272,33 +272,39 @@ namespace bpkg } } - optional - package_version (const common_options& o, const dir_path& d) + vector> + package_versions (const common_options& o, const dir_paths& ds) { path b (name_b (o)); + vector pis; try { - b_project_info pi ( - b_info (d, - false /* ext_mods */, - verb, - [] (const char* const args[], size_t n) - { - if (verb >= 2) - print_process (args, n); - }, - b, - exec_dir, - o.build_option ())); - - optional r; - - // An empty version indicates that the version module is not enabled for - // the project. - // - if (!pi.version.empty ()) - r = version (pi.version.string ()); + b_info (pis, + ds, + false /* ext_mods */, + verb, + [] (const char* const args[], size_t n) + { + if (verb >= 2) + print_process (args, n); + }, + b, + exec_dir, + o.build_option ()); + + vector> r; + r.reserve (pis.size ()); + + for (const b_project_info& pi: pis) + { + // An empty version indicates that the version module is not enabled + // for the project. + // + r.push_back (!pi.version.empty () + ? version (pi.version.string ()) + : optional ()); + } return r; } @@ -307,7 +313,10 @@ namespace bpkg if (e.normal ()) throw failed (); // Assume the build2 process issued diagnostics. - fail << "unable to parse project " << d << " info: " << e << + diag_record dr (fail); + dr << "unable to parse project "; + if (pis.size () < ds.size ()) dr << ds[pis.size ()] << ' '; + dr << "info: " << e << info << "produced by '" << b << "'; use --build to override" << endf; } } -- cgit v1.1