aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-10 17:20:02 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-10 17:48:13 +0000
commit75e5230b9aa3ca5dc59cbc36be43d805f60150b3 (patch)
tree01401260490306f856579c46ae5aa0ae664ea887
parent303e393a5b5b359160b9611a27db872ab09ea866 (diff)
downloadpaludis-75e5230b9aa3ca5dc59cbc36be43d805f60150b3.tar.gz
paludis-75e5230b9aa3ca5dc59cbc36be43d805f60150b3.tar.xz
Add overridden masks.
Fixes: ticket:369 Fixes: ticket:693
-rw-r--r--paludis/environment.hh8
-rw-r--r--paludis/environments/no_config/no_config_environment.cc2
-rw-r--r--paludis/environments/no_config/no_config_environment.hh4
-rw-r--r--paludis/environments/paludis/paludis_environment.cc29
-rw-r--r--paludis/environments/paludis/paludis_environment.hh4
-rw-r--r--paludis/environments/portage/portage_environment.cc29
-rw-r--r--paludis/environments/portage/portage_environment.hh4
-rw-r--r--paludis/environments/test/test_environment.cc2
-rw-r--r--paludis/environments/test/test_environment.hh2
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/mask-fwd.hh10
-rw-r--r--paludis/mask.cc7
-rw-r--r--paludis/mask.hh17
-rw-r--r--paludis/mask.se21
-rw-r--r--paludis/package_id.cc29
-rw-r--r--paludis/package_id.hh25
-rw-r--r--paludis/repositories/e/ebuild_id.cc51
-rw-r--r--paludis/repositories/fake/fake_package_id.cc15
-rw-r--r--paludis/repositories/gems/gem_specification.cc16
-rw-r--r--python/additional_tests.cc2
-rw-r--r--python/environment.cc9
-rwxr-xr-xpython/environment_TEST.py2
-rw-r--r--src/output/console_query_task.cc15
23 files changed, 252 insertions, 53 deletions
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 63a9545..467b1a8 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009 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
@@ -157,10 +157,14 @@ namespace paludis
*
* Returns a zero pointer if no.
*
+ * If the second parameter is true, return a Mask suitable for
+ * being added to an OverriddenMask.
+ *
* Used by PackageID implementations. Generally PackageID's masks methods
* should be used rather than calling this directly.
*/
- virtual const std::tr1::shared_ptr<const Mask> mask_for_user(const PackageID &) const
+ virtual const std::tr1::shared_ptr<const Mask> mask_for_user(const PackageID &,
+ const bool will_be_used_for_overridden) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc
index 02b10a0..06e3185 100644
--- a/paludis/environments/no_config/no_config_environment.cc
+++ b/paludis/environments/no_config/no_config_environment.cc
@@ -547,7 +547,7 @@ NoConfigEnvironment::mask_for_breakage(const PackageID &) const
}
const std::tr1::shared_ptr<const Mask>
-NoConfigEnvironment::mask_for_user(const PackageID &) const
+NoConfigEnvironment::mask_for_user(const PackageID &, const bool) const
{
return std::tr1::shared_ptr<const Mask>();
}
diff --git a/paludis/environments/no_config/no_config_environment.hh b/paludis/environments/no_config/no_config_environment.hh
index 84dd679..e41a613 100644
--- a/paludis/environments/no_config/no_config_environment.hh
+++ b/paludis/environments/no_config/no_config_environment.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 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
@@ -171,7 +171,7 @@ namespace paludis
virtual const std::tr1::shared_ptr<const Mask> mask_for_breakage(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual const std::tr1::shared_ptr<const Mask> mask_for_user(const PackageID &) const
+ virtual const std::tr1::shared_ptr<const Mask> mask_for_user(const PackageID &, const bool will_be_used_for_overridden) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool unmasked_by_user(const PackageID &) const
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 392c2d5..e073adb 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -462,15 +462,24 @@ namespace
class UserConfigMask :
public UserMask
{
- char key() const
- {
- return 'U';
- }
+ private:
+ bool _overridden;
- const std::string description() const
- {
- return "user";
- }
+ public:
+ UserConfigMask(const bool o) :
+ _overridden(o)
+ {
+ }
+
+ char key() const
+ {
+ return _overridden ? 'u' : 'U';
+ }
+
+ const std::string description() const
+ {
+ return _overridden ? "user (overridden)" : "user";
+ }
};
}
@@ -495,10 +504,10 @@ PaludisEnvironment::mask_for_breakage(const PackageID & id) const
}
const std::tr1::shared_ptr<const Mask>
-PaludisEnvironment::mask_for_user(const PackageID & d) const
+PaludisEnvironment::mask_for_user(const PackageID & d, const bool o) const
{
if (_imp->config->package_mask_conf()->query(d))
- return make_shared_ptr(new UserConfigMask);
+ return make_shared_ptr(new UserConfigMask(o));
return std::tr1::shared_ptr<const Mask>();
}
diff --git a/paludis/environments/paludis/paludis_environment.hh b/paludis/environments/paludis/paludis_environment.hh
index b686d74..b8159c9 100644
--- a/paludis/environments/paludis/paludis_environment.hh
+++ b/paludis/environments/paludis/paludis_environment.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009 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
@@ -133,7 +133,7 @@ namespace paludis
virtual const std::tr1::shared_ptr<const Mask> mask_for_breakage(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual const std::tr1::shared_ptr<const Mask> mask_for_user(const PackageID &) const
+ virtual const std::tr1::shared_ptr<const Mask> mask_for_user(const PackageID &, const bool) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool unmasked_by_user(const PackageID &) const
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index 166612d..0432d88 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -804,15 +804,24 @@ namespace
class UserConfigMask :
public UserMask
{
- char key() const
- {
- return 'U';
- }
+ private:
+ bool _overridden;
- const std::string description() const
- {
- return "user";
- }
+ public:
+ UserConfigMask(const bool o) :
+ _overridden(o)
+ {
+ }
+
+ char key() const
+ {
+ return _overridden ? 'u' : 'U';
+ }
+
+ const std::string description() const
+ {
+ return _overridden ? "user (overridden)" : "user";
+ }
};
}
@@ -837,12 +846,12 @@ PortageEnvironment::mask_for_breakage(const PackageID & id) const
}
const std::tr1::shared_ptr<const Mask>
-PortageEnvironment::mask_for_user(const PackageID & d) const
+PortageEnvironment::mask_for_user(const PackageID & d, const bool o) const
{
for (PackageMask::const_iterator i(_imp->package_mask.begin()), i_end(_imp->package_mask.end()) ;
i != i_end ; ++i)
if (match_package(*this, **i, d, MatchPackageOptions()))
- return make_shared_ptr(new UserConfigMask);
+ return make_shared_ptr(new UserConfigMask(o));
return std::tr1::shared_ptr<const Mask>();
}
diff --git a/paludis/environments/portage/portage_environment.hh b/paludis/environments/portage/portage_environment.hh
index 98021fc..5c49106 100644
--- a/paludis/environments/portage/portage_environment.hh
+++ b/paludis/environments/portage/portage_environment.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 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
@@ -145,7 +145,7 @@ namespace paludis
virtual const std::tr1::shared_ptr<const Mask> mask_for_breakage(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual const std::tr1::shared_ptr<const Mask> mask_for_user(const PackageID &) const
+ virtual const std::tr1::shared_ptr<const Mask> mask_for_user(const PackageID &, const bool) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool unmasked_by_user(const PackageID &) const
diff --git a/paludis/environments/test/test_environment.cc b/paludis/environments/test/test_environment.cc
index 89351a6..58a71b3 100644
--- a/paludis/environments/test/test_environment.cc
+++ b/paludis/environments/test/test_environment.cc
@@ -188,7 +188,7 @@ TestEnvironment::mask_for_breakage(const PackageID &) const
}
const std::tr1::shared_ptr<const Mask>
-TestEnvironment::mask_for_user(const PackageID &) const
+TestEnvironment::mask_for_user(const PackageID &, const bool) const
{
return std::tr1::shared_ptr<const Mask>();
}
diff --git a/paludis/environments/test/test_environment.hh b/paludis/environments/test/test_environment.hh
index fc63318..5bad55b 100644
--- a/paludis/environments/test/test_environment.hh
+++ b/paludis/environments/test/test_environment.hh
@@ -92,7 +92,7 @@ namespace paludis
virtual const std::tr1::shared_ptr<const Mask> mask_for_breakage(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual const std::tr1::shared_ptr<const Mask> mask_for_user(const PackageID &) const
+ virtual const std::tr1::shared_ptr<const Mask> mask_for_user(const PackageID &, const bool) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool unmasked_by_user(const PackageID &) const
diff --git a/paludis/files.m4 b/paludis/files.m4
index 98e841c..04888a1 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -43,7 +43,7 @@ add(`hook', `hh', `cc', `fwd', `se')
add(`hooker', `hh', `cc', `test', `testscript')
add(`install_task', `hh', `cc', `se')
add(`literal_metadata_key', `hh', `cc')
-add(`mask', `hh', `cc', `fwd')
+add(`mask', `hh', `cc', `fwd', `se')
add(`match_package', `hh', `cc', `se', `fwd')
add(`merger', `hh', `cc', `fwd', `se', `test', `testscript')
add(`merger_entry_type', `hh', `cc', `se')
diff --git a/paludis/mask-fwd.hh b/paludis/mask-fwd.hh
index 8f1d5f1..569edc9 100644
--- a/paludis/mask-fwd.hh
+++ b/paludis/mask-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 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
@@ -20,6 +20,9 @@
#ifndef PALUDIS_GUARD_PALUDIS_MASK_FWD_HH
#define PALUDIS_GUARD_PALUDIS_MASK_FWD_HH 1
+#include <paludis/util/attributes.hh>
+#include <iosfwd>
+
/** \file
* Forward declarations for paludis/mask.hh .
*
@@ -36,6 +39,11 @@ namespace paludis
class AssociationMask;
struct RepositoryMaskInfo;
+
+ struct OverriddenMask;
+
+#include <paludis/mask-se.hh>
+
}
#endif
diff --git a/paludis/mask.cc b/paludis/mask.cc
index 0f81f17..e4b5627 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 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 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
@@ -18,9 +18,14 @@
*/
#include <paludis/mask.hh>
+#include <paludis/util/stringify.hh>
+#include <istream>
+#include <ostream>
using namespace paludis;
+#include <paludis/mask-se.cc>
+
Mask::~Mask()
{
}
diff --git a/paludis/mask.hh b/paludis/mask.hh
index ed23fdf..fd2fd78 100644
--- a/paludis/mask.hh
+++ b/paludis/mask.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 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
@@ -46,7 +46,9 @@ namespace paludis
namespace n
{
struct comment;
+ struct mask;
struct mask_file;
+ struct override_reason;
}
/**
@@ -201,6 +203,19 @@ namespace paludis
*/
virtual const std::tr1::shared_ptr<const PackageID> associated_package() const = 0;
};
+
+ /**
+ * An OverriddenMask holds a Mask and an explanation of why it has been overridden.
+ *
+ * \ingroup g_mask
+ * \since 0.34
+ */
+ struct OverriddenMask
+ {
+ NamedValue<n::mask, std::tr1::shared_ptr<const Mask> > mask;
+ NamedValue<n::override_reason, MaskOverrideReason> override_reason;
+
+ };
}
#endif
diff --git a/paludis/mask.se b/paludis/mask.se
new file mode 100644
index 0000000..c26b403
--- /dev/null
+++ b/paludis/mask.se
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_MaskOverrideReason()
+{
+ prefix mro
+ want_destringify
+
+ key mro_accepted_unstable "The package is unstable, but the user accepted that (for example, ~keyword)"
+ key mro_overridden_by_user "The user overrode the mask (for example, package_unmask.conf)"
+
+ doxygen_comment << "END"
+ /**
+ * The reason an OverriddenMask is overridden.
+ *
+ * \see OverriddenMask
+ * \ingroup g_mask
+ */
+END
+}
+
diff --git a/paludis/package_id.cc b/paludis/package_id.cc
index e62c4b1..9cf6c13 100644
--- a/paludis/package_id.cc
+++ b/paludis/package_id.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 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
@@ -56,8 +56,9 @@ template class WrappedForwardIterator<Set<std::tr1::shared_ptr<const PackageID>,
template class WrappedOutputIterator<Set<std::tr1::shared_ptr<const PackageID>, PackageIDSetComparator>::InserterTag,
std::tr1::shared_ptr<const PackageID> >;
-template class WrappedForwardIterator<PackageID::MetadataConstIteratorTag, std::tr1::shared_ptr<const MetadataKey> >;
-template class WrappedForwardIterator<PackageID::MasksConstIteratorTag, std::tr1::shared_ptr<const Mask> >;
+template class WrappedForwardIterator<PackageID::MetadataConstIteratorTag, const std::tr1::shared_ptr<const MetadataKey> >;
+template class WrappedForwardIterator<PackageID::MasksConstIteratorTag, const std::tr1::shared_ptr<const Mask> >;
+template class WrappedForwardIterator<PackageID::OverriddenMasksConstIteratorTag, const std::tr1::shared_ptr<const OverriddenMask> >;
namespace paludis
{
@@ -65,6 +66,7 @@ namespace paludis
struct Implementation<PackageID>
{
mutable std::list<std::tr1::shared_ptr<const Mask> > masks;
+ mutable std::list<std::tr1::shared_ptr<const OverriddenMask> > overridden_masks;
};
}
@@ -84,6 +86,12 @@ PackageID::add_mask(const std::tr1::shared_ptr<const Mask> & k) const
_imp->masks.push_back(k);
}
+void
+PackageID::add_overridden_mask(const std::tr1::shared_ptr<const OverriddenMask> & k) const
+{
+ _imp->overridden_masks.push_back(k);
+}
+
PackageID::MasksConstIterator
PackageID::begin_masks() const
{
@@ -98,6 +106,20 @@ PackageID::end_masks() const
return MasksConstIterator(_imp->masks.end());
}
+PackageID::OverriddenMasksConstIterator
+PackageID::begin_overridden_masks() const
+{
+ need_masks_added();
+ return OverriddenMasksConstIterator(_imp->overridden_masks.begin());
+}
+
+PackageID::OverriddenMasksConstIterator
+PackageID::end_overridden_masks() const
+{
+ need_masks_added();
+ return OverriddenMasksConstIterator(_imp->overridden_masks.end());
+}
+
bool
PackageID::masked() const
{
@@ -108,6 +130,7 @@ void
PackageID::invalidate_masks() const
{
_imp->masks.clear();
+ _imp->overridden_masks.clear();
}
std::ostream &
diff --git a/paludis/package_id.hh b/paludis/package_id.hh
index b19693d..29e2fa6 100644
--- a/paludis/package_id.hh
+++ b/paludis/package_id.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 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
@@ -104,6 +104,13 @@ namespace paludis
virtual void add_mask(const std::tr1::shared_ptr<const Mask> &) const;
/**
+ * Add a new OverriddenMask.
+ *
+ * \since 0.34
+ */
+ virtual void add_overridden_mask(const std::tr1::shared_ptr<const OverriddenMask> &) const;
+
+ /**
* This method will be called before any of the mask iteration
* methods does its work. It can be used by subclasses to implement
* as-needed loading of masks.
@@ -305,13 +312,13 @@ namespace paludis
///\{
struct MasksConstIteratorTag;
- typedef WrappedForwardIterator<MasksConstIteratorTag, std::tr1::shared_ptr<const Mask> > MasksConstIterator;
+ typedef WrappedForwardIterator<MasksConstIteratorTag, const std::tr1::shared_ptr<const Mask> > MasksConstIterator;
MasksConstIterator begin_masks() const PALUDIS_ATTRIBUTE((warn_unused_result));
MasksConstIterator end_masks() const PALUDIS_ATTRIBUTE((warn_unused_result));
/**
- * Do we have any masks? Equivalent to begin_masks() != end_masks().
+ * Do we have any effective masks? Equivalent to begin_masks() != end_masks().
*/
bool masked() const PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -334,6 +341,18 @@ namespace paludis
///\}
+ ///\name Overridden masks
+ ///\{
+ ///\since 0.34
+
+ struct OverriddenMasksConstIteratorTag;
+ typedef WrappedForwardIterator<OverriddenMasksConstIteratorTag, const std::tr1::shared_ptr<const OverriddenMask> > OverriddenMasksConstIterator;
+
+ OverriddenMasksConstIterator begin_overridden_masks() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ OverriddenMasksConstIterator end_overridden_masks() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ ///\}
+
///\name Extra comparisons
///\{
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index bc189c3..25ed312 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -380,6 +380,12 @@ namespace
ok = false;
}
};
+
+ bool is_stable_keyword(const KeywordName & k)
+ {
+ char c(*stringify(k).c_str());
+ return (c != '~') && (c != '-');
+ }
}
void
@@ -401,10 +407,25 @@ EbuildID::need_masks_added() const
}
if (keywords_key())
+ {
if (! _imp->environment->accept_keywords(keywords_key()->value(), *this))
+ {
add_mask(make_shared_ptr(new EUnacceptedMask('K',
DistributionData::get_instance()->distribution_from_string(
_imp->environment->distribution())->concept_keyword(), keywords_key())));
+ }
+ else if (keywords_key()->value()->end() == std::find_if(keywords_key()->value()->begin(),
+ keywords_key()->value()->end(), &is_stable_keyword))
+ {
+ add_overridden_mask(make_shared_ptr(new OverriddenMask(
+ make_named_values<OverriddenMask>(
+ value_for<n::mask>(make_shared_ptr(new EUnacceptedMask('~',
+ DistributionData::get_instance()->distribution_from_string(
+ _imp->environment->distribution())->concept_keyword() + " (unstable accepted)", keywords_key()))),
+ value_for<n::override_reason>(mro_accepted_unstable)
+ ))));
+ }
+ }
if (license_key())
{
@@ -427,10 +448,38 @@ EbuildID::need_masks_added() const
add_mask(make_shared_ptr(new ERepositoryMask('P', "profile", _imp->profile_mask)));
/* user */
- std::tr1::shared_ptr<const Mask> user_mask(_imp->environment->mask_for_user(*this));
+ std::tr1::shared_ptr<const Mask> user_mask(_imp->environment->mask_for_user(*this, false));
if (user_mask)
add_mask(user_mask);
}
+ else
+ {
+ /* repo overridden by user */
+ if (_imp->repository_mask->value())
+ add_overridden_mask(make_shared_ptr(new OverriddenMask(
+ make_named_values<OverriddenMask>(
+ value_for<n::mask>(make_shared_ptr(new ERepositoryMask('r', "repository (overridden)", _imp->repository_mask))),
+ value_for<n::override_reason>(mro_overridden_by_user)
+ ))));
+
+ /* profile unless user */
+ if (_imp->profile_mask->value())
+ add_overridden_mask(make_shared_ptr(new OverriddenMask(
+ make_named_values<OverriddenMask>(
+ value_for<n::mask>(make_shared_ptr(new ERepositoryMask('p', "profile (overridden)", _imp->profile_mask))),
+ value_for<n::override_reason>(mro_overridden_by_user)
+ ))));
+
+ /* user */
+ std::tr1::shared_ptr<const Mask> user_mask(_imp->environment->mask_for_user(*this, true));
+ if (user_mask)
+ add_overridden_mask(make_shared_ptr(new OverriddenMask(
+ make_named_values<OverriddenMask>(
+ value_for<n::mask>(user_mask),
+ value_for<n::override_reason>(mro_overridden_by_user)
+ ))));
+
+ }
/* break portage */
std::tr1::shared_ptr<const Mask> breaks_mask(_imp->environment->mask_for_breakage(*this));
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index f8c0920..4959172 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 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
@@ -38,6 +38,7 @@
#include <paludis/util/hashes.hh>
#include <paludis/util/tribool.hh>
#include <paludis/util/wrapped_output_iterator.hh>
+#include <paludis/util/make_named_values.hh>
#include <map>
#include <list>
#include <sstream>
@@ -914,10 +915,20 @@ FakePackageID::need_masks_added() const
if (! _imp->env->unmasked_by_user(*this))
{
- std::tr1::shared_ptr<const Mask> user_mask(_imp->env->mask_for_user(*this));
+ std::tr1::shared_ptr<const Mask> user_mask(_imp->env->mask_for_user(*this, false));
if (user_mask)
add_mask(user_mask);
}
+ else
+ {
+ std::tr1::shared_ptr<const Mask> user_mask(_imp->env->mask_for_user(*this, true));
+ if (user_mask)
+ add_overridden_mask(make_shared_ptr(new OverriddenMask(
+ make_named_values<OverriddenMask>(
+ value_for<n::mask>(user_mask),
+ value_for<n::override_reason>(mro_overridden_by_user)
+ ))));
+ }
std::tr1::shared_ptr<const Mask> breaks_mask(_imp->env->mask_for_breakage(*this));
if (breaks_mask)
diff --git a/paludis/repositories/gems/gem_specification.cc b/paludis/repositories/gems/gem_specification.cc
index 3d0420d..86c08b0 100644
--- a/paludis/repositories/gems/gem_specification.cc
+++ b/paludis/repositories/gems/gem_specification.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 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
@@ -22,6 +22,7 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/repository.hh>
@@ -29,6 +30,7 @@
#include <paludis/action.hh>
#include <paludis/environment.hh>
#include <paludis/literal_metadata_key.hh>
+#include <paludis/mask.hh>
#include <tr1/functional>
using namespace paludis;
@@ -584,10 +586,20 @@ GemSpecification::need_masks_added() const
if (! _imp->environment->unmasked_by_user(*this))
{
/* user */
- std::tr1::shared_ptr<const Mask> user_mask(_imp->environment->mask_for_user(*this));
+ std::tr1::shared_ptr<const Mask> user_mask(_imp->environment->mask_for_user(*this, false));
if (user_mask)
add_mask(user_mask);
}
+ else
+ {
+ std::tr1::shared_ptr<const Mask> user_mask(_imp->environment->mask_for_user(*this, true));
+ if (user_mask)
+ add_overridden_mask(make_shared_ptr(new OverriddenMask(
+ make_named_values<OverriddenMask>(
+ value_for<n::mask>(user_mask),
+ value_for<n::override_reason>(mro_overridden_by_user)
+ ))));
+ }
/* break portage */
std::tr1::shared_ptr<const Mask> breaks_mask(_imp->environment->mask_for_breakage(*this));
diff --git a/python/additional_tests.cc b/python/additional_tests.cc
index 30b7e47..b116913 100644
--- a/python/additional_tests.cc
+++ b/python/additional_tests.cc
@@ -57,7 +57,7 @@ namespace environment
e.mask_for_breakage(*pid);
- e.mask_for_user(*pid);
+ e.mask_for_user(*pid, false);
bool PALUDIS_ATTRIBUTE((unused)) b4(e.unmasked_by_user(*pid));
diff --git a/python/environment.cc b/python/environment.cc
index ba1732d..fe15bd8 100644
--- a/python/environment.cc
+++ b/python/environment.cc
@@ -93,13 +93,13 @@ class EnvironmentImplementationWrapper :
throw PythonMethodNotImplemented("EnvironmentImplementation", "mask_for_breakage");
}
- virtual const std::tr1::shared_ptr<const Mask> mask_for_user(const PackageID & p) const
+ virtual const std::tr1::shared_ptr<const Mask> mask_for_user(const PackageID & p, const bool b) const
PALUDIS_ATTRIBUTE((warn_unused_result))
{
Lock l(get_mutex());
if (bp::override f = get_override("mask_for_user"))
- return f(boost::cref(p));
+ return f(boost::cref(p), b);
else
throw PythonMethodNotImplemented("EnvironmentImplementation", "mask_for_user");
}
@@ -571,9 +571,10 @@ void expose_environment()
)
.def("mask_for_user", bp::pure_virtual(&EnvImp::mask_for_user),
- "mask_for_user(PackageID) -> Mask\n"
+ "mask_for_user(PackageID, bool) -> Mask\n"
"Do we have a 'user' mask for a particular package?\n\n"
- "Returns None if no."
+ "Returns None if no. The second parameter should be true if the mask will be overridden "
+ "and false otherwise."
)
.def("unmasked_by_user", bp::pure_virtual(&EnvImp::unmasked_by_user),
diff --git a/python/environment_TEST.py b/python/environment_TEST.py
index 419a446..8155302 100755
--- a/python/environment_TEST.py
+++ b/python/environment_TEST.py
@@ -103,7 +103,7 @@ class TestCase_04_Environment_subclassingd(unittest.TestCase):
def mask_for_breakage(self, pid):
return UserMask()
- def mask_for_user(self, pid):
+ def mask_for_user(self, pid, b):
return UserMask()
def unmasked_by_user(self, pid):
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index 4cc400f..d602e1c 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 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
@@ -217,6 +217,19 @@ ConsoleQueryTask::display_versions_by_repository(const PackageDepSpec &,
right_column.append(render_as_masked("(" + (*e)->canonical_form(idcf_version) + ")" + reasons));
}
+ {
+ std::string reasons;
+ for (PackageID::OverriddenMasksConstIterator m((*e)->begin_overridden_masks()), m_end((*e)->end_overridden_masks()) ;
+ m != m_end ; ++m)
+ {
+ reasons.append(stringify((*m)->mask()->key()));
+ _imp->masks_to_explain->insert((*m)->mask()->key(), (*m)->mask()->description());
+ }
+
+ if (! reasons.empty())
+ right_column.append(render_as_visible("(" + reasons + ")"));
+ }
+
if (**e == *display_entry)
right_column.append("*");
right_column.append(" ");