aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-19 13:30:33 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-19 13:30:33 +0000
commita9be46e2316e6c06452b74777aca069433fb3d2a (patch)
treea6de317982ad3c88d5ec1f063d2d43b0efac70f8
parentdf660379a0c4e6fffd66fab54cc3f3f9e1f54e96 (diff)
downloadpaludis-a9be46e2316e6c06452b74777aca069433fb3d2a.tar.gz
paludis-a9be46e2316e6c06452b74777aca069433fb3d2a.tar.xz
Put tokens on user masks
-rw-r--r--paludis/mask-fwd.hh8
-rw-r--r--paludis/mask.cc45
-rw-r--r--paludis/mask.hh8
-rw-r--r--paludis/repositories/e/ebuild_id.cc2
4 files changed, 61 insertions, 2 deletions
diff --git a/paludis/mask-fwd.hh b/paludis/mask-fwd.hh
index 18353fd..f102250 100644
--- a/paludis/mask-fwd.hh
+++ b/paludis/mask-fwd.hh
@@ -42,6 +42,14 @@ namespace paludis
#include <paludis/mask-se.hh>
+ /**
+ * Fetch the token associated with a Mask, or "" if there is
+ * no such token.
+ *
+ * \since 0.60
+ * \ingroup g_mask
+ */
+ const std::string get_mask_token(const Mask &) PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
}
#endif
diff --git a/paludis/mask.cc b/paludis/mask.cc
index 08ac243..0f3bafd 100644
--- a/paludis/mask.cc
+++ b/paludis/mask.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 2007, 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
@@ -31,3 +31,46 @@ Mask::~Mask()
{
}
+const std::string
+UserMask::token() const
+{
+ return "user";
+}
+
+namespace
+{
+ struct TokenGetter
+ {
+ std::string visit(const UserMask & m) const
+ {
+ return m.token();
+ }
+
+ std::string visit(const RepositoryMask & m) const
+ {
+ return m.token();
+ }
+
+ std::string visit(const UnacceptedMask &) const
+ {
+ return "";
+ }
+
+ std::string visit(const UnsupportedMask &) const
+ {
+ return "";
+ }
+
+ std::string visit(const AssociationMask &) const
+ {
+ return "";
+ }
+ };
+}
+
+const std::string
+paludis::get_mask_token(const Mask & m)
+{
+ return m.accept_returning<std::string>(TokenGetter{});
+}
+
diff --git a/paludis/mask.hh b/paludis/mask.hh
index 9379512..39b7f9f 100644
--- a/paludis/mask.hh
+++ b/paludis/mask.hh
@@ -104,6 +104,14 @@ namespace paludis
public Mask,
public ImplementAcceptMethods<Mask, UserMask>
{
+ public:
+ /**
+ * An associated token, for Environment::unmasked_by_user. Might be empty,
+ * but is probably "user".
+ *
+ * \since 0.60
+ */
+ virtual const std::string token() const;
};
/**
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 03d4284..09ff33f 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -596,7 +596,7 @@ EbuildID::need_masks_added() const
std::shared_ptr<const Mask> user_mask(_imp->environment->mask_for_user(shared_from_this(), false));
if (user_mask)
{
- if (_imp->environment->unmasked_by_user(shared_from_this(), "user"))
+ if (_imp->environment->unmasked_by_user(shared_from_this(), get_mask_token(*user_mask)))
add_overridden_mask(std::make_shared<OverriddenMask>(
make_named_values<OverriddenMask>(
n::mask() = user_mask,