aboutsummaryrefslogtreecommitdiff
path: root/paludis
diff options
context:
space:
mode:
Diffstat (limited to 'paludis')
-rw-r--r--paludis/dep_spec.cc13
-rw-r--r--paludis/dep_spec.hh13
-rw-r--r--paludis/dep_spec_TEST.cc1
-rw-r--r--paludis/dep_spec_data.hh13
-rw-r--r--paludis/elike_package_dep_spec-fwd.hh14
-rw-r--r--paludis/elike_package_dep_spec.cc152
-rw-r--r--paludis/elike_package_dep_spec.hh8
-rw-r--r--paludis/files.m41
-rw-r--r--paludis/match_package.cc49
-rw-r--r--paludis/package_dep_spec_constraint-fwd.hh4
-rw-r--r--paludis/package_dep_spec_constraint.cc51
-rw-r--r--paludis/package_dep_spec_constraint.hh27
-rw-r--r--paludis/package_dep_spec_constraint.se8
-rw-r--r--paludis/package_dep_spec_properties.cc2
-rw-r--r--paludis/partially_made_package_dep_spec.cc104
-rw-r--r--paludis/partially_made_package_dep_spec.hh12
-rw-r--r--paludis/repositories/e/e_repository_sets.cc9
-rw-r--r--paludis/repositories/e/vdb_repository.cc7
-rw-r--r--paludis/repositories/gemcutter/gemcutter_dependencies_key.cc6
-rw-r--r--paludis/repositories/virtuals/package_id.cc6
-rw-r--r--paludis/resolver/decider.cc17
-rw-r--r--paludis/user_dep_spec.cc67
-rw-r--r--paludis/user_dep_spec_TEST.cc22
-rw-r--r--paludis/version_operator.hh7
-rw-r--r--paludis/version_requirements-fwd.hh71
-rw-r--r--paludis/version_requirements.cc58
-rw-r--r--paludis/version_requirements.hh64
27 files changed, 319 insertions, 487 deletions
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