diff options
author | 2011-04-02 15:14:21 +0100 | |
---|---|---|
committer | 2011-04-04 08:32:59 +0100 | |
commit | 1a8319191a0c4a585fab173199a2c898c76f30c3 (patch) | |
tree | 39ae0ee349e25f0b420fbd72cc43bd4ba3007d8d | |
parent | f243a4014b98275a3ebb7872faadab5ba1fcafa8 (diff) | |
download | paludis-1a8319191a0c4a585fab173199a2c898c76f30c3.tar.gz paludis-1a8319191a0c4a585fab173199a2c898c76f30c3.tar.xz |
Version requirements to constraints
43 files changed, 374 insertions, 784 deletions
diff --git a/doc/api/cplusplus/examples/example_dep_spec.cc b/doc/api/cplusplus/examples/example_dep_spec.cc index 8b72b16df..1c386ab62 100644 --- a/doc/api/cplusplus/examples/example_dep_spec.cc +++ b/doc/api/cplusplus/examples/example_dep_spec.cc @@ -68,31 +68,31 @@ int main(int argc, char * argv[]) if (spec.package_name_part_constraint()) cout << " " << left << setw(24) << "Package part:" << " " << spec.package_name_part_constraint()->name_part() << endl; - if (spec.version_requirements_ptr() && ! spec.version_requirements_ptr()->empty()) + if (spec.all_version_constraints() && ! spec.all_version_constraints()->empty()) { cout << " " << left << setw(24) << "Version requirements:" << " "; bool need_join(false); - for (VersionRequirements::ConstIterator r(spec.version_requirements_ptr()->begin()), - r_end(spec.version_requirements_ptr()->end()) ; r != r_end ; ++r) + for (auto r(spec.all_version_constraints()->begin()), r_end(spec.all_version_constraints()->end()) ; + r != r_end ; ++r) { if (need_join) { - switch (spec.version_requirements_mode()) + switch ((*r)->combiner()) { - case vr_and: + case vcc_and: cout << " and "; break; - case vr_or: + case vcc_or: cout << " or "; break; - case last_vr: + case last_vcc: throw InternalError(PALUDIS_HERE, "Bad version_requirements_mode"); } } - cout << r->version_operator() << r->version_spec(); + cout << (*r)->version_operator() << (*r)->version_spec(); need_join = true; } cout << endl; diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc index ec1d07545..47c95aa48 100644 --- a/paludis/dep_spec.cc +++ b/paludis/dep_spec.cc @@ -21,7 +21,6 @@ #include <paludis/environment.hh> #include <paludis/version_operator.hh> #include <paludis/version_spec.hh> -#include <paludis/version_requirements.hh> #include <paludis/util/clone-impl.hh> #include <paludis/util/log.hh> #include <paludis/util/join.hh> @@ -560,16 +559,10 @@ PackageDepSpec::category_name_part_constraint() const return _imp->data->category_name_part_constraint(); } -std::shared_ptr<const VersionRequirements> -PackageDepSpec::version_requirements_ptr() const +const std::shared_ptr<const VersionConstraintSequence> +PackageDepSpec::all_version_constraints() const { - return _imp->data->version_requirements_ptr(); -} - -VersionRequirementsMode -PackageDepSpec::version_requirements_mode() const -{ - return _imp->data->version_requirements_mode(); + return _imp->data->all_version_constraints(); } const std::shared_ptr<const AnySlotConstraint> diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh index 9682bdb9b..bd7c4af6f 100644 --- a/paludis/dep_spec.hh +++ b/paludis/dep_spec.hh @@ -32,7 +32,6 @@ #include <paludis/dep_spec-fwd.hh> #include <paludis/name.hh> #include <paludis/version_operator-fwd.hh> -#include <paludis/version_requirements-fwd.hh> #include <paludis/version_spec-fwd.hh> #include <paludis/package_id-fwd.hh> #include <paludis/environment-fwd.hh> @@ -340,14 +339,12 @@ namespace paludis const std::shared_ptr<const CategoryNamePartConstraint> category_name_part_constraint() const; /** - * Fetch the version requirements (may be a zero pointer). - */ - std::shared_ptr<const VersionRequirements> version_requirements_ptr() const; - - /** - * Fetch the version requirements mode. + * Fetch all our VersionConstraints, if we have any, or + * a null pointer otherwise. + * + * \since 0.61 */ - VersionRequirementsMode version_requirements_mode() const; + const std::shared_ptr<const VersionConstraintSequence> all_version_constraints() const; /** * Fetch the single ExactSlotConstraint, if we have one, or diff --git a/paludis/dep_spec_TEST.cc b/paludis/dep_spec_TEST.cc index 816e054ad..07779a2e4 100644 --- a/paludis/dep_spec_TEST.cc +++ b/paludis/dep_spec_TEST.cc @@ -19,7 +19,6 @@ #include <paludis/dep_spec.hh> #include <paludis/user_dep_spec.hh> -#include <paludis/version_requirements.hh> #include <paludis/environments/test/test_environment.hh> #include <paludis/util/clone-impl.hh> diff --git a/paludis/dep_spec_data.hh b/paludis/dep_spec_data.hh index 864a5a82e..d3e6f683e 100644 --- a/paludis/dep_spec_data.hh +++ b/paludis/dep_spec_data.hh @@ -26,7 +26,6 @@ #include <paludis/changed_choices-fwd.hh> #include <paludis/name-fwd.hh> #include <paludis/version_operator-fwd.hh> -#include <paludis/version_requirements-fwd.hh> #include <paludis/additional_package_dep_spec_requirement-fwd.hh> #include <paludis/dep_spec-fwd.hh> #include <paludis/partially_made_package_dep_spec-fwd.hh> @@ -137,14 +136,12 @@ namespace paludis PALUDIS_ATTRIBUTE((warn_unused_result)) = 0; /** - * Fetch the version requirements (may be a zero pointer). - */ - virtual std::shared_ptr<const VersionRequirements> version_requirements_ptr() const = 0; - - /** - * Fetch the version requirements mode. + * Fetch all our VersionConstraints, if we have any, or + * a null pointer otherwise. + * + * \since 0.61 */ - virtual VersionRequirementsMode version_requirements_mode() const = 0; + virtual const std::shared_ptr<const VersionConstraintSequence> all_version_constraints() const = 0; /** * Fetch the single ExactSlotConstraint, if we have one, or diff --git a/paludis/elike_package_dep_spec-fwd.hh b/paludis/elike_package_dep_spec-fwd.hh index c1d222688..80309cc9e 100644 --- a/paludis/elike_package_dep_spec-fwd.hh +++ b/paludis/elike_package_dep_spec-fwd.hh @@ -26,6 +26,7 @@ #include <paludis/package_id-fwd.hh> #include <paludis/version_operator-fwd.hh> #include <paludis/version_spec-fwd.hh> +#include <paludis/package_dep_spec_constraint-fwd.hh> #include <paludis/partially_made_package_dep_spec-fwd.hh> #include <functional> #include <iosfwd> @@ -78,9 +79,20 @@ namespace paludis VersionSpec elike_get_remove_trailing_version(std::string & s, const VersionSpecOptions &) PALUDIS_VISIBLE; - void elike_add_version_requirement(const VersionOperator & op, const VersionSpec & spec, PartiallyMadePackageDepSpec & result) + void elike_add_version_requirement( + const VersionSpec & spec, + const VersionOperator & op, + const VersionConstraintCombiner, + PartiallyMadePackageDepSpec & result) PALUDIS_VISIBLE; + void parse_elike_version_range( + const std::string &, + PartiallyMadePackageDepSpec &, + const ELikePackageDepSpecOptions & options, + const VersionSpecOptions & version_options, + bool & had_bracket_version_requirements) PALUDIS_VISIBLE; + void elike_add_package_requirement(const std::string & s, PartiallyMadePackageDepSpec & result) PALUDIS_VISIBLE; } diff --git a/paludis/elike_package_dep_spec.cc b/paludis/elike_package_dep_spec.cc index 7ff1474e9..226631717 100644 --- a/paludis/elike_package_dep_spec.cc +++ b/paludis/elike_package_dep_spec.cc @@ -19,15 +19,17 @@ #include <paludis/elike_package_dep_spec.hh> #include <paludis/elike_use_requirement.hh> -#include <paludis/util/options.hh> -#include <paludis/util/log.hh> -#include <paludis/util/make_named_values.hh> #include <paludis/dep_spec.hh> #include <paludis/version_operator.hh> #include <paludis/version_spec.hh> -#include <paludis/version_requirements.hh> #include <paludis/user_dep_spec.hh> #include <paludis/partially_made_package_dep_spec.hh> + +#include <paludis/util/options.hh> +#include <paludis/util/log.hh> +#include <paludis/util/make_named_values.hh> +#include <paludis/util/options.hh> + #include <strings.h> using namespace paludis; @@ -59,7 +61,7 @@ paludis::partial_parse_generic_elike_package_dep_spec(const std::string & ss, co /* Leading (or maybe =*) operator, so trailing version. */ VersionOperator op(fns.get_remove_version_operator()(s)); VersionSpec spec(fns.get_remove_trailing_version()(s)); - fns.add_version_requirement()(op, spec, result); + fns.add_version_requirement()(spec, op, vcc_and, result); fns.add_package_requirement()(s, result); } else @@ -122,68 +124,7 @@ paludis::elike_remove_trailing_square_bracket_if_exists(std::string & s, Partial << "Version range dependencies not safe for use here"; } - { - char needed_mode(0); - - while (! flag.empty()) - { - Context cc("When parsing [] segment '" + flag + "':"); - - std::string op; - std::string::size_type opos(0); - while (opos < flag.length()) - if (std::string::npos == std::string("><=~").find(flag.at(opos))) - break; - else - ++opos; - - op = flag.substr(0, opos); - flag.erase(0, opos); - - if (op.empty()) - throw PackageDepSpecError("Missing operator inside []"); - - VersionOperator vop(op); - - std::string ver; - opos = flag.find_first_of("|&"); - if (std::string::npos == opos) - { - - ver = flag; - flag.clear(); - } - else - { - if (0 == needed_mode) - needed_mode = flag.at(opos); - else if (needed_mode != flag.at(opos)) - throw PackageDepSpecError("Mixed & and | inside []"); - - result.version_requirements_mode((flag.at(opos) == '|' ? vr_or : vr_and)); - ver = flag.substr(0, opos++); - flag.erase(0, opos); - } - - if (ver.empty()) - throw PackageDepSpecError("Missing version after operator '" + stringify(vop) + " inside []"); - - if ('*' == ver.at(ver.length() - 1)) - { - ver.erase(ver.length() - 1); - if (vop == vo_equal) - vop = options[epdso_nice_equal_star] ? vo_nice_equal_star : vo_stupid_equal_star; - else - throw PackageDepSpecError("Invalid use of * with operator '" + stringify(vop) + " inside []"); - } - - VersionSpec vs(ver, version_options); - result.version_requirement(make_named_values<VersionRequirement>( - n::version_operator() = vop, - n::version_spec() = vs)); - had_bracket_version_requirements = true; - } - } + parse_elike_version_range(flag, result, options, version_options, had_bracket_version_requirements); break; case '.': @@ -429,11 +370,13 @@ paludis::elike_get_remove_trailing_version(std::string & s, const VersionSpecOpt } void -paludis::elike_add_version_requirement(const VersionOperator & op, const VersionSpec & spec, PartiallyMadePackageDepSpec & result) +paludis::elike_add_version_requirement( + const VersionSpec & ver, + const VersionOperator & op, + const VersionConstraintCombiner vcc, + PartiallyMadePackageDepSpec & result) { - result.version_requirement(make_named_values<VersionRequirement>( - n::version_operator() = op, - n::version_spec() = spec)); + result.version_constraint(ver, op, vcc); } void @@ -484,7 +427,7 @@ paludis::partial_parse_elike_package_dep_spec( return partial_parse_generic_elike_package_dep_spec(ss, make_named_values<GenericELikePackageDepSpecParseFunctions>( n::add_package_requirement() = std::bind(&elike_add_package_requirement, _1, _2), - n::add_version_requirement() = std::bind(&elike_add_version_requirement, _1, _2, _3), + n::add_version_requirement() = std::bind(&elike_add_version_requirement, _1, _2, _3, _4), n::check_sanity() = &elike_check_sanity, n::get_remove_trailing_version() = std::bind(&elike_get_remove_trailing_version, _1, version_options), n::get_remove_version_operator() = std::bind(&elike_get_remove_version_operator, _1, options), @@ -505,3 +448,68 @@ paludis::parse_elike_package_dep_spec(const std::string & ss, const ELikePackage return partial_parse_elike_package_dep_spec(ss, options, version_options); } +void +paludis::parse_elike_version_range( + const std::string & s, + PartiallyMadePackageDepSpec & result, + const ELikePackageDepSpecOptions & options, + const VersionSpecOptions & version_options, + bool & had_bracket_version_requirements) +{ + std::string flag(s); + VersionConstraintCombiner vcc(vcc_and); + + while (! flag.empty()) + { + Context cc("When parsing [] segment '" + flag + "':"); + VersionConstraintCombiner next_vcc(vcc); + + std::string op; + std::string::size_type opos(0); + while (opos < flag.length()) + if (std::string::npos == std::string("><=~").find(flag.at(opos))) + break; + else + ++opos; + + op = flag.substr(0, opos); + flag.erase(0, opos); + + if (op.empty()) + throw PackageDepSpecError("Missing operator inside []"); + + VersionOperator vop(op); + + std::string ver; + opos = flag.find_first_of("|&"); + if (std::string::npos == opos) + { + ver = flag; + flag.clear(); + } + else + { + next_vcc = (flag.at(opos) == '|' ? vcc_or : vcc_and); + ver = flag.substr(0, opos++); + flag.erase(0, opos); + } + + if (ver.empty()) + throw PackageDepSpecError("Missing version after operator '" + stringify(vop) + " inside []"); + + if ('*' == ver.at(ver.length() - 1)) + { + ver.erase(ver.length() - 1); + if (vop == vo_equal) + vop = options[epdso_nice_equal_star] ? vo_nice_equal_star : vo_stupid_equal_star; + else + throw PackageDepSpecError("Invalid use of * with operator '" + stringify(vop) + " inside []"); + } + + VersionSpec vs(ver, version_options); + result.version_constraint(vs, vop, vcc); + had_bracket_version_requirements = true; + vcc = next_vcc; + } +} + diff --git a/paludis/elike_package_dep_spec.hh b/paludis/elike_package_dep_spec.hh index 25e9041cf..9d7beb7cc 100644 --- a/paludis/elike_package_dep_spec.hh +++ b/paludis/elike_package_dep_spec.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh + * Copyright (c) 2008, 2009, 2010, 2011 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -42,7 +42,11 @@ namespace paludis struct GenericELikePackageDepSpecParseFunctions { NamedValue<n::add_package_requirement, std::function<void (const std::string &, PartiallyMadePackageDepSpec &)> > add_package_requirement; - NamedValue<n::add_version_requirement, std::function<void (const VersionOperator &, const VersionSpec &, PartiallyMadePackageDepSpec &)> > add_version_requirement; + NamedValue<n::add_version_requirement, std::function<void ( + const VersionSpec &, + const VersionOperator &, + const VersionConstraintCombiner, + PartiallyMadePackageDepSpec &)> > add_version_requirement; NamedValue<n::check_sanity, std::function<void (const std::string &)> > check_sanity; NamedValue<n::get_remove_trailing_version, std::function<VersionSpec (std::string &)> > get_remove_trailing_version; NamedValue<n::get_remove_version_operator, std::function<VersionOperator (std::string &)> > get_remove_version_operator; diff --git a/paludis/files.m4 b/paludis/files.m4 index 4d4f7d1f6..6c45c22de 100644 --- a/paludis/files.m4 +++ b/paludis/files.m4 @@ -103,6 +103,5 @@ add(`unformatted_pretty_printer', `hh', `cc', `fwd') add(`unmerger', `hh', `cc') add(`user_dep_spec', `hh', `cc', `se', `fwd', `gtest') add(`version_operator', `hh', `cc', `fwd', `se', `gtest') -add(`version_requirements', `hh', `cc', `fwd') add(`version_spec', `hh', `cc', `se', `fwd', `gtest') diff --git a/paludis/match_package.cc b/paludis/match_package.cc index 9e51e8195..44a46535a 100644 --- a/paludis/match_package.cc +++ b/paludis/match_package.cc @@ -21,7 +21,6 @@ #include <paludis/dep_spec.hh> #include <paludis/dep_spec_flattener.hh> #include <paludis/environment.hh> -#include <paludis/version_requirements.hh> #include <paludis/package_id.hh> #include <paludis/metadata_key.hh> #include <paludis/action.hh> @@ -29,6 +28,7 @@ #include <paludis/additional_package_dep_spec_requirement.hh> #include <paludis/package_dep_spec_constraint.hh> #include <paludis/contents.hh> +#include <paludis/version_operator.hh> #include <paludis/util/set.hh> #include <paludis/util/options.hh> @@ -640,36 +640,27 @@ paludis::match_package_with_maybe_changes( if (spec.category_name_part_constraint() && spec.category_name_part_constraint()->name_part() != id->name().category()) return false; - if (spec.version_requirements_ptr()) - switch (spec.version_requirements_mode()) - { - case vr_and: - for (VersionRequirements::ConstIterator r(spec.version_requirements_ptr()->begin()), - r_end(spec.version_requirements_ptr()->end()) ; r != r_end ; ++r) - if (! r->version_operator().as_version_spec_comparator()(id->version(), r->version_spec())) - return false; - break; - - case vr_or: - { - bool matched(false); - for (VersionRequirements::ConstIterator r(spec.version_requirements_ptr()->begin()), - r_end(spec.version_requirements_ptr()->end()) ; r != r_end ; ++r) - if (r->version_operator().as_version_spec_comparator()(id->version(), r->version_spec())) - { - matched = true; - break; - } - - if (! matched) - return false; - } - break; - - case last_vr: - ; + if (spec.all_version_constraints()) + { + bool ok(true); + + for (auto r(spec.all_version_constraints()->begin()), r_end(spec.all_version_constraints()->end()) ; + r != r_end ; ++r) + { + bool one((*r)->version_operator().as_version_spec_comparator()(id->version(), (*r)->version_spec())); + + switch ((*r)->combiner()) + { + case vcc_and: ok &= one; break; + case vcc_or: ok |= one; break; + case last_vcc: throw InternalError(PALUDIS_HERE, "Bad vcc"); + } } + if (! ok) + return false; + } + if (spec.in_repository_constraint()) if (spec.in_repository_constraint()->name() != id->repository_name()) return false; diff --git a/paludis/package_dep_spec_constraint-fwd.hh b/paludis/package_dep_spec_constraint-fwd.hh index 6eb748dbf..5dabea47a 100644 --- a/paludis/package_dep_spec_constraint-fwd.hh +++ b/paludis/package_dep_spec_constraint-fwd.hh @@ -39,6 +39,10 @@ namespace paludis class CategoryNamePartConstraint; typedef Pool<CategoryNamePartConstraint> CategoryNamePartConstraintPool; + class VersionConstraint; + + typedef Sequence<std::shared_ptr<const VersionConstraint> > VersionConstraintSequence; + class InRepositoryConstraint; typedef Pool<InRepositoryConstraint> InRepositoryConstraintPool; diff --git a/paludis/package_dep_spec_constraint.cc b/paludis/package_dep_spec_constraint.cc index 85d39795e..0c5482339 100644 --- a/paludis/package_dep_spec_constraint.cc +++ b/paludis/package_dep_spec_constraint.cc @@ -18,6 +18,9 @@ */ #include <paludis/package_dep_spec_constraint.hh> +#include <paludis/version_spec.hh> +#include <paludis/version_operator.hh> + #include <paludis/util/pool-impl.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/singleton-impl.hh> @@ -25,6 +28,7 @@ #include <paludis/util/exception.hh> #include <paludis/util/sequence-impl.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> +#include <paludis/util/pimp-impl.hh> #include <istream> #include <ostream> @@ -89,6 +93,53 @@ template class Singleton<Pool<PackageNamePartConstraint> >; template const std::shared_ptr<const PackageNamePartConstraint> Pool<PackageNamePartConstraint>::create( const PackageNamePart &) const; +namespace paludis +{ + template <> + struct Imp<VersionConstraint> + { + VersionSpec spec; + VersionOperator op; + VersionConstraintCombiner combiner; + + Imp(const VersionSpec & s, const VersionOperator & o, const VersionConstraintCombiner c) : + spec(s), + op(o), + combiner(c) + { + } + }; +} + +VersionConstraint::VersionConstraint(const VersionSpec & s, const VersionOperator & o, const VersionConstraintCombiner c) : + _imp(s, o, c) +{ +} + +VersionConstraint::~VersionConstraint() = default; + +const VersionSpec +VersionConstraint::version_spec() const +{ + return _imp->spec; +} + +const VersionOperator +VersionConstraint::version_operator() const +{ + return _imp->op; +} + +VersionConstraintCombiner +VersionConstraint::combiner() const +{ + return _imp->combiner; +} + +template class Sequence<std::shared_ptr<const VersionConstraint> >; +template class WrappedForwardIterator<Sequence<std::shared_ptr<const VersionConstraint> >::ConstIteratorTag, const std::shared_ptr<const VersionConstraint> >; +template class Pimp<VersionConstraint>; + InRepositoryConstraint::InRepositoryConstraint(const RepositoryName & n) : _name(n) { diff --git a/paludis/package_dep_spec_constraint.hh b/paludis/package_dep_spec_constraint.hh index 1736b40ed..87643bbda 100644 --- a/paludis/package_dep_spec_constraint.hh +++ b/paludis/package_dep_spec_constraint.hh @@ -22,12 +22,15 @@ #include <paludis/package_dep_spec_constraint-fwd.hh> #include <paludis/name.hh> +#include <paludis/version_operator-fwd.hh> +#include <paludis/version_spec-fwd.hh> #include <paludis/util/attributes.hh> #include <paludis/util/pool.hh> #include <paludis/util/visitor.hh> #include <paludis/util/type_list.hh> #include <paludis/util/fs_path.hh> +#include <paludis/util/pimp.hh> namespace paludis { @@ -36,6 +39,7 @@ namespace paludis NameConstraint, PackageNamePartConstraint, CategoryNamePartConstraint, + VersionConstraint, InRepositoryConstraint, FromRepositoryConstraint, InstalledAtPathConstraint, @@ -107,6 +111,26 @@ namespace paludis const PackageNamePart name_part() const PALUDIS_ATTRIBUTE((warn_unused_result)); }; + class PALUDIS_VISIBLE VersionConstraint : + public PackageDepSpecConstraint, + public ImplementAcceptMethods<PackageDepSpecConstraint, VersionConstraint> + { + private: + Pimp<VersionConstraint> _imp; + + VersionConstraint(const VersionConstraint &) = delete; + + public: + /* not pooled for now, since VersionSpec gives equality for 1 and 1-r0 */ + VersionConstraint(const VersionSpec &, const VersionOperator &, const VersionConstraintCombiner); + + ~VersionConstraint(); + + const VersionSpec version_spec() const PALUDIS_ATTRIBUTE((warn_unused_result)); + const VersionOperator version_operator() const PALUDIS_ATTRIBUTE((warn_unused_result)); + VersionConstraintCombiner combiner() const PALUDIS_ATTRIBUTE((warn_unused_result)); + }; + class PALUDIS_VISIBLE InRepositoryConstraint : public PackageDepSpecConstraint, public ImplementAcceptMethods<PackageDepSpecConstraint, InRepositoryConstraint> @@ -272,6 +296,7 @@ namespace paludis extern template class Pool<NameConstraint>; extern template class Pool<PackageNamePartConstraint>; extern template class Pool<CategoryNamePartConstraint>; + extern template class Pool<VersionConstraint>; extern template class Pool<InRepositoryConstraint>; extern template class Pool<FromRepositoryConstraint>; extern template class Pool<InstalledAtPathConstraint>; @@ -280,6 +305,8 @@ namespace paludis extern template class Pool<ExactSlotConstraint>; extern template class Pool<AnySlotConstraint>; extern template class Pool<KeyConstraint>; + + extern template class Pimp<VersionConstraint>; } #endif diff --git a/paludis/package_dep_spec_constraint.se b/paludis/package_dep_spec_constraint.se index 75e6e2c7c..8a9369691 100644 --- a/paludis/package_dep_spec_constraint.se +++ b/paludis/package_dep_spec_constraint.se @@ -11,3 +11,11 @@ make_enum_KeyConstraintOperation() key kco_question "A question constraint" } +make_enum_VersionConstraintCombiner() +{ + prefix vcc + + key vcc_and "And with previous value" + key vcc_or "Or with previons value" +} + diff --git a/paludis/package_dep_spec_properties.cc b/paludis/package_dep_spec_properties.cc index f4f4af1ad..0c003631e 100644 --- a/paludis/package_dep_spec_properties.cc +++ b/paludis/package_dep_spec_properties.cc @@ -53,7 +53,7 @@ paludis::package_dep_spec_has_properties(const PackageDepSpec & spec, const Pack result = result && check(bool(spec.package_name_part_constraint()), properties.has_package_name_part()); result = result && check(bool(spec.exact_slot_constraint()), properties.has_exact_slot_requirement()); result = result && check(bool(spec.any_slot_constraint()), properties.has_any_slot_requirement()); - result = result && check(spec.version_requirements_ptr() && ! spec.version_requirements_ptr()->empty(), properties.has_version_requirements()); + result = result && check(bool(spec.all_version_constraints()) && ! spec.all_version_constraints()->empty(), properties.has_version_requirements()); return result; } diff --git a/paludis/partially_made_package_dep_spec.cc b/paludis/partially_made_package_dep_spec.cc index 37d8c0f5c..9d67d9cc0 100644 --- a/paludis/partially_made_package_dep_spec.cc +++ b/paludis/partially_made_package_dep_spec.cc @@ -18,6 +18,12 @@ */ #include <paludis/partially_made_package_dep_spec.hh> +#include <paludis/additional_package_dep_spec_requirement.hh> +#include <paludis/dep_spec_data.hh> +#include <paludis/package_dep_spec_constraint.hh> +#include <paludis/version_operator.hh> +#include <paludis/version_spec.hh> + #include <paludis/util/stringify.hh> #include <paludis/util/exception.hh> #include <paludis/util/options.hh> @@ -25,10 +31,7 @@ #include <paludis/util/iterator_funcs.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/sequence-impl.hh> -#include <paludis/version_requirements.hh> -#include <paludis/additional_package_dep_spec_requirement.hh> -#include <paludis/dep_spec_data.hh> -#include <paludis/package_dep_spec_constraint.hh> + #include <iterator> #include <algorithm> #include <ostream> @@ -51,8 +54,7 @@ namespace std::shared_ptr<const NameConstraint> package; std::shared_ptr<const PackageNamePartConstraint> package_name_part; std::shared_ptr<const CategoryNamePartConstraint> category_name_part; - std::shared_ptr<VersionRequirements> version_requirements; - VersionRequirementsMode version_requirements_mode_v; + std::shared_ptr<VersionConstraintSequence> all_versions; std::shared_ptr<const AnySlotConstraint> any_slot; std::shared_ptr<const ExactSlotConstraint> exact_slot; std::shared_ptr<const InRepositoryConstraint> in_repository; @@ -66,7 +68,6 @@ namespace PartiallyMadePackageDepSpecData(const PartiallyMadePackageDepSpecOptions & o) : PackageDepSpecData(), - version_requirements_mode_v(vr_and), options_for_partially_made_package_dep_spec_v(o) { } @@ -76,8 +77,7 @@ namespace package(other.package_name_constraint()), package_name_part(other.package_name_part_constraint()), category_name_part(other.category_name_part_constraint()), - version_requirements(other.version_requirements_ptr() ? new VersionRequirements : 0), - version_requirements_mode_v(other.version_requirements_mode()), + all_versions(other.all_version_constraints() ? new VersionConstraintSequence : 0), any_slot(other.any_slot_constraint()), exact_slot(other.exact_slot_constraint()), in_repository(other.in_repository_constraint()), @@ -89,9 +89,9 @@ namespace additional_requirements(other.additional_requirements_ptr() ? new AdditionalPackageDepSpecRequirements : 0), options_for_partially_made_package_dep_spec_v(other.options_for_partially_made_package_dep_spec()) { - if (version_requirements) - std::copy(other.version_requirements_ptr()->begin(), other.version_requirements_ptr()->end(), - version_requirements->back_inserter()); + if (all_versions) + std::copy(other.all_version_constraints()->begin(), other.all_version_constraints()->end(), + all_versions->back_inserter()); if (all_keys) std::copy(other.all_key_constraints()->begin(), other.all_key_constraints()->end(), @@ -107,8 +107,7 @@ namespace package(other.package), package_name_part(other.package_name_part), category_name_part(other.category_name_part), - version_requirements(other.version_requirements), - version_requirements_mode_v(other.version_requirements_mode_v), + all_versions(other.all_versions), any_slot(other.any_slot), exact_slot(other.exact_slot), in_repository(other.in_repository), @@ -126,18 +125,19 @@ namespace { std::ostringstream s; - if (version_requirements_ptr()) + if (all_version_constraints()) { - if (version_requirements_ptr()->begin() == version_requirements_ptr()->end()) + if (all_version_constraints()->begin() == all_version_constraints()->end()) { } - else if (next(version_requirements_ptr()->begin()) == version_requirements_ptr()->end() && + else if (next(all_version_constraints()->begin()) == all_version_constraints()->end() && ! options_for_partially_made_package_dep_spec_v[pmpdso_always_use_ranged_deps]) { - if (version_requirements_ptr()->begin()->version_operator() == vo_stupid_equal_star || version_requirements_ptr()->begin()->version_operator() == vo_nice_equal_star) + if ((*all_version_constraints()->begin())->version_operator() == vo_stupid_equal_star || + (*all_version_constraints()->begin())->version_operator() == vo_nice_equal_star) s << "="; else - s << version_requirements_ptr()->begin()->version_operator(); + s << (*all_version_constraints()->begin())->version_operator(); } } @@ -158,16 +158,17 @@ namespace s << "*"; } - if (version_requirements_ptr()) + if (all_version_constraints()) { - if (version_requirements_ptr()->begin() == version_requirements_ptr()->end()) + if (all_version_constraints()->begin() == all_version_constraints()->end()) { } - else if (next(version_requirements_ptr()->begin()) == version_requirements_ptr()->end() && + else if (next(all_version_constraints()->begin()) == all_version_constraints()->end() && ! options_for_partially_made_package_dep_spec_v[pmpdso_always_use_ranged_deps]) { - s << "-" << version_requirements_ptr()->begin()->version_spec(); - if (version_requirements_ptr()->begin()->version_operator() == vo_stupid_equal_star || version_requirements_ptr()->begin()->version_operator() == vo_nice_equal_star) + s << "-" << (*all_version_constraints()->begin())->version_spec(); + if ((*all_version_constraints()->begin())->version_operator() == vo_stupid_equal_star || + (*all_version_constraints()->begin())->version_operator() == vo_nice_equal_star) s << "*"; } } @@ -242,12 +243,12 @@ namespace else if (! left.empty()) s << "::" << left << "->"; - if (version_requirements_ptr()) + if (all_version_constraints()) { - if (version_requirements_ptr()->begin() == version_requirements_ptr()->end()) + if (all_version_constraints()->begin() == all_version_constraints()->end()) { } - else if (next(version_requirements_ptr()->begin()) == version_requirements_ptr()->end() && + else if (next(all_version_constraints()->begin()) == all_version_constraints()->end() && ! options_for_partially_made_package_dep_spec_v[pmpdso_always_use_ranged_deps]) { } @@ -255,38 +256,37 @@ namespace { bool need_op(false); s << "["; - for (VersionRequirements::ConstIterator r(version_requirements_ptr()->begin()), - r_end(version_requirements_ptr()->end()) ; r != r_end ; ++r) + for (auto r(all_version_constraints()->begin()), r_end(all_version_constraints()->end()) ; r != r_end ; ++r) { if (need_op) { do { - switch (version_requirements_mode()) + switch ((*r)->combiner()) { - case vr_and: + case vcc_and: s << "&"; continue; - case vr_or: + case vcc_or: s << "|"; continue; - case last_vr: + case last_vcc: ; } throw InternalError(PALUDIS_HERE, "Bad version_requirements_mode"); } while (false); } - if (r->version_operator() == vo_stupid_equal_star || r->version_operator() == vo_nice_equal_star) + if ((*r)->version_operator() == vo_stupid_equal_star || (*r)->version_operator() == vo_nice_equal_star) s << "="; else - s << r->version_operator(); + s << (*r)->version_operator(); - s << r->version_spec(); + s << (*r)->version_spec(); - if (r->version_operator() == vo_stupid_equal_star || r->version_operator() == vo_nice_equal_star) + if ((*r)->version_operator() == vo_stupid_equal_star || (*r)->version_operator() == vo_nice_equal_star) s << "*"; need_op = true; @@ -337,14 +337,9 @@ namespace return category_name_part; } - virtual std::shared_ptr<const VersionRequirements> version_requirements_ptr() const - { - return version_requirements; - } - - virtual VersionRequirementsMode version_requirements_mode() const + virtual const std::shared_ptr<const VersionConstraintSequence> all_version_constraints() const { - return version_requirements_mode_v; + return all_versions; } virtual const std::shared_ptr<const ExactSlotConstraint> exact_slot_constraint() const @@ -583,25 +578,22 @@ PartiallyMadePackageDepSpec::clear_category_name_part() } PartiallyMadePackageDepSpec & -PartiallyMadePackageDepSpec::version_requirement(const VersionRequirement & req) +PartiallyMadePackageDepSpec::version_constraint(const VersionSpec & vs, const VersionOperator & vo, const VersionConstraintCombiner vc) { - if (! _imp->data->version_requirements) - _imp->data->version_requirements = std::make_shared<VersionRequirements>(); - _imp->data->version_requirements->push_back(req); - return *this; -} + if (! _imp->data->all_versions) + _imp->data->all_versions = std::make_shared<VersionConstraintSequence>(); -PartiallyMadePackageDepSpec & -PartiallyMadePackageDepSpec::clear_version_requirements() -{ - _imp->data->version_requirements.reset(); + if (_imp->data->all_versions->empty() && vc != vcc_and) + throw InternalError(PALUDIS_HERE, "First vc must be vcc_and"); + + _imp->data->all_versions->push_back(std::make_shared<VersionConstraint>(vs, vo, vc)); return *this; } PartiallyMadePackageDepSpec & -PartiallyMadePackageDepSpec::version_requirements_mode(const VersionRequirementsMode & mode) +PartiallyMadePackageDepSpec::clear_version_requirements() { - _imp->data->version_requirements_mode_v = mode; + _imp->data->all_versions.reset(); return *this; } diff --git a/paludis/partially_made_package_dep_spec.hh b/paludis/partially_made_package_dep_spec.hh index 14d2c5a5c..686dc9405 100644 --- a/paludis/partially_made_package_dep_spec.hh +++ b/paludis/partially_made_package_dep_spec.hh @@ -183,9 +183,12 @@ namespace paludis PartiallyMadePackageDepSpec & clear_category_name_part(); /** - * Add a version requirement, return ourself. + * Add a version constraint, return ourself. + * + * \since 0.61 */ - PartiallyMadePackageDepSpec & version_requirement(const VersionRequirement &); + PartiallyMadePackageDepSpec & version_constraint( + const VersionSpec &, const VersionOperator &, const VersionConstraintCombiner); /** * Clear all version requirement, return ourself. @@ -195,11 +198,6 @@ namespace paludis PartiallyMadePackageDepSpec & clear_version_requirements(); /** - * Set our version requirements mode, return ourself. - */ - PartiallyMadePackageDepSpec & version_requirements_mode(const VersionRequirementsMode &); - - /** * Add an additional requirement, return ourself. */ PartiallyMadePackageDepSpec & additional_requirement( diff --git a/paludis/repositories/e/e_repository_sets.cc b/paludis/repositories/e/e_repository_sets.cc index d9f15fe01..2f5736042 100644 --- a/paludis/repositories/e/e_repository_sets.cc +++ b/paludis/repositories/e/e_repository_sets.cc @@ -37,7 +37,6 @@ #include <paludis/set_file.hh> #include <paludis/user_dep_spec.hh> #include <paludis/version_operator.hh> -#include <paludis/version_requirements.hh> #include <paludis/util/config_file.hh> #include <paludis/util/is_file_with_extension.hh> @@ -296,9 +295,7 @@ ERepositorySets::security_set(bool insecurity) const std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>( make_package_dep_spec({ }) .package((*c)->name()) - .version_requirement(make_named_values<VersionRequirement>( - n::version_operator() = vo_equal, - n::version_spec() = (*c)->version())) + .version_constraint((*c)->version(), vo_equal, vcc_and) .in_repository((*c)->repository_name()))); security_packages->top()->append(spec); } @@ -328,9 +325,7 @@ ERepositorySets::security_set(bool insecurity) const std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(make_package_dep_spec({ }) .package((*r)->name()) - .version_requirement(make_named_values<VersionRequirement>( - n::version_operator() = vo_equal, - n::version_spec() = (*r)->version())) + .version_constraint((*r)->version(), vo_equal, vcc_and) .in_repository((*r)->repository_name()))); security_packages->top()->append(spec); ok = true; diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc index 1a70d48db..a6b9a91ba 100644 --- a/paludis/repositories/e/vdb_repository.cc +++ b/paludis/repositories/e/vdb_repository.cc @@ -45,7 +45,6 @@ #include <paludis/repository_name_cache.hh> #include <paludis/set_file.hh> #include <paludis/version_operator.hh> -#include <paludis/version_requirements.hh> #include <paludis/selection.hh> #include <paludis/generator.hh> #include <paludis/filtered_generator.hh> @@ -1111,7 +1110,11 @@ VDBRepository::need_package_ids(const CategoryNamePart & c) const IDMap::iterator i(_imp->ids.find(p.package_name_constraint()->name())); if (_imp->ids.end() == i) i = _imp->ids.insert(std::make_pair(p.package_name_constraint()->name(), std::make_shared<PackageIDSequence>())).first; - i->second->push_back(make_id(p.package_name_constraint()->name(), p.version_requirements_ptr()->begin()->version_spec(), *d)); + + if ((! bool(p.all_version_constraints())) || (std::distance(p.all_version_constraints()->begin(), p.all_version_constraints()->end()) != 1)) + throw InternalError(PALUDIS_HERE, "didn't get a single version constraint"); + + i->second->push_back(make_id(p.package_name_constraint()->name(), (*p.all_version_constraints()->begin())->version_spec(), *d)); } catch (const InternalError &) { diff --git a/paludis/repositories/gemcutter/gemcutter_dependencies_key.cc b/paludis/repositories/gemcutter/gemcutter_dependencies_key.cc index 8cfb1210d..c5a77f873 100644 --- a/paludis/repositories/gemcutter/gemcutter_dependencies_key.cc +++ b/paludis/repositories/gemcutter/gemcutter_dependencies_key.cc @@ -36,7 +36,6 @@ #include <paludis/generator.hh> #include <paludis/filtered_generator.hh> #include <paludis/filter.hh> -#include <paludis/version_requirements.hh> #include <paludis/version_operator.hh> #include <paludis/version_spec.hh> #include <paludis/pretty_printer.hh> @@ -175,10 +174,7 @@ namespace return make_shared_copy(PackageDepSpec(make_package_dep_spec({ pmpdso_always_use_ranged_deps }) .package(QualifiedPackageName("gem/" + dep.name())) - .version_requirement(make_named_values<VersionRequirement>( - n::version_operator() = op, - n::version_spec() = ver - )) + .version_constraint(ver, op, vcc_and) )); } diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc index f4f48a42f..253466eb6 100644 --- a/paludis/repositories/virtuals/package_id.cc +++ b/paludis/repositories/virtuals/package_id.cc @@ -31,8 +31,8 @@ #include <paludis/name.hh> #include <paludis/dep_spec.hh> #include <paludis/version_spec.hh> +#include <paludis/version_operator.hh> #include <paludis/environment.hh> -#include <paludis/version_requirements.hh> #include <paludis/metadata_key.hh> #include <paludis/action.hh> #include <paludis/mask.hh> @@ -72,9 +72,7 @@ namespace paludis std::make_shared<PackageDepSpec>( make_package_dep_spec(PartiallyMadePackageDepSpecOptions()) .package(v->name()) - .version_requirement(make_named_values<VersionRequirement>( - n::version_operator() = vo_equal, - n::version_spec() = v->version())) + .version_constraint(v->version(), vo_equal, vcc_and) .exact_slot_constraint(v->slot_key() ? v->slot_key()->value() : SlotName("UNKNOWN"), false) .in_repository(v->repository_name())) : diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc index 3af2dc5cd..1960a97d6 100644 --- a/paludis/resolver/decider.cc +++ b/paludis/resolver/decider.cc @@ -64,7 +64,6 @@ #include <paludis/selection.hh> #include <paludis/filter.hh> #include <paludis/match_package.hh> -#include <paludis/version_requirements.hh> #include <paludis/choice.hh> #include <paludis/action.hh> #include <paludis/package_id.hh> @@ -73,6 +72,7 @@ #include <paludis/partially_made_package_dep_spec.hh> #include <paludis/dep_spec_annotations.hh> #include <paludis/package_dep_spec_constraint.hh> +#include <paludis/version_operator.hh> #include <paludis/util/pimp-impl.hh> @@ -1271,16 +1271,15 @@ Decider::find_any_score( // AnyDepSpecChildHandler::commit in satitised_dependencies.cc // matches this logic OperatorScore operator_bias(os_worse_than_worst); - if (spec.version_requirements_ptr() && ! spec.version_requirements_ptr()->empty()) + if (spec.all_version_constraints() && ! spec.all_version_constraints()->empty()) { OperatorScore score(os_worse_than_worst); - for (VersionRequirements::ConstIterator v(spec.version_requirements_ptr()->begin()), - v_end(spec.version_requirements_ptr()->end()) ; + for (auto v(spec.all_version_constraints()->begin()), v_end(spec.all_version_constraints()->end()) ; v != v_end ; ++v) { OperatorScore local_score(os_worse_than_worst); - switch (v->version_operator().value()) + switch ((*v)->version_operator().value()) { case vo_greater: case vo_greater_equal: @@ -1308,17 +1307,17 @@ Decider::find_any_score( if (score == os_worse_than_worst) score = local_score; else - switch (spec.version_requirements_mode()) + switch ((*v)->combiner()) { - case vr_and: + case vcc_and: score = is_block ? std::max(score, local_score) : std::min(score, local_score); break; - case vr_or: + case vcc_or: score = is_block ? std::min(score, local_score) : std::max(score, local_score); break; - case last_vr: + case last_vcc: break; } } diff --git a/paludis/user_dep_spec.cc b/paludis/user_dep_spec.cc index 59310c430..ce9b015d2 100644 --- a/paludis/user_dep_spec.cc +++ b/paludis/user_dep_spec.cc @@ -23,7 +23,6 @@ #include <paludis/elike_use_requirement.hh> #include <paludis/version_operator.hh> #include <paludis/version_spec.hh> -#include <paludis/version_requirements.hh> #include <paludis/filter.hh> #include <paludis/package_id.hh> #include <paludis/metadata_key.hh> @@ -155,67 +154,7 @@ namespace case '>': case '=': case '~': - { - char needed_mode(0); - - while (! flag.empty()) - { - Context cc("When parsing [] segment '" + flag + "':"); - - std::string op; - std::string::size_type opos(0); - while (opos < flag.length()) - if (std::string::npos == std::string("><=~").find(flag.at(opos))) - break; - else - ++opos; - - op = flag.substr(0, opos); - flag.erase(0, opos); - - if (op.empty()) - throw PackageDepSpecError("Missing operator inside []"); - - VersionOperator vop(op); - - std::string ver; - opos = flag.find_first_of("|&"); - if (std::string::npos == opos) - { - ver = flag; - flag.clear(); - } - else - { - if (0 == needed_mode) - needed_mode = flag.at(opos); - else if (needed_mode != flag.at(opos)) - throw PackageDepSpecError("Mixed & and | inside []"); - - result.version_requirements_mode((flag.at(opos) == '|' ? vr_or : vr_and)); - ver = flag.substr(0, opos++); - flag.erase(0, opos); - } - - if (ver.empty()) - throw PackageDepSpecError("Missing version after operator '" + stringify(vop) + " inside []"); - - if ('*' == ver.at(ver.length() - 1)) - { - ver.erase(ver.length() - 1); - if (vop == vo_equal) - vop = vo_nice_equal_star; - else - throw PackageDepSpecError("Invalid use of * with operator '" + stringify(vop) + " inside []"); - } - - VersionSpec vs(ver, user_version_spec_options()); - result.version_requirement(make_named_values<VersionRequirement>( - n::version_operator() = vop, - n::version_spec() = vs)); - had_bracket_version_requirements = true; - } - } + parse_elike_version_range(flag, result, { epdso_nice_equal_star }, user_version_spec_options(), had_bracket_version_requirements); break; case '.': @@ -331,7 +270,7 @@ paludis::parse_user_package_dep_spec(const std::string & ss, const Environment * return partial_parse_generic_elike_package_dep_spec(ss, make_named_values<GenericELikePackageDepSpecParseFunctions>( n::add_package_requirement() = std::bind(&user_add_package_requirement, _1, _2, env, options, filter), - n::add_version_requirement() = std::bind(&elike_add_version_requirement, _1, _2, _3), + n::add_version_requirement() = std::bind(&elike_add_version_requirement, _1, _2, _3, _4), n::check_sanity() = std::bind(&user_check_sanity, _1, options, env), n::get_remove_trailing_version() = std::bind(&elike_get_remove_trailing_version, _1, user_version_spec_options()), @@ -359,7 +298,7 @@ paludis::envless_parse_package_dep_spec_for_tests(const std::string & ss) return partial_parse_generic_elike_package_dep_spec(ss, make_named_values<GenericELikePackageDepSpecParseFunctions>( n::add_package_requirement() = std::bind(&envless_add_package_requirement, _1, _2), - n::add_version_requirement() = std::bind(&elike_add_version_requirement, _1, _2, _3), + n::add_version_requirement() = std::bind(&elike_add_version_requirement, _1, _2, _3, _4), n::check_sanity() = std::bind(&test_check_sanity, _1), n::get_remove_trailing_version() = std::bind(&elike_get_remove_trailing_version, _1, user_version_spec_options()), diff --git a/paludis/user_dep_spec_TEST.cc b/paludis/user_dep_spec_TEST.cc index 2da7b4984..c76eed842 100644 --- a/paludis/user_dep_spec_TEST.cc +++ b/paludis/user_dep_spec_TEST.cc @@ -20,8 +20,8 @@ #include <paludis/dep_spec.hh> #include <paludis/user_dep_spec.hh> #include <paludis/match_package.hh> -#include <paludis/version_requirements.hh> #include <paludis/package_dep_spec_constraint.hh> +#include <paludis/version_operator.hh> #include <paludis/util/clone-impl.hh> #include <paludis/util/sequence.hh> @@ -46,7 +46,7 @@ using namespace paludis; namespace { - std::string dump_version_requirement(const VersionRequirement & v) + std::string dump_version_requirement(const VersionConstraint & v) { return stringify(v.version_operator()) + stringify(v.version_spec()); } @@ -133,15 +133,22 @@ UserDepSpecTest::check_spec( } if (! version_requirement_mode.empty()) - EXPECT_EQ(version_requirement_mode, stringify(spec.version_requirements_mode())); + { + ASSERT_TRUE(bool(spec.all_version_constraints())); + ASSERT_TRUE(! spec.all_version_constraints()->empty()); + for (auto v(next(spec.all_version_constraints()->begin())), v_end(spec.all_version_constraints()->end()) ; + v != v_end ; ++v) + EXPECT_EQ(version_requirement_mode, stringify((*v)->combiner())); + } if (version_requirements.empty()) - EXPECT_TRUE((! spec.version_requirements_ptr()) || spec.version_requirements_ptr()->empty()); + EXPECT_TRUE((! spec.all_version_constraints()) || spec.all_version_constraints()->empty()); else { - ASSERT_TRUE(bool(spec.version_requirements_ptr())); + ASSERT_TRUE(bool(spec.all_version_constraints())); EXPECT_EQ(version_requirements, stringify(join( - spec.version_requirements_ptr()->begin(), spec.version_requirements_ptr()->end(), ", ", &dump_version_requirement))); + indirect_iterator(spec.all_version_constraints()->begin()), + indirect_iterator(spec.all_version_constraints()->end()), ", ", &dump_version_requirement))); } if (slot_requirement.empty()) @@ -270,6 +277,9 @@ TEST_F(UserDepSpecTest, Parsing) PackageDepSpec r(parse_user_package_dep_spec("foo/bar[.$short_description=value]", &env, { })); check_spec(r, "foo/bar", "", "", "", "", "", "", "", "[.$short_description=value]"); + + PackageDepSpec s(parse_user_package_dep_spec("=foo/bar-1-r0", &env, { })); + check_spec(s, "foo/bar", "", "", "=1-r0", "", "", "", "", ""); } TEST_F(UserDepSpecTest, Unspecified) diff --git a/paludis/version_operator.hh b/paludis/version_operator.hh index a548c6061..cf053906a 100644 --- a/paludis/version_operator.hh +++ b/paludis/version_operator.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2010 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2010, 2011 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -119,6 +119,11 @@ namespace paludis return _v == other._v; } + std::size_t hash() const + { + return static_cast<std::size_t>(_v); + } + ///\} }; diff --git a/paludis/version_requirements-fwd.hh b/paludis/version_requirements-fwd.hh deleted file mode 100644 index 2528b85d4..000000000 --- a/paludis/version_requirements-fwd.hh +++ /dev/null @@ -1,71 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh - * - * This file is part of the Paludis package manager. Paludis is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PALUDIS_GUARD_PALUDIS_VERSION_REQUIREMENTS_FWD_HH -#define PALUDIS_GUARD_PALUDIS_VERSION_REQUIREMENTS_FWD_HH 1 - -#include <paludis/util/sequence-fwd.hh> -#include <paludis/util/attributes.hh> -#include <paludis/version_spec-fwd.hh> -#include <memory> -#include <iosfwd> - -/** \file - * Forward declarations for paludis/version_requirements.hh . - * - * \ingroup g_dep_spec - */ - -namespace paludis -{ - class VersionRequirement; - - /** - * A collection of VersionRequirement instances, usually for a - * PackageDepSpec. - * - * \see PackageDepSpec - * \ingroup g_dep_spec - */ - typedef Sequence<VersionRequirement> VersionRequirements; - - /** - * Whether our version requirements are an 'and' or an 'or' set. - * - * \see PackageDepSpec - * \ingroup g_dep_spec - */ - enum VersionRequirementsMode - { - vr_or, ///\< Must match one - vr_and, ///\< Must match all - last_vr - }; - - /** - * Write a VersionRequirementsMode to a stream. - * - * \ingroup g_dep_spec - */ - std::ostream & - operator<< (std::ostream &, const VersionRequirementsMode &) PALUDIS_VISIBLE; - -} - -#endif diff --git a/paludis/version_requirements.cc b/paludis/version_requirements.cc deleted file mode 100644 index ece662c7a..000000000 --- a/paludis/version_requirements.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh - * - * This file is part of the Paludis package manager. Paludis is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <paludis/version_requirements.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/sequence.hh> -#include <paludis/util/sequence-impl.hh> -#include <paludis/util/wrapped_forward_iterator-impl.hh> -#include <paludis/util/wrapped_output_iterator-impl.hh> -#include <paludis/util/make_named_values.hh> - -using namespace paludis; - -template class Sequence<VersionRequirement>; -template class WrappedForwardIterator<Sequence<VersionRequirement>::ConstIteratorTag, const VersionRequirement>; -template class WrappedOutputIterator<Sequence<VersionRequirement>::InserterTag, VersionRequirement>; - -std::ostream & -paludis::operator<< (std::ostream & o, const VersionRequirementsMode & s) -{ - do - { - switch (s) - { - case vr_and: - o << "and"; - continue; - - case vr_or: - o << "or"; - continue; - - case last_vr: - ; - } - - throw InternalError(PALUDIS_HERE, "Bad VersionRequirementsMode"); - } while (false); - - return o; -} - diff --git a/paludis/version_requirements.hh b/paludis/version_requirements.hh deleted file mode 100644 index 380adc0a5..000000000 --- a/paludis/version_requirements.hh +++ /dev/null @@ -1,64 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007, 2008, 2010 Ciaran McCreesh - * - * This file is part of the Paludis package manager. Paludis is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PALUDIS_GUARD_PALUDIS_VERSION_REQUIREMENTS_HH -#define PALUDIS_GUARD_PALUDIS_VERSION_REQUIREMENTS_HH 1 - -#include <paludis/version_requirements-fwd.hh> -#include <paludis/version_operator.hh> -#include <paludis/version_spec.hh> -#include <paludis/util/named_value.hh> - -/** \file - * Declarations for version requirements classes. - * - * \ingroup g_dep_spec - * - * \section Examples - * - * - \ref example_dep_spec.cc "example_dep_spec.cc" (for specifications) - */ - -namespace paludis -{ - namespace n - { - typedef Name<struct name_version_operator> version_operator; - typedef Name<struct name_version_spec> version_spec; - } - - /** - * A requirement for a version, consisting of a VersionOperator and an associated - * VersionSpec. - * - * \ingroup g_dep_spec - * \see PackageDepSpec - * \see VersionSpec - * \see VersionOperator - * \see VersionRequirements - * \nosubgrouping - */ - struct VersionRequirement - { - NamedValue<n::version_operator, VersionOperator> version_operator; - NamedValue<n::version_spec, VersionSpec> version_spec; - }; -} - -#endif diff --git a/python/Makefile.am b/python/Makefile.am index e58412490..e0cf4f0e1 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -42,7 +42,6 @@ IF_PYTHON_TESTS = \ repository_TEST.py \ selection_TEST.py \ version_operator_TEST.py \ - version_requirements_TEST.py \ version_spec_TEST.py IF_PYTHON_SOURCES = \ @@ -74,7 +73,6 @@ IF_PYTHON_SOURCES = \ repository.cc \ selection.cc \ version_operator.cc \ - version_requirements.cc \ version_spec.cc BUILT_SOURCES = \ diff --git a/python/dep_spec.cc b/python/dep_spec.cc index beb8fa09a..939fbeceb 100644 --- a/python/dep_spec.cc +++ b/python/dep_spec.cc @@ -26,10 +26,11 @@ #include <paludis/dep_spec.hh> #include <paludis/environment.hh> #include <paludis/user_dep_spec.hh> -#include <paludis/version_requirements.hh> #include <paludis/partially_made_package_dep_spec.hh> #include <paludis/dep_spec_data.hh> #include <paludis/package_dep_spec_constraint.hh> +#include <paludis/version_spec.hh> +#include <paludis/version_operator.hh> #include <paludis/util/save.hh> #include <paludis/util/stringify.hh> @@ -76,8 +77,7 @@ namespace paludis std::shared_ptr<const NameConstraint> package_name_constraint; std::shared_ptr<const CategoryNamePartConstraint> category_name_part_constraint; std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint; - std::shared_ptr<VersionRequirements> version_requirements; - VersionRequirementsMode version_requirements_mode; + std::shared_ptr<const VersionConstraintSequence> all_versions; std::shared_ptr<const AnySlotConstraint> any_slot; std::shared_ptr<const ExactSlotConstraint> exact_slot; std::shared_ptr<const InRepositoryConstraint> in_repository; @@ -90,8 +90,7 @@ namespace paludis const std::shared_ptr<const NameConstraint> & q, const std::shared_ptr<const CategoryNamePartConstraint> & c, const std::shared_ptr<const PackageNamePartConstraint> & p, - const std::shared_ptr<VersionRequirements> & v, - const VersionRequirementsMode m, + const std::shared_ptr<const VersionConstraintSequence> & v, const std::shared_ptr<const AnySlotConstraint> & s, const std::shared_ptr<const ExactSlotConstraint> & xs, const std::shared_ptr<const InRepositoryConstraint> & ri, @@ -102,8 +101,7 @@ namespace paludis package_name_constraint(q), category_name_part_constraint(c), package_name_part_constraint(p), - version_requirements(v), - version_requirements_mode(m), + all_versions(v), any_slot(s), exact_slot(xs), in_repository(ri), @@ -232,8 +230,7 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) : p.package_name_constraint(), p.category_name_part_constraint(), p.package_name_part_constraint(), - std::make_shared<VersionRequirements>(), - p.version_requirements_mode(), + p.all_version_constraints(), p.any_slot_constraint(), p.exact_slot_constraint(), p.in_repository_constraint(), @@ -242,11 +239,6 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) : p.all_key_constraints(), stringify(p)) { - if (p.version_requirements_ptr()) - { - std::copy(p.version_requirements_ptr()->begin(), p.version_requirements_ptr()->end(), - _imp->version_requirements->back_inserter()); - } } PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) : @@ -255,8 +247,7 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) : p.package_name_constraint(), p.category_name_part_constraint(), p.package_name_part_constraint(), - std::make_shared<VersionRequirements>(), - p.version_requirements_mode(), + p.all_version_constraints(), p.any_slot_constraint(), p.exact_slot_constraint(), p.in_repository_constraint(), @@ -265,8 +256,6 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) : p.all_key_constraints(), p.py_str()) { - std::copy(p.version_requirements_ptr()->begin(), p.version_requirements_ptr()->end(), - _imp->version_requirements->back_inserter()); } PythonPackageDepSpec::~PythonPackageDepSpec() @@ -286,7 +275,12 @@ PythonPackageDepSpec::operator PackageDepSpec() const if (package_name_part_constraint()) p.package_name_part(package_name_part_constraint()->name_part()); - p.version_requirements_mode(version_requirements_mode()); + if (all_version_constraints()) + { + for (auto i(all_version_constraints()->begin()), i_end(all_version_constraints()->end()) ; + i != i_end ; ++i) + p.version_constraint((*i)->version_spec(), (*i)->version_operator(), (*i)->combiner()); + } if (any_slot_constraint()) p.any_slot_constraint(any_slot_constraint()->locking()); @@ -314,13 +308,6 @@ PythonPackageDepSpec::operator PackageDepSpec() const p.key_constraint((*i)->key(), (*i)->operation(), (*i)->pattern()); } - if (version_requirements_ptr()) - { - for (VersionRequirements::ConstIterator i(version_requirements_ptr()->begin()), - i_end(version_requirements_ptr()->end()) ; i != i_end ; ++i) - p.version_requirement(*i); - } - return p.to_package_dep_spec(); } @@ -348,22 +335,10 @@ PythonPackageDepSpec::category_name_part_constraint() const return _imp->category_name_part_constraint; } -std::shared_ptr<const VersionRequirements> -PythonPackageDepSpec::version_requirements_ptr() const +const std::shared_ptr<const VersionConstraintSequence> +PythonPackageDepSpec::all_version_constraints() const { - return _imp->version_requirements; -} - -VersionRequirementsMode -PythonPackageDepSpec::version_requirements_mode() const -{ - return _imp->version_requirements_mode; -} - -void -PythonPackageDepSpec::set_version_requirements_mode(const VersionRequirementsMode m) -{ - _imp->version_requirements_mode = m; + return _imp->all_versions; } const std::shared_ptr<const AnySlotConstraint> @@ -1248,16 +1223,6 @@ void expose_dep_spec() "Category name part constraint (may be None)." ) - .add_property("version_requirements", &PythonPackageDepSpec::version_requirements_ptr, - "[ro] VersionRequirements\n" - "Version requirements (may be None)." - ) - - .add_property("version_requirements_mode", &PythonPackageDepSpec::version_requirements_mode, - "[ro] VersionRequirementsMode\n" - "Version requirements mode." - ) - .add_property("exact_slot", &PythonPackageDepSpec::exact_slot_constraint, "[ro] ExactSlotConstraint\n" "Exact slot constraint (may be None)." diff --git a/python/dep_spec.hh b/python/dep_spec.hh index 07f89867e..4c6b28f8d 100644 --- a/python/dep_spec.hh +++ b/python/dep_spec.hh @@ -175,15 +175,13 @@ namespace paludis const std::shared_ptr<const NameConstraint> package_name_constraint() const; const std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint() const; const std::shared_ptr<const CategoryNamePartConstraint> category_name_part_constraint() const; + const std::shared_ptr<const VersionConstraintSequence> all_version_constraints() const; const std::shared_ptr<const InRepositoryConstraint> in_repository_constraint() const; const std::shared_ptr<const FromRepositoryConstraint> from_repository_constraint() const; const std::shared_ptr<const ExactSlotConstraint> exact_slot_constraint() const; const std::shared_ptr<const AnySlotConstraint> any_slot_constraint() const; const std::shared_ptr<const KeyConstraintSequence> all_key_constraints() const; - std::shared_ptr<const VersionRequirements> version_requirements_ptr() const; - VersionRequirementsMode version_requirements_mode() const; - void set_version_requirements_mode(const VersionRequirementsMode m); std::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const; std::string py_str() const; diff --git a/python/dep_spec_TEST.py b/python/dep_spec_TEST.py index 8f8e0a79e..476d7179d 100755 --- a/python/dep_spec_TEST.py +++ b/python/dep_spec_TEST.py @@ -71,18 +71,6 @@ class TestCase_1_DepSpecs(unittest.TestCase): self.assertEqual(str(self.pds.in_repository_constraint.name), "testrepo") self.assertEqual(self.pds.from_repository_constraint, None) - def test_07_version_requirements(self): - self.get_depspecs() - vrc = self.pds.version_requirements - - self.assertEquals(len(list(vrc)), 1) - self.assertEquals(iter(vrc).next().version_spec, VersionSpec("1")) - self.assertEquals(iter(vrc).next().version_operator.value, VersionOperator(">=").value) - - def test_08_version_requirements_mode(self): - self.get_depspecs() - self.assertEquals(self.pds.version_requirements_mode, VersionRequirementsMode.AND) - ### def test_09_additional_requirements(self): ### spec = parse_user_package_dep_spec("foo/monkey[foo]", UserPackageDepSpecOptions()) ### ur = iter(spec.additional_requirements).next() diff --git a/python/paludis_python.hh b/python/paludis_python.hh index 640b521bc..da8dcddad 100644 --- a/python/paludis_python.hh +++ b/python/paludis_python.hh @@ -193,7 +193,6 @@ void expose_package_id() PALUDIS_VISIBLE; void expose_repository() PALUDIS_VISIBLE; void expose_selection() PALUDIS_VISIBLE; void expose_version_operator() PALUDIS_VISIBLE; -void expose_version_requirements() PALUDIS_VISIBLE; void expose_version_spec() PALUDIS_VISIBLE; #endif diff --git a/python/paludis_python_so.cc b/python/paludis_python_so.cc index b2ac1804c..dad35d9d5 100644 --- a/python/paludis_python_so.cc +++ b/python/paludis_python_so.cc @@ -33,7 +33,6 @@ BOOST_PYTHON_MODULE(paludis) expose_exception(); expose_version_spec(); expose_version_operator(); - expose_version_requirements(); expose_fs_path(); expose_contents(); expose_filter(); /* must be before dep_spec */ diff --git a/python/version_requirements.cc b/python/version_requirements.cc deleted file mode 100644 index 3ec32da3c..000000000 --- a/python/version_requirements.cc +++ /dev/null @@ -1,85 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 Piotr Jaroszyński - * - * This file is part of the Paludis package manager. Paludis is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <python/paludis_python.hh> -#include <python/iterable.hh> - -#include <paludis/version_requirements.hh> -#include <paludis/util/wrapped_forward_iterator.hh> -#include <paludis/util/make_named_values.hh> - -using namespace paludis; -using namespace paludis::python; -namespace bp = boost::python; - -namespace -{ - VersionRequirement * make_version_requirement(const VersionOperator & op, const VersionSpec & spec) - { - return new VersionRequirement(make_named_values<VersionRequirement>( - n::version_operator() = op, - n::version_spec() = spec - )); - } -} - -void expose_version_requirements() -{ - /** - * Enums - */ - enum_auto("VersionRequirementsMode", last_vr, - "Whether our version requirements are an 'and' or an 'or' set."); - - /** - * VersionRequirement - */ - bp::class_<VersionRequirement> - ( - "VersionRequirement", - bp::no_init - ) - - .def("__init__", - bp::make_constructor(&make_version_requirement), - "__init__(VersionOperator, VersionSpec)" - ) - - .add_property("version_operator", - &named_values_getter<VersionRequirement, n::version_operator, VersionOperator, &VersionRequirement::version_operator>, - &named_values_setter<VersionRequirement, n::version_operator, VersionOperator, &VersionRequirement::version_operator>, - "[rw] VersionOperator" - ) - - .add_property("version_spec", - &named_values_getter<VersionRequirement, n::version_spec, VersionSpec, &VersionRequirement::version_spec>, - &named_values_setter<VersionRequirement, n::version_spec, VersionSpec, &VersionRequirement::version_spec>, - "[rw] VersionSpec" - ) - ; - - /** - * VersionRequirements - */ - class_iterable<VersionRequirements> - ( - "VersionRequirements", - "Iterable collection of VersionRequirement instances, usually for a PackageDepSpec." - ); -} diff --git a/python/version_requirements_TEST.py b/python/version_requirements_TEST.py deleted file mode 100755 index 46321ed4f..000000000 --- a/python/version_requirements_TEST.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -# vim: set fileencoding=utf-8 sw=4 sts=4 et : - -# -# Copyright (c) 2007 Piotr Jaroszyński -# -# This file is part of the Paludis package manager. Paludis is free software; -# you can redistribute it and/or modify it under the terms of the GNU General -# Public License version 2, as published by the Free Software Foundation. -# -# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 59 Temple -# Place, Suite 330, Boston, MA 02111-1307 USA -# - -from paludis import * -import unittest - -class TestCase_VersionRequirements(unittest.TestCase): - def test_01_init(self): - VersionRequirement("<", VersionSpec("0")) - VersionRequirement(VersionOperatorValue.LESS, VersionSpec("0")) - - def test_02_data_members(self): - v1 = VersionRequirement("<", VersionSpec("0")) - v1.version_operator = ">" - v1.version_spec = VersionSpec("1") - - self.assertEquals(str(v1.version_operator), ">") - self.assertEquals(str(v1.version_spec), "1") - -if __name__ == "__main__": - unittest.main() diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc index 6e6e2a696..7952976a8 100644 --- a/ruby/dep_spec.cc +++ b/ruby/dep_spec.cc @@ -22,7 +22,6 @@ #include <paludis/dep_spec.hh> #include <paludis/user_dep_spec.hh> -#include <paludis/version_requirements.hh> #include <paludis/version_operator.hh> #include <paludis/package_dep_spec_constraint.hh> @@ -65,8 +64,6 @@ namespace static VALUE c_exactly_one_dep_spec; static VALUE c_conditional_dep_spec; - static VALUE c_version_requirements_mode; - struct WrappedSpecBase; template <typename> struct WrappedSpec; @@ -719,35 +716,6 @@ namespace std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_repository_constraint()); } - /* - * call-seq: - * version_requirements -> Array - * - * Fetch the version requirements. E.g. [ {:operator => '=', :spec => VersionSpec.new('0.1') } ] - */ - VALUE - package_dep_spec_version_requirements_ptr(VALUE self) - { - std::shared_ptr<WrappedSpecBase> * ptr; - Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr); - VALUE result(rb_ary_new()); - VALUE result_hash; - if (std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->version_requirements_ptr()) - for (VersionRequirements::ConstIterator i(std::static_pointer_cast<const PackageDepSpec>((*ptr)->base_spec())-> - version_requirements_ptr()->begin()), - i_end(std::static_pointer_cast<const PackageDepSpec>((*ptr)->base_spec())->version_requirements_ptr()->end()) ; - i != i_end; ++i) - { - result_hash = rb_hash_new(); - rb_hash_aset(result_hash, ID2SYM(rb_intern("operator")), - rb_str_new2(stringify(i->version_operator()).c_str())); - rb_hash_aset(result_hash, ID2SYM(rb_intern("spec")), - version_spec_to_value(i->version_spec())); - rb_ary_push(result, result_hash); - } - return result; - } - #ifdef CIARANM_REMOVED_THIS /* * call-seq: @@ -780,14 +748,6 @@ namespace } #endif - VALUE - package_dep_spec_version_requirements_mode(VALUE self) - { - std::shared_ptr<WrappedSpecBase> * ptr; - Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr); - return INT2FIX(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->version_requirements_mode()); - } - /* * Document-method: original_url * call-seq: original_url -> String @@ -1068,8 +1028,6 @@ namespace rb_define_method(c_package_dep_spec, "installable_to_path_constraint", RUBY_FUNC_CAST(&package_dep_spec_installable_to_path_constraint), 0); rb_define_method(c_package_dep_spec, "any_slot_constraint", RUBY_FUNC_CAST(&package_dep_spec_any_slot_constraint), 0); rb_define_method(c_package_dep_spec, "exact_slot_constraint", RUBY_FUNC_CAST(&package_dep_spec_exact_slot_constraint), 0); - rb_define_method(c_package_dep_spec, "version_requirements", RUBY_FUNC_CAST(&package_dep_spec_version_requirements_ptr), 0); - rb_define_method(c_package_dep_spec, "version_requirements_mode", RUBY_FUNC_CAST(&package_dep_spec_version_requirements_mode), 0); #ifdef CIARANM_REMOVED_THIS rb_define_method(c_package_dep_spec, "use_requirements", RUBY_FUNC_CAST(&package_dep_spec_use_requirements), 0); #endif @@ -1135,19 +1093,6 @@ namespace VALUE (* block_dep_spec_to_s) (VALUE) = &dep_spec_to_s<BlockDepSpec>; rb_define_method(c_block_dep_spec, "to_s", RUBY_FUNC_CAST(block_dep_spec_to_s), 0); - /* - * Document-module: Paludis::VersionRequirementsMode - * - * What sort of VersionRequirements to we have. - * - */ - c_version_requirements_mode = rb_define_module_under(paludis_module(), "VersionRequirementsMode"); - for (VersionRequirementsMode l(static_cast<VersionRequirementsMode>(0)), l_end(last_vr) ; l != l_end ; - l = static_cast<VersionRequirementsMode>(static_cast<int>(l) + 1)) - rb_define_const(c_version_requirements_mode, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l)); - - // cc_enum_special<paludis/version_requirements.hh, VersionRequirementsMode, c_version_requirements_mode> - rb_define_module_function(paludis_module(), "parse_user_package_dep_spec", RUBY_FUNC_CAST(&paludis_parse_user_dep_spec), -1); } } diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb index d0d63e3f1..d8bb8929e 100644 --- a/ruby/dep_spec_TEST.rb +++ b/ruby/dep_spec_TEST.rb @@ -203,22 +203,6 @@ module Paludis assert_nil pde.category_name_part_constraint end - def test_version_requirements - assert_kind_of Array, pda.version_requirements - assert_equal 1, pda.version_requirements.size - assert_equal VersionSpec.new('1'), pda.version_requirements.first[:spec] - assert_equal ">=", pda.version_requirements.first[:operator] - assert_equal 0, pdb.version_requirements.size - assert_equal 0, pdc.version_requirements.size - assert_equal 0, pdd.version_requirements.size - assert_equal 0, pde.version_requirements.size - end - - def test_version_requirements_mode - assert_kind_of Fixnum, pda.version_requirements_mode - assert_equal VersionRequirementsMode::And, pda.version_requirements_mode - end - ### def test_use_requirements ### assert_kind_of Array, pda.use_requirements ### assert_equal 2, pda.use_requirements.size diff --git a/ruby/package_dep_spec_constraint.cc b/ruby/package_dep_spec_constraint.cc index 52109a544..4184b4f4d 100644 --- a/ruby/package_dep_spec_constraint.cc +++ b/ruby/package_dep_spec_constraint.cc @@ -34,6 +34,7 @@ namespace static VALUE c_name_constraint; static VALUE c_package_name_part_constraint; static VALUE c_category_name_part_constraint; + static VALUE c_version_constraint; static VALUE c_in_repository_constraint; static VALUE c_from_repository_constraint; static VALUE c_installed_at_path_constraint; @@ -73,6 +74,12 @@ namespace new std::shared_ptr<const PackageDepSpecConstraint>(mm)); } + void visit(const VersionConstraint &) + { + value = Data_Wrap_Struct(c_version_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free, + new std::shared_ptr<const PackageDepSpecConstraint>(mm)); + } + void visit(const InRepositoryConstraint &) { value = Data_Wrap_Struct(c_in_repository_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free, diff --git a/src/clients/cave/cmd_fix_linkage.cc b/src/clients/cave/cmd_fix_linkage.cc index a99f227c5..c12fcf05a 100644 --- a/src/clients/cave/cmd_fix_linkage.cc +++ b/src/clients/cave/cmd_fix_linkage.cc @@ -28,6 +28,7 @@ #include <paludis/util/make_named_values.hh> #include <paludis/util/make_null_shared_ptr.hh> #include <paludis/util/create_iterator-impl.hh> + #include <paludis/broken_linkage_finder.hh> #include <paludis/package_id.hh> #include <paludis/name.hh> @@ -36,8 +37,8 @@ #include <paludis/metadata_key.hh> #include <paludis/notifier_callback.hh> #include <paludis/version_operator.hh> -#include <paludis/version_requirements.hh> #include <paludis/partially_made_package_dep_spec.hh> +#include <paludis/version_spec.hh> #include <iostream> #include <set> @@ -213,9 +214,7 @@ FixLinkageCommand::run( part_spec.exact_slot_constraint((*pkg_it)->slot_key()->value(), false); if (cmdline.a_exact.specified()) - part_spec.version_requirement(make_named_values<VersionRequirement>( - n::version_operator() = vo_equal, - n::version_spec() = (*pkg_it)->version())); + part_spec.version_constraint((*pkg_it)->version(), vo_equal, vcc_and); targets->push_back(std::make_pair(stringify(PackageDepSpec(part_spec)), join(broken_files.begin(), broken_files.end(), ", "))); } diff --git a/src/clients/cave/cmd_print_spec.cc b/src/clients/cave/cmd_print_spec.cc index a967aec0a..6380a9ded 100644 --- a/src/clients/cave/cmd_print_spec.cc +++ b/src/clients/cave/cmd_print_spec.cc @@ -20,8 +20,10 @@ #include "cmd_print_spec.hh" #include "exceptions.hh" #include "format_string.hh" + #include <paludis/args/args.hh> #include <paludis/args/do_help.hh> + #include <paludis/util/visitor_cast.hh> #include <paludis/util/set.hh> #include <paludis/util/iterator_funcs.hh> @@ -32,6 +34,7 @@ #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/join.hh> #include <paludis/util/make_named_values.hh> + #include <paludis/environment.hh> #include <paludis/metadata_key.hh> #include <paludis/user_dep_spec.hh> @@ -39,7 +42,8 @@ #include <paludis/partially_made_package_dep_spec.hh> #include <paludis/user_dep_spec.hh> #include <paludis/version_operator.hh> -#include <paludis/version_requirements.hh> +#include <paludis/version_spec.hh> + #include <iostream> #include <algorithm> @@ -218,6 +222,17 @@ namespace s.category_name_part(CategoryNamePart(cmdline.a_category_part.argument())); } + VersionConstraintCombiner vcc(vcc_and); + if (cmdline.a_version_requirements_mode.specified()) + { + if (cmdline.a_version_requirements_mode.argument() == "and") + vcc = vcc_and; + else if (cmdline.a_version_requirements_mode.argument() == "or") + vcc = vcc_or; + else + throw args::DoHelp("Argument for --" + cmdline.a_version_requirements_mode.long_name() + " unrecognised"); + } + if (cmdline.a_version_requirement.specified()) { s.clear_version_requirements(); @@ -232,24 +247,10 @@ namespace throw args::DoHelp("--" + cmdline.a_version_requirement.long_name() + " arguments should be in the form =1.23"); std::string op(a->substr(0, p)), ver(a->substr(p)); - - s.version_requirement(make_named_values<VersionRequirement>( - n::version_operator() = VersionOperator(op), - n::version_spec() = VersionSpec(ver, {}) - )); + s.version_constraint(VersionSpec(ver, {}), VersionOperator(op), vcc); } } - if (cmdline.a_version_requirements_mode.specified()) - { - if (cmdline.a_version_requirements_mode.argument() == "and") - s.version_requirements_mode(vr_and); - else if (cmdline.a_version_requirements_mode.argument() == "or") - s.version_requirements_mode(vr_or); - else - throw args::DoHelp("Argument for --" + cmdline.a_version_requirements_mode.long_name() + " unrecognised"); - } - if (cmdline.a_additional_requirement.specified()) { s.clear_additional_requirements(); diff --git a/src/clients/cave/cmd_report.cc b/src/clients/cave/cmd_report.cc index 4aefa3a7d..ff6e639ed 100644 --- a/src/clients/cave/cmd_report.cc +++ b/src/clients/cave/cmd_report.cc @@ -38,8 +38,8 @@ #include <paludis/mask.hh> #include <paludis/match_package.hh> #include <paludis/partially_made_package_dep_spec.hh> -#include <paludis/version_requirements.hh> #include <paludis/action.hh> +#include <paludis/version_operator.hh> #include <paludis/util/set.hh> #include <paludis/util/wrapped_forward_iterator.hh> @@ -108,9 +108,7 @@ namespace generator::InRepository(RepositoryName(*r)) & generator::Matches(make_package_dep_spec({ }) .package(id->name()) - .version_requirement(make_named_values<VersionRequirement>( - n::version_operator() = vo_equal, - n::version_spec() = id->version())), + .version_constraint(id->version(), vo_equal, vcc_and), make_null_shared_ptr(), { })) | filter::SupportsAction<InstallAction>())]); diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc index cfb68dc1e..cad509ba4 100644 --- a/src/clients/cave/resolve_common.cc +++ b/src/clients/cave/resolve_common.cc @@ -1118,7 +1118,7 @@ paludis::cave::resolve_common( if ('!' != t->at(0) && std::string::npos != t->find('/')) { PackageDepSpec ts(parse_spec_with_nice_error(*t, env.get(), { }, filter::All())); - if (ts.version_requirements_ptr() && ! ts.version_requirements_ptr()->empty()) + if (ts.all_version_constraints() && ! ts.all_version_constraints()->empty()) { confirm_helper.add_permit_downgrade_spec(ts); confirm_helper.add_permit_old_version_spec(ts); |