aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/clients/cave/cmd_display_resolution.cc10
-rw-r--r--src/clients/cave/cmd_print_id_masks.cc40
-rw-r--r--src/clients/cave/cmd_show.cc19
-rw-r--r--src/output/mask_displayer.cc18
4 files changed, 48 insertions, 39 deletions
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index dbb12adf6..a9ef2afce 100755
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -1026,16 +1026,16 @@ namespace
{
cout << fuc(fs_masked_by(), fv<'i'>(indent), fv<'c'>(colour), fv<'d'>(m.description()));
MaskedByKeyVisitor v{env, id, indent + " "};
- if (m.mask_key())
- m.mask_key()->accept(v);
+ if (! m.mask_key_name().empty())
+ (*id->find_metadata(m.mask_key_name()))->accept(v);
}
void visit(const UnacceptedMask & m) const
{
cout << fuc(fs_masked_by(), fv<'i'>(indent), fv<'c'>(colour), fv<'d'>(m.description()));
MaskedByKeyVisitor v{env, id, indent + " "};
- if (m.unaccepted_key())
- m.unaccepted_key()->accept(v);
+ if (! m.unaccepted_key_name().empty())
+ (*id->find_metadata(m.unaccepted_key_name()))->accept(v);
}
void visit(const UnsupportedMask & m) const
@@ -1046,7 +1046,7 @@ namespace
void visit(const AssociationMask & m) const
{
cout << fuc(fs_masked_by_explanation(), fv<'i'>(indent), fv<'c'>(colour), fv<'d'>(m.description()),
- fv<'x'>("associated package '" + stringify(*m.associated_package()) + "'"));
+ fv<'x'>("associated package '" + stringify(m.associated_package_spec()) + "'"));
}
};
diff --git a/src/clients/cave/cmd_print_id_masks.cc b/src/clients/cave/cmd_print_id_masks.cc
index 1937eb6aa..9664c11d9 100644
--- a/src/clients/cave/cmd_print_id_masks.cc
+++ b/src/clients/cave/cmd_print_id_masks.cc
@@ -103,33 +103,34 @@ namespace
struct GetInfo
{
- const std::pair<std::shared_ptr<const MetadataKey>, std::string> visit(const UserMask &) const
+ const std::pair<std::string, std::string> visit(const UserMask &) const
{
- return std::make_pair(make_null_shared_ptr(), "");
+ return std::make_pair("", "");
}
- const std::pair<std::shared_ptr<const MetadataKey>, std::string> visit(const UnacceptedMask & m) const
+ const std::pair<std::string, std::string> visit(const UnacceptedMask & m) const
{
- return std::make_pair(m.unaccepted_key(), "");
+ return std::make_pair(m.unaccepted_key_name(), "");
}
- const std::pair<std::shared_ptr<const MetadataKey>, std::string> visit(const RepositoryMask & m) const
+ const std::pair<std::string, std::string> visit(const RepositoryMask & m) const
{
- return std::make_pair(m.mask_key(), "");
+ return std::make_pair(m.mask_key_name(), "");
}
- const std::pair<std::shared_ptr<const MetadataKey>, std::string> visit(const UnsupportedMask &) const
+ const std::pair<std::string, std::string> visit(const UnsupportedMask &) const
{
- return std::make_pair(make_null_shared_ptr(), "");
+ return std::make_pair("", "");
}
- const std::pair<std::shared_ptr<const MetadataKey>, std::string> visit(const AssociationMask & m) const
+ const std::pair<std::string, std::string> visit(const AssociationMask & m) const
{
- return std::make_pair(make_null_shared_ptr(), stringify(*m.associated_package()));
+ return std::make_pair("", stringify(m.associated_package_spec()));
}
};
void do_one_mask(
+ const std::shared_ptr<const PackageID> & id,
const std::shared_ptr<const Mask> & mask,
const MaskOverrideReason & override,
const PrintIDMasksCommandLine & cmdline
@@ -139,12 +140,15 @@ namespace
m->insert('k', std::string(1, mask->key()));
m->insert('d', mask->description());
- std::pair<std::shared_ptr<const MetadataKey>, std::string> info(
- mask->accept_returning<std::pair<std::shared_ptr<const MetadataKey>, std::string> >(GetInfo()));
- m->insert('r', info.first ? info.first->raw_name() : "");
- m->insert('=', info.first ? "=" : "");
- m->insert('h', info.first ? info.first->human_name() : "");
- m->insert('v', info.first ? format_plain_metadata_key_value(info.first) : info.second);
+ auto info(mask->accept_returning<std::pair<std::string, std::string> >(GetInfo()));
+ std::shared_ptr<const MetadataKey> info_key;
+ if (! info.first.empty())
+ info_key = *id->find_metadata(info.first);
+
+ m->insert('r', info_key ? info_key->raw_name() : "");
+ m->insert('=', info_key ? "=" : "");
+ m->insert('h', info_key ? info_key->human_name() : "");
+ m->insert('v', info_key ? format_plain_metadata_key_value(info_key) : info.second);
m->insert('(', last_mro == override ? "" : "(");
m->insert(')', last_mro == override ? "" : ")");
@@ -201,12 +205,12 @@ PrintIDMasksCommand::run(
if (! cmdline.a_no_active.specified())
for (PackageID::MasksConstIterator m((*i)->begin_masks()), m_end((*i)->end_masks()) ;
m != m_end ; ++m)
- do_one_mask(*m, last_mro, cmdline);
+ do_one_mask(*i, *m, last_mro, cmdline);
if (cmdline.a_overridden.specified())
for (PackageID::OverriddenMasksConstIterator m((*i)->begin_overridden_masks()), m_end((*i)->end_overridden_masks()) ;
m != m_end ; ++m)
- do_one_mask((*m)->mask(), (*m)->override_reason(), cmdline);
+ do_one_mask(*i, (*m)->mask(), (*m)->override_reason(), cmdline);
}
return EXIT_SUCCESS;
diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc
index e3e323b05..e4cdfa8d2 100644
--- a/src/clients/cave/cmd_show.cc
+++ b/src/clients/cave/cmd_show.cc
@@ -967,12 +967,15 @@ namespace
struct MaskDisplayer
{
const std::shared_ptr<const Environment> env;
+ const std::shared_ptr<const PackageID> id;
const ShowCommandLine & cmdline;
const int indent;
std::ostream & out;
- MaskDisplayer(const std::shared_ptr<const Environment> & e, const ShowCommandLine & c, const int i, std::ostream & o) :
+ MaskDisplayer(const std::shared_ptr<const Environment> & e,
+ const std::shared_ptr<const PackageID> & d, const ShowCommandLine & c, const int i, std::ostream & o) :
env(e),
+ id(d),
cmdline(c),
indent(i),
out(o)
@@ -981,10 +984,10 @@ namespace
void visit(const UnacceptedMask & m)
{
- if (m.unaccepted_key())
+ if (! m.unaccepted_key_name().empty())
{
InfoDisplayer i(env, cmdline, indent, false, make_null_shared_ptr(), make_null_shared_ptr(), false, out);
- m.unaccepted_key()->accept(i);
+ (*id->find_metadata(m.unaccepted_key_name()))->accept(i);
}
else
{
@@ -1016,7 +1019,7 @@ namespace
out << fuc(
(cmdline.a_raw_names.specified() ? fs_metadata_value_raw() : fs_metadata_value_human()),
fv<'s'>(cmdline.a_raw_names.specified() ? stringify(m.key()) : "by " + m.description()),
- fv<'v'>(stringify(*m.associated_package())),
+ fv<'v'>(stringify(m.associated_package_spec())),
fv<'i'>(std::string(indent, ' ')),
fv<'b'>(""),
fv<'p'>("")
@@ -1037,10 +1040,10 @@ namespace
void visit(const RepositoryMask & m)
{
- if (m.mask_key())
+ if (! m.mask_key_name().empty())
{
InfoDisplayer i(env, cmdline, indent, false, make_null_shared_ptr(), make_null_shared_ptr(), false, out);
- m.mask_key()->accept(i);
+ (*id->find_metadata(m.mask_key_name()))->accept(i);
}
else
{
@@ -1097,14 +1100,14 @@ namespace
if (best->masked())
{
out << fuc(fs_package_id_masks(), fv<'s'>("Masked"));
- MaskDisplayer d(env, cmdline, 2, out);
+ MaskDisplayer d(env, best, cmdline, 2, out);
std::for_each(indirect_iterator(best->begin_masks()), indirect_iterator(best->end_masks()), accept_visitor(d));
}
if (best->begin_overridden_masks() != best->end_overridden_masks())
{
out << fuc(fs_package_id_masks_overridden(), fv<'s'>("Overridden Masks"));
- MaskDisplayer d(env, cmdline, 2, out);
+ MaskDisplayer d(env, best, cmdline, 2, out);
for (PackageID::OverriddenMasksConstIterator m(best->begin_overridden_masks()), m_end(best->end_overridden_masks()) ;
m != m_end ; ++m)
(*m)->mask()->accept(d);
diff --git a/src/output/mask_displayer.cc b/src/output/mask_displayer.cc
index 3b0a68315..765232dc8 100644
--- a/src/output/mask_displayer.cc
+++ b/src/output/mask_displayer.cc
@@ -29,6 +29,8 @@
#include <paludis/util/timestamp.hh>
#include <paludis/name.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/package_id.hh>
+#include <paludis/dep_spec.hh>
#include <sstream>
using namespace paludis;
@@ -241,10 +243,10 @@ MaskDisplayer::visit(const UnacceptedMask & m)
if (_imp->want_description)
_imp->s << m.description() << " (";
- if (m.unaccepted_key())
+ if (! m.unaccepted_key_name().empty())
{
KeyPrettyPrinter k(_imp->env, _imp->id);
- m.unaccepted_key()->accept(k);
+ (*_imp->id->find_metadata(m.unaccepted_key_name()))->accept(k);
_imp->s << k.s.str();
}
@@ -265,19 +267,19 @@ MaskDisplayer::visit(const RepositoryMask & m)
{
_imp->s << m.description();
- if (m.mask_key())
+ if (! m.mask_key_name().empty())
{
KeyPrettyPrinter k(_imp->env, _imp->id);
- m.mask_key()->accept(k);
+ (*_imp->id->find_metadata(m.mask_key_name()))->accept(k);
_imp->s << " (" << k.s.str() << ")";
}
}
else
{
- if (m.mask_key())
+ if (! m.mask_key_name().empty())
{
KeyPrettyPrinter k(_imp->env, _imp->id);
- m.mask_key()->accept(k);
+ (*_imp->id->find_metadata(m.mask_key_name()))->accept(k);
_imp->s << k.s.str();
}
else
@@ -298,8 +300,8 @@ void
MaskDisplayer::visit(const AssociationMask & m)
{
if (_imp->want_description)
- _imp->s << m.description() << " (associated package '" << *m.associated_package() << "')";
+ _imp->s << m.description() << " (associated package '" << m.associated_package_spec() << "')";
else
- _imp->s << *m.associated_package();
+ _imp->s << m.associated_package_spec();
}