diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2021-08-16 18:54:15 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-08-18 10:52:23 +0300 |
commit | cd315fecaf4c7473950c1610e06417634b416954 (patch) | |
tree | fdc821b4e55c3af9b87fd678a8c550089e52ef80 /bpkg/manifest-utility.cxx | |
parent | c7d9b6020f41ef64d9315ec0bf3e2b4a1c59f67b (diff) |
Optimize rep-fetch for dir and git repos quering projects info in single call
Diffstat (limited to 'bpkg/manifest-utility.cxx')
-rw-r--r-- | bpkg/manifest-utility.cxx | 55 |
1 files changed, 32 insertions, 23 deletions
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<version> - package_version (const common_options& o, const dir_path& d) + vector<optional<version>> + package_versions (const common_options& o, const dir_paths& ds) { path b (name_b (o)); + vector<b_project_info> 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<version> 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<optional<version>> 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<version> ()); + } 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; } } |