aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Aleksandar Petrinic <petrinic@gmail.com> 2010-12-07 15:14:20 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-07 14:20:20 +0000
commit738e455a3beaedf5252cb2354381f6facef8d62d (patch)
tree3010b466c749992cf81e9272a5ed74cac75dff02
parentceca955ba1c180ee7964adf8d451218b26b55a54 (diff)
downloadpaludis-738e455a3beaedf5252cb2354381f6facef8d62d.tar.gz
paludis-738e455a3beaedf5252cb2354381f6facef8d62d.tar.xz
PackageDatabase::fetch_unique_qualified_package_name disambiguate flag
-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 f6cdabd..28f1d66 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 2bc9ffc..b081ca5 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 63c6efd..d2196cf 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;