From a2b084651909929d58f6b4bc0f3c742d87ee31f6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 27 Apr 2018 15:53:00 +0300 Subject: Add support for repository fragments --- bpkg/rep-list.cxx | 52 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 22 deletions(-) (limited to 'bpkg/rep-list.cxx') diff --git a/bpkg/rep-list.cxx b/bpkg/rep-list.cxx index 8d308dd..f1e251c 100644 --- a/bpkg/rep-list.cxx +++ b/bpkg/rep-list.cxx @@ -20,7 +20,7 @@ namespace bpkg // // Each line has the following form: // - // [(complement|prerequisite) ] + // [(complement|prerequisite) ] [ ()] // // and is indented with 2 additional spaces for each recursion level. // @@ -44,34 +44,42 @@ namespace bpkg indent += " "; - if (o.complements ()) + auto print_repo = [&o, &indent, &chain] ( + const shared_ptr& r, + const char* role, + const repository::fragment_type& fr) { - for (const lazy_shared_ptr& rp: r->complements) - { - // Skip the root complement (see rep_fetch() for details). - // - if (rp.object_id () == "") - continue; + cout << indent << role << ' ' << r->name << ' ' << r->location; - shared_ptr r (rp.load ()); + if (!fr.friendly_name.empty ()) + cout << " (" << fr.friendly_name << ")"; - cout << indent << "complement " - << r->location.canonical_name () << " " << r->location << endl; + cout << endl; - print_dependencies (o, r, indent, chain); - } - } + print_dependencies (o, r, indent, chain); + }; - if (o.prerequisites ()) + for (const repository::fragment_type& rfr: r->fragments) { - for (const lazy_weak_ptr& rp: r->prerequisites) - { - shared_ptr r (rp.load ()); + shared_ptr fr (rfr.fragment.load ()); - cout << indent << "prerequisite " - << r->location.canonical_name () << " " << r->location << endl; + if (o.complements ()) + { + for (const lazy_shared_ptr& rp: fr->complements) + { + // Skip the root complement (see rep_fetch() for details). + // + if (rp.object_id () == "") + continue; + + print_repo (rp.load (), "complement", rfr); + } + } - print_dependencies (o, r, indent, chain); + if (o.prerequisites ()) + { + for (const lazy_weak_ptr& rp: fr->prerequisites) + print_repo (rp.load (), "prerequisite", rfr); } } @@ -104,7 +112,7 @@ namespace bpkg transaction t (db); session s; // Repository dependencies can have cycles. - shared_ptr root (db.load ("")); + shared_ptr root (db.load ("")); for (const lazy_shared_ptr& rp: root->complements) { -- cgit v1.1