aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--paludis/package_database.cc6
-rw-r--r--paludis/package_database.hh6
-rw-r--r--paludis/package_database_TEST.cc3
3 files changed, 12 insertions, 3 deletions
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index f6cdabd09..28f1d661f 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -267,7 +267,7 @@ namespace
}
QualifiedPackageName
-PackageDatabase::fetch_unique_qualified_package_name(const PackageNamePart & p, const Filter & f) const
+PackageDatabase::fetch_unique_qualified_package_name(const PackageNamePart & p, const Filter & f, const bool disambiguate) const
{
Context context("When disambiguating package name '" + stringify(p) + "':");
@@ -344,6 +344,10 @@ PackageDatabase::fetch_unique_qualified_package_name(const PackageNamePart & p,
first_iterator(result->end()));
} while (false);
+ if (! disambiguate)
+ throw AmbiguousPackageNameError(stringify(p), first_iterator(result->begin()),
+ first_iterator(result->end()));
+
Log::get_instance()->message("package_database.ambiguous_name", ll_warning, lc_context)
<< "Package name '" << p << "' is ambiguous, assuming you meant '" << *qpns.begin()
<< "' (candidates were '"
diff --git a/paludis/package_database.hh b/paludis/package_database.hh
index 2bc9ffc9a..b081ca533 100644
--- a/paludis/package_database.hh
+++ b/paludis/package_database.hh
@@ -279,10 +279,12 @@ namespace paludis
* limit the potential results to packages that match.
*
* \throw AmbiguousPackageNameError if there is no unambiguous
- * disambiguation.
+ * disambiguation. If disambiguate is set to false, the
+ * exception will be always thrown in presence of ambiguity.
+ * \since 0.56 takes the disambiguate flag.
*/
QualifiedPackageName fetch_unique_qualified_package_name(
- const PackageNamePart &, const Filter & = all_filter()) const
+ const PackageNamePart &, const Filter & = all_filter(), const bool disambiguate = true) const
PALUDIS_ATTRIBUTE((warn_unused_result));
/**
diff --git a/paludis/package_database_TEST.cc b/paludis/package_database_TEST.cc
index 63c6efd47..d2196cfa2 100644
--- a/paludis/package_database_TEST.cc
+++ b/paludis/package_database_TEST.cc
@@ -216,6 +216,9 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(p.fetch_unique_qualified_package_name(PackageNamePart("pkg-foo"),
filter::SupportsAction<InstallAction>()),
"avail-cat/pkg-foo");
+ TEST_CHECK_THROWS(p.fetch_unique_qualified_package_name(PackageNamePart("pkg-foo"),
+ filter::All(), false),
+ AmbiguousPackageNameError);
}
} package_database_disambiguate_test;