From db495f3c771ecfe2911d55ba41ab83d22409bcc0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 25 Jan 2016 16:01:42 +0200 Subject: Print reason for fetching repository unless user-added --- bpkg/cfg-fetch.cxx | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/bpkg/cfg-fetch.cxx b/bpkg/cfg-fetch.cxx index 1fba31e..c261863 100644 --- a/bpkg/cfg-fetch.cxx +++ b/bpkg/cfg-fetch.cxx @@ -25,7 +25,9 @@ namespace bpkg static void cfg_fetch (const common_options& co, transaction& t, - const shared_ptr& r) + const shared_ptr& r, + const shared_ptr& root, + const string& reason) { tracer trace ("cfg_fetch(rep)"); @@ -39,8 +41,20 @@ namespace bpkg // The fetch_*() functions below will be quiet at level 1, which // can be quite confusing if the download hangs. // - if (verb >= (rl.remote () ? 1 : 2)) - text << "fetching " << r->name; + if (verb) + { + diag_record dr (text); + + dr << "fetching " << r->name; + + const auto& ua (root->complements); + + if (ua.find (lazy_shared_ptr (db, r)) == ua.end ()) + { + assert (!reason.empty ()); + dr << " (" << reason << ")"; + } + } r->fetched = true; // Mark as being fetched. @@ -89,7 +103,18 @@ namespace bpkg // (or is already being) fetched. // if (!pr->fetched) - cfg_fetch (co, t, pr); + { + string reason; + switch (rr) + { + case repository_role::complement: reason = "complements "; break; + case repository_role::prerequisite: reason = "prerequisite of "; break; + case repository_role::base: assert (false); + } + reason += r->name; + + cfg_fetch (co, t, pr, root, reason); + } // @@ What if we have duplicated? Ideally, we would like to check // this once and as early as possible. The original idea was to @@ -226,7 +251,7 @@ namespace bpkg // their packages. // for (const lazy_shared_ptr& lp: ua) - cfg_fetch (o, t, lp.load ()); + cfg_fetch (o, t, lp.load (), root, ""); // No reason (user-added). size_t rcount, pcount; if (verb) -- cgit v1.1