aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mike Kelly <pioto@pioto.org> 2009-02-19 22:15:14 -0500
committerAvatar Mike Kelly <pioto@pioto.org> 2009-02-19 22:21:54 -0500
commitb23598ff09e9f2eb4f36f1ca4cdc4cef04edf5dd (patch)
tree423c588b1657db0f7f7a275c84fddbace5bf8514
parent6fc60c59273edc2ccfc5c6fe0d96b3cae4f3a53f (diff)
downloadpaludis-b23598ff09e9f2eb4f36f1ca4cdc4cef04edf5dd.tar.gz
paludis-b23598ff09e9f2eb4f36f1ca4cdc4cef04edf5dd.tar.xz
FakeInstalledRepositories "support" uninstalling.
By default now, FakeInstalledRepository objects will claim that some_ids_might_support_action(SupportsActionTest<UninstallAction>()). That can be disabled with the optional 3rd argument to the constructor.
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc21
-rw-r--r--paludis/repositories/fake/fake_installed_repository.hh2
2 files changed, 16 insertions, 7 deletions
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 05d2438..7ef9871 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -41,18 +41,20 @@ namespace paludis
{
std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key;
std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > installed_root_key;
+ const bool supports_uninstall;
- Implementation() :
+ Implementation(const bool s) :
format_key(new LiteralMetadataValueKey<std::string> (
"format", "format", mkt_significant, "installed_fake")),
installed_root_key(new LiteralMetadataValueKey<FSEntry> (
- "installed_root", "installed_root", mkt_normal, FSEntry("/")))
+ "installed_root", "installed_root", mkt_normal, FSEntry("/"))),
+ supports_uninstall(s)
{
}
};
}
-FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, const RepositoryName & our_name) :
+FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, const RepositoryName & our_name, const bool supports_uninstall) :
FakeRepositoryBase(e, our_name, make_named_values<RepositoryCapabilities>(
value_for<n::destination_interface>(this),
value_for<n::e_interface>(static_cast<RepositoryEInterface *>(0)),
@@ -67,7 +69,7 @@ FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, co
value_for<n::syncable_interface>(static_cast<RepositorySyncableInterface *>(0)),
value_for<n::virtuals_interface>(static_cast<RepositoryVirtualsInterface *>(0))
)),
- PrivateImplementationPattern<FakeInstalledRepository>(new Implementation<FakeInstalledRepository>),
+ PrivateImplementationPattern<FakeInstalledRepository>(new Implementation<FakeInstalledRepository>(supports_uninstall)),
_imp(PrivateImplementationPattern<FakeInstalledRepository>::_imp)
{
add_metadata_key(_imp->format_key);
@@ -140,6 +142,13 @@ namespace
{
struct SupportsActionQuery
{
+ const bool supports_uninstall;
+
+ SupportsActionQuery(const bool s) :
+ supports_uninstall(s)
+ {
+ }
+
bool visit(const SupportsActionTest<InstalledAction> &) const
{
return true;
@@ -177,7 +186,7 @@ namespace
bool visit(const SupportsActionTest<UninstallAction> &) const
{
- return false;
+ return supports_uninstall;
}
};
}
@@ -185,7 +194,7 @@ namespace
bool
FakeInstalledRepository::some_ids_might_support_action(const SupportsActionTestBase & a) const
{
- SupportsActionQuery q;
+ SupportsActionQuery q(_imp->supports_uninstall);
return a.accept_returning<bool>(q);
}
diff --git a/paludis/repositories/fake/fake_installed_repository.hh b/paludis/repositories/fake/fake_installed_repository.hh
index 2848867..5f5e661 100644
--- a/paludis/repositories/fake/fake_installed_repository.hh
+++ b/paludis/repositories/fake/fake_installed_repository.hh
@@ -61,7 +61,7 @@ namespace paludis
///\name Basic operations
///\{
- FakeInstalledRepository(const Environment * const, const RepositoryName &);
+ FakeInstalledRepository(const Environment * const, const RepositoryName &, const bool supports_uninstall = true);
~FakeInstalledRepository();
///\}