aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-24 03:04:35 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-24 03:04:35 +0000
commitedc933d9af3d9b7ddcc36411cda54179ba54a3d3 (patch)
tree2ac1e3d9065315e7d58639615a04aebb7cefad80
parent64453b1a3c86a734620643cdd765c42d905efc49 (diff)
downloadpaludis-edc933d9af3d9b7ddcc36411cda54179ba54a3d3.tar.gz
paludis-edc933d9af3d9b7ddcc36411cda54179ba54a3d3.tar.xz
Improve the error message given for no resolvable || () items. Don't require a package name when checking whether a USE flag is enabled.
-rw-r--r--paludis/default_environment.cc29
-rw-r--r--paludis/default_environment.hh2
-rw-r--r--paludis/dep_list.cc19
-rw-r--r--paludis/dep_list.hh6
-rw-r--r--paludis/environment.hh2
-rw-r--r--paludis/test_environment.cc3
-rw-r--r--paludis/test_environment.hh2
-rw-r--r--src/install.cc2
8 files changed, 29 insertions, 36 deletions
diff --git a/paludis/default_environment.cc b/paludis/default_environment.cc
index 59ab4c3..58d732f 100644
--- a/paludis/default_environment.cc
+++ b/paludis/default_environment.cc
@@ -53,31 +53,11 @@ DefaultEnvironment::~DefaultEnvironment()
}
bool
-DefaultEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry & e) const
+DefaultEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry * e) const
{
- /// \todo
- /* prefer user masks, then profile, then disabled */
- do
- {
-#if 0
- switch (DefaultConfig::get_instance()->query_use(f, e))
- {
- case use_enabled:
- return true;
-
- case use_disabled:
- return false;
-
- case use_unspecified:
- continue;
- }
-
- throw InternalError(PALUDIS_HERE, "bad state");
-
-#endif
- } while (false);
-
+ /// \todo package use
+ /* prefer user masks, then profile, then disabled */
do
{
UseFlagState state(use_unspecified);
@@ -104,7 +84,8 @@ DefaultEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry
throw InternalError(PALUDIS_HERE, "bad state " + stringify(state));
} while (false);
- switch (package_database()->fetch_repository(e.get<pde_repository>())->query_use(f))
+ switch (e ? package_database()->fetch_repository(e->get<pde_repository>())->query_use(f) :
+ package_database()->fetch_repository(package_database()->favourite_repository())->query_use(f))
{
case use_disabled:
case use_unspecified:
diff --git a/paludis/default_environment.hh b/paludis/default_environment.hh
index a2ac4c9..c63d29b 100644
--- a/paludis/default_environment.hh
+++ b/paludis/default_environment.hh
@@ -49,7 +49,7 @@ namespace paludis
~DefaultEnvironment();
public:
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const;
+ virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
virtual bool accept_keyword(const KeywordName &, const PackageDatabaseEntry * const) const;
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 086af0c..8fe7cac 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -60,6 +60,13 @@ NoResolvableOptionError::NoResolvableOptionError() throw () :
{
}
+template <typename I_>
+NoResolvableOptionError::NoResolvableOptionError(I_ i, I_ end) throw () :
+ DepListError("No resolvable || ( ) option." + (i == end ?
+ std::string("") : " Failure messages are '" + join(i, end, "', '") + "'"))
+{
+}
+
AllMaskedError::AllMaskedError(const std::string & query) throw () :
DepListError("Error searching for '" + query + "': no available versions")
{
@@ -327,7 +334,7 @@ DepList::visit(const UseDepAtom * const u)
throw InternalError(PALUDIS_HERE, "current_package is 0");
if (_implementation->environment->query_use(u->flag(),
- *_implementation->current_package) ^ u->inverse())
+ _implementation->current_package) ^ u->inverse())
std::for_each(u->begin(), u->end(), std::bind1st(std::mem_fun(&DepList::add), this));
}
@@ -348,7 +355,7 @@ struct IsViable :
const UseDepAtom * u(0);
if (0 != ((u = dynamic_cast<const UseDepAtom *>(a.raw_pointer()))))
return _impl.environment->query_use(u->flag(),
- *_impl.current_package) ^ u->inverse();
+ _impl.current_package) ^ u->inverse();
else
return true;
}
@@ -370,8 +377,6 @@ DepList::visit(const AnyDepAtom * const a)
*/
std::list<DepAtom::ConstPointer> viable_children;
- if (0 == _implementation->current_package)
- throw InternalError(PALUDIS_HERE, "current_package is 0");
std::copy(a->begin(), a->end(), filter_inserter(
std::back_inserter(viable_children), IsViable(*_implementation)));
@@ -398,6 +403,7 @@ DepList::visit(const AnyDepAtom * const a)
}
/* try to merge each of our viable children in turn. */
+ std::list<std::string> errors;
for (CompositeDepAtom::Iterator i(viable_children.begin()), i_end(viable_children.end()) ;
i != i_end ; ++i)
{
@@ -412,13 +418,14 @@ DepList::visit(const AnyDepAtom * const a)
* resolvable with a deeper stack. */
throw;
}
- catch (const DepListError &)
+ catch (const DepListError & e)
{
+ errors.push_back(e.message() + " (" + e.what() + ")");
}
}
/* no match */
- throw NoResolvableOptionError();
+ throw NoResolvableOptionError(errors.begin(), errors.end());
}
void
diff --git a/paludis/dep_list.hh b/paludis/dep_list.hh
index bf464a5..9b96a37 100644
--- a/paludis/dep_list.hh
+++ b/paludis/dep_list.hh
@@ -103,6 +103,12 @@ namespace paludis
* Constructor.
*/
NoResolvableOptionError() throw ();
+
+ /**
+ * Constructor with failure reasons.
+ */
+ template <typename I_>
+ NoResolvableOptionError(I_ i, I_ end) throw ();
};
/**
diff --git a/paludis/environment.hh b/paludis/environment.hh
index aa12176..8502394 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -60,7 +60,7 @@ namespace paludis
* Does the user want the specified USE flag set for a
* particular package?
*/
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const = 0;
+ virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry *) const = 0;
/**
* Is the specified KEYWORD accepted?
diff --git a/paludis/test_environment.cc b/paludis/test_environment.cc
index 7d947a3..68e314c 100644
--- a/paludis/test_environment.cc
+++ b/paludis/test_environment.cc
@@ -28,9 +28,8 @@ TestEnvironment::TestEnvironment() :
}
bool
-TestEnvironment::query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+TestEnvironment::query_use(const UseFlagName &, const PackageDatabaseEntry *) const
{
- /// \todo
return false;
}
diff --git a/paludis/test_environment.hh b/paludis/test_environment.hh
index 0d7bd57..7abb2d1 100644
--- a/paludis/test_environment.hh
+++ b/paludis/test_environment.hh
@@ -38,7 +38,7 @@ namespace paludis
*/
TestEnvironment();
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const;
+ virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry *) const;
virtual bool accept_keyword(const KeywordName &, const PackageDatabaseEntry * const) const;
diff --git a/src/install.cc b/src/install.cc
index e16ea3e..bf41781 100644
--- a/src/install.cc
+++ b/src/install.cc
@@ -107,7 +107,7 @@ do_install()
for (p::VersionMetadata::IuseIterator i(metadata->begin_iuse()),
i_end(metadata->end_iuse()) ; i != i_end ; ++i)
{
- if (env->query_use(*i, p))
+ if (env->query_use(*i, &p))
cout << " " << colour(cl_flag_on, *i);
else if (env->package_database()->fetch_repository(dep->get<p::dle_repository>())->query_use_mask(*i))
cout << " " << colour(cl_flag_off, "(-" + p::stringify(*i) + ")");