diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-11 15:50:48 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-11 17:53:08 +0200 |
commit | e80ebd1c1a6fe7749c1565c4a9e2fccaa07d5d95 (patch) | |
tree | 6cc8e8d6f65d3cd631e458e62c9c74ed9de29411 | |
parent | aacff79e854d6d4eb22540339bc88c3efab353a2 (diff) |
Add package::internal() predicate
-rw-r--r-- | brep/package | 3 | ||||
-rw-r--r-- | brep/package-details.cxx | 2 | ||||
-rw-r--r-- | brep/package-version-details.cxx | 6 | ||||
-rw-r--r-- | brep/package.cxx | 2 | ||||
-rw-r--r-- | brep/page.cxx | 2 | ||||
-rw-r--r-- | loader/loader.cxx | 13 | ||||
-rw-r--r-- | tests/loader/driver.cxx | 8 |
7 files changed, 17 insertions, 19 deletions
diff --git a/brep/package b/brep/package index ef73542..8fc6a43 100644 --- a/brep/package +++ b/brep/package @@ -407,6 +407,9 @@ namespace brep // package (std::string name, version_type, std::shared_ptr<repository_type>); + bool + internal () const noexcept {return internal_repository != nullptr;} + // Manifest data. // package_id id; diff --git a/brep/package-details.cxx b/brep/package-details.cxx index 0424d5b..12480c8 100644 --- a/brep/package-details.cxx +++ b/brep/package-details.cxx @@ -198,7 +198,7 @@ namespace brep if (p->license_alternatives != ll) s << TR_LICENSE (p->license_alternatives); - assert (p->internal_repository != nullptr); + assert (p->internal ()); // @@ Shouldn't we make package location to be a link to the proper // place of the About page, describing corresponding repository? diff --git a/brep/package-version-details.cxx b/brep/package-version-details.cxx index a4fa95a..9c90b8d 100644 --- a/brep/package-version-details.cxx +++ b/brep/package-version-details.cxx @@ -131,7 +131,7 @@ namespace brep // If the requested package turned up to be an "external" one just // respond that no "internal" package is present. // - not_found = p->internal_repository == nullptr; + not_found = !p->internal (); } catch (const object_not_persistent& ) { @@ -212,7 +212,7 @@ namespace brep shared_ptr<package> p (d.package.load ()); string en (mime_url_encode (p->id.name)); - if (p->internal_repository != nullptr) + if (p->internal ()) s << A << HREF << "/go/" << en << ~HREF << p->id.name << ~A; else // @@ Refer to package repository URL when supported in repository @@ -224,7 +224,7 @@ namespace brep { s << ' '; - if (p->internal_repository != nullptr) + if (p->internal ()) s << A << HREF << "/go/" << en << "/" << p->version.string () << ~HREF << *d.constraint diff --git a/brep/package.cxx b/brep/package.cxx index 3c65ed8..853d484 100644 --- a/brep/package.cxx +++ b/brep/package.cxx @@ -77,7 +77,7 @@ namespace brep weighted_text package:: search_text () const { - if (internal_repository == nullptr) + if (!internal ()) return weighted_text (); // Derive keywords from the basic package information: name, diff --git a/brep/page.cxx b/brep/page.cxx index deee055..481825b 100644 --- a/brep/page.cxx +++ b/brep/page.cxx @@ -284,7 +284,7 @@ namespace brep shared_ptr<package> p (da.package.load ()); - if (p->internal_repository != nullptr) + if (p->internal ()) s << A << HREF << "/go/" << mime_url_encode (n) << ~HREF << n << ~A; else // @@ Refer to package repository URL when supported in repository diff --git a/loader/loader.cxx b/loader/loader.cxx index 74844f5..782d3f3 100644 --- a/loader/loader.cxx +++ b/loader/loader.cxx @@ -372,7 +372,7 @@ load_packages (const shared_ptr<repository>& rp, database& db) // As soon as internal repositories get loaded first, the internal // package can duplicate an internal package only. // - assert (!rp->internal || p->internal_repository != nullptr); + assert (!rp->internal || p->internal ()); p->other_repositories.push_back (rp); db.update (p); @@ -560,10 +560,7 @@ resolve_dependencies (package& p, database& db) { // Resolve dependencies for internal packages only. // - // @@ add package::internal() predicate? Lots of place where you do - // (p.internal_repository != nullptr). - // - assert (p.internal_repository != nullptr); + assert (p.internal ()); if (p.dependencies.empty ()) return; @@ -651,12 +648,10 @@ detect_dependency_cycle (const package_id& id, package_ids& chain, database& db) [&o, &db](const package_id& id) { shared_ptr<package> p (db.load<package> (id)); - - assert (p->internal_repository != nullptr || - !p->other_repositories.empty ()); + assert (p->internal () || !p->other_repositories.empty ()); shared_ptr<repository> r ( - p->internal_repository != nullptr + p->internal () ? p->internal_repository.load () : p->other_repositories[0].load ()); diff --git a/tests/loader/driver.cxx b/tests/loader/driver.cxx index 2222fde..881a2db 100644 --- a/tests/loader/driver.cxx +++ b/tests/loader/driver.cxx @@ -38,11 +38,11 @@ operator== (const dependency& a, const dependency& b) static bool check_location (shared_ptr<package>& p) { - if (p->internal_repository == nullptr) - return !p->location; - else + if (p->internal ()) return p->location && *p->location == path (p->id.name + "-" + p->version.string () + ".tar.gz"); + else + return !p->location; } static bool @@ -50,7 +50,7 @@ check_external (const package& p) { return p.summary.empty () && p.tags.empty () && !p.description && p.url.empty () && !p.package_url && p.email.empty () && !p.package_email && - p.internal_repository == nullptr && p.other_repositories.size () > 0 && + !p.internal () && p.other_repositories.size () > 0 && p.priority == priority () && p.changes.empty () && p.license_alternatives.empty () && p.dependencies.empty () && p.requirements.empty (); |