aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-07 20:03:47 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-07 20:03:47 +0000
commita2c1a3146931b3a52d18f98e32c99278a1ab0382 (patch)
treee861a94ba11c58a1d491ecf8fffaec1416edda59
parent65530572ad088c290b4eba463a38a4754560b002 (diff)
downloadpaludis-a2c1a3146931b3a52d18f98e32c99278a1ab0382.tar.gz
paludis-a2c1a3146931b3a52d18f98e32c99278a1ab0382.tar.xz
Tag support for the new deplist
-rwxr-xr-xmisc/make_sr.bash2
-rw-r--r--paludis/dep_list.cc63
-rw-r--r--paludis/dep_list.hh6
-rw-r--r--paludis/dep_tag.cc7
-rw-r--r--paludis/dep_tag.hh27
-rw-r--r--paludis/dep_tag.sr10
-rw-r--r--paludis/files.m42
-rw-r--r--src/paludis/install.cc21
8 files changed, 95 insertions, 43 deletions
diff --git a/misc/make_sr.bash b/misc/make_sr.bash
index 381c9fa..be98244 100755
--- a/misc/make_sr.bash
+++ b/misc/make_sr.bash
@@ -478,7 +478,7 @@ while read a ; do
echo "{"
for (( k = 0 ; k < ${#want_comparison_fields[@]} ; k++ )) ; do
w=${want_comparison_fields[${k}]}
- echo " switch (paludis::compare(${w}, other.${w}))"
+ echo " switch (paludis::compare(${w}, ${w//[^\*]}other.${w#\*}))"
echo " {"
echo " case -1:"
echo " return -1;"
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 75fb384..661d38e 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -124,12 +124,37 @@ namespace
{
}
- bool operator() (const DepListEntry & e) const
+ template <typename T_>
+ bool operator() (const T_ & e) const
{
return e.generation > g;
}
};
+ struct RemoveTagsWithGenerationGreaterThan
+ {
+ long g;
+
+ RemoveTagsWithGenerationGreaterThan(long gg) :
+ g(gg)
+ {
+ }
+
+ void operator() (DepListEntry & e) const
+ {
+ /* see EffSTL 9 for why this is so painful */
+ if (e.tags->empty())
+ return;
+ DepListEntryTags::Pointer t(new DepListEntryTags::Concrete);
+ GenerationGreaterThan pred(g);
+ for (DepListEntryTags::Iterator i(e.tags->begin()), i_end(e.tags->end()) ;
+ i != i_end ; ++i)
+ if (! pred(*i))
+ t->insert(*i);
+ std::swap(e.tags, t);
+ }
+ };
+
class DepListTransaction
{
protected:
@@ -156,7 +181,10 @@ namespace
~DepListTransaction()
{
if (! _committed)
+ {
_list.remove_if(GenerationGreaterThan(_initial_generation));
+ std::for_each(_list.begin(), _list.end(), RemoveTagsWithGenerationGreaterThan(_initial_generation));
+ }
}
};
@@ -332,10 +360,16 @@ DepList::AddVisitor::visit(const PackageDepAtom * const a)
*a, is_installed_only));
/* are we already on the merge list? */
- MergeList::const_iterator existing_merge_list_entry(std::find_if(d->_imp->merge_list.begin(),
+ MergeList::iterator existing_merge_list_entry(std::find_if(d->_imp->merge_list.begin(),
d->_imp->merge_list.end(), MatchDepListEntryAgainstPackageDepAtom(d->_imp->env, a)));
if (existing_merge_list_entry != d->_imp->merge_list.end())
{
+ /* tag it */
+ if (a->tag())
+ existing_merge_list_entry->tags->insert(DepTagEntry::create()
+ .tag(a->tag())
+ .generation(d->_imp->merge_list_generation));
+
/* have our deps been merged already, or is this a circular dep? */
if (dle_no_deps == existing_merge_list_entry->state)
{
@@ -370,8 +404,8 @@ DepList::AddVisitor::visit(const PackageDepAtom * const a)
break;
}
- /* no installable candidates. if we're already installed, that's ok,
- * otherwise error. */
+ /* no installable candidates. if we're already installed, that's ok (except for top level
+ * package targets), otherwise error. */
if (! best_visible_candidate)
{
if (already_installed->empty())
@@ -384,10 +418,11 @@ DepList::AddVisitor::visit(const PackageDepAtom * const a)
}
else
{
+ // todo: top level
Log::get_instance()->message(ll_warning, lc_context, "No visible packages matching '"
+ stringify(*a) + "', falling back to installed package '"
+ stringify(*already_installed->last()) + "'");
- d->add_already_installed_package(*already_installed->last());
+ d->add_already_installed_package(*already_installed->last(), a->tag());
return;
}
}
@@ -409,7 +444,7 @@ DepList::AddVisitor::visit(const PackageDepAtom * const a)
{
Log::get_instance()->message(ll_debug, lc_context, "Taking installed package '"
+ stringify(*already_installed_in_same_slot->last()) + "' over '" + stringify(*best_visible_candidate) + "'");
- d->add_already_installed_package(*already_installed_in_same_slot->last());
+ d->add_already_installed_package(*already_installed_in_same_slot->last(), a->tag());
return;
}
else
@@ -420,7 +455,7 @@ DepList::AddVisitor::visit(const PackageDepAtom * const a)
Log::get_instance()->message(ll_debug, lc_context, "No installed packages in SLOT '"
+ stringify(slot) + "', taking uninstalled package '" + stringify(*best_visible_candidate) + "'");
- d->add_package(*best_visible_candidate);
+ d->add_package(*best_visible_candidate, a->tag());
}
void
@@ -550,7 +585,7 @@ DepList::add(DepAtom::ConstPointer atom)
}
void
-DepList::add_package(const PackageDatabaseEntry & p)
+DepList::add_package(const PackageDatabaseEntry & p, DepTag::ConstPointer tag)
{
Context context("When adding package '" + stringify(p) + "':");
@@ -572,6 +607,11 @@ DepList::add_package(const PackageDatabaseEntry & p)
.already_installed(false))),
our_merge_entry_post_position(our_merge_entry_position);
+ if (tag)
+ our_merge_entry_position->tags->insert(DepTagEntry::create()
+ .generation(_imp->merge_list_generation)
+ .tag(tag));
+
Save<MergeList::const_iterator> save_current_merge_list_entry(&_imp->current_merge_list_entry,
our_merge_entry_position);
@@ -671,7 +711,7 @@ DepList::add_postdeps(DepAtom::ConstPointer d, const DepListDepsOption opt, cons
}
void
-DepList::add_already_installed_package(const PackageDatabaseEntry & p)
+DepList::add_already_installed_package(const PackageDatabaseEntry & p, DepTag::ConstPointer tag)
{
Context context("When adding installed package '" + stringify(p) + "':");
@@ -688,6 +728,11 @@ DepList::add_already_installed_package(const PackageDatabaseEntry & p)
.state(dle_has_pre_deps)
.already_installed(true)));
+ if (tag)
+ our_merge_entry->tags->insert(DepTagEntry::create()
+ .generation(_imp->merge_list_generation)
+ .tag(tag));
+
Save<MergeList::const_iterator> save_current_merge_list_entry(&_imp->current_merge_list_entry,
our_merge_entry);
diff --git a/paludis/dep_list.hh b/paludis/dep_list.hh
index a8c4b92..f87b833 100644
--- a/paludis/dep_list.hh
+++ b/paludis/dep_list.hh
@@ -76,8 +76,6 @@ namespace paludis
dle_has_all_deps
};
- typedef SortedCollection<DepTag::ConstPointer, DepTag::Comparator> DepListEntryTags;
-
#include <paludis/dep_list-sr.hh>
/**
@@ -215,8 +213,8 @@ namespace paludis
void add_in_role(DepAtom::ConstPointer, const std::string & role);
bool prefer_installed_over_uninstalled(const PackageDatabaseEntry &,
const PackageDatabaseEntry &);
- void add_package(const PackageDatabaseEntry &);
- void add_already_installed_package(const PackageDatabaseEntry &);
+ void add_package(const PackageDatabaseEntry &, DepTag::ConstPointer);
+ void add_already_installed_package(const PackageDatabaseEntry &, DepTag::ConstPointer);
void add_predeps(DepAtom::ConstPointer, const DepListDepsOption, const std::string &);
void add_postdeps(DepAtom::ConstPointer, const DepListDepsOption, const std::string &);
diff --git a/paludis/dep_tag.cc b/paludis/dep_tag.cc
index bd0ea03..1d76e4b 100644
--- a/paludis/dep_tag.cc
+++ b/paludis/dep_tag.cc
@@ -18,6 +18,7 @@
*/
#include "dep_tag.hh"
+#include <paludis/util/compare.hh>
/** \file
* Implementation for DepTag, DepTagCategory etc.
@@ -27,6 +28,8 @@
using namespace paludis;
+#include <paludis/dep_tag-sr.cc>
+
namespace
{
/**
@@ -95,7 +98,9 @@ NoSuchDepTagCategory::NoSuchDepTagCategory(const std::string & s) throw () :
{
}
-DepTag::DepTag()
+DepTag::DepTag() :
+ ComparisonPolicy<DepTag, comparison_mode::FullComparisonTag,
+ comparison_method::CompareByMemberFetchFunctionTag<std::string> >(&DepTag::short_text)
{
}
diff --git a/paludis/dep_tag.hh b/paludis/dep_tag.hh
index 7954f43..a91692c 100644
--- a/paludis/dep_tag.hh
+++ b/paludis/dep_tag.hh
@@ -32,6 +32,8 @@
#include <paludis/util/counted_ptr.hh>
#include <paludis/util/virtual_constructor.hh>
#include <paludis/util/exception.hh>
+#include <paludis/util/collection.hh>
+#include <paludis/util/sr.hh>
namespace paludis
{
@@ -136,7 +138,7 @@ namespace paludis
/**
* A DepTag can be associated with a PackageDepAtom, and is transferred
- * onto any associated DepListEntry instances.
+ * onto any associated DepListEntry instances.
*
* It is used for tagging dep list entries visually, for example to
* indicate an associated GLSA.
@@ -146,7 +148,10 @@ namespace paludis
class DepTag :
InstantiationPolicy<DepTag, instantiation_method::NonCopyableTag>,
public InternalCounted<DepTag>,
- public virtual VisitableInterface<DepTagVisitorTypes>
+ public virtual VisitableInterface<DepTagVisitorTypes>,
+ public ComparisonPolicy<DepTag,
+ comparison_mode::FullComparisonTag,
+ comparison_method::CompareByMemberFetchFunctionTag<std::string> >
{
protected:
/**
@@ -172,20 +177,8 @@ namespace paludis
virtual std::string category() const = 0;
/**
- * Used for comparisons in containers containing pointers to DepTag
- * instances.
- *
- * \ingroup grpdeptag
+ * Compare, by short_text only.
*/
- struct Comparator
- {
- /// Perform the comparison.
- bool operator() (const DepTag::ConstPointer & d1,
- const DepTag::ConstPointer & d2) const
- {
- return d1->short_text() < d2->short_text();
- }
- };
};
/**
@@ -240,6 +233,10 @@ namespace paludis
virtual std::string category() const;
};
+
+#include <paludis/dep_tag-sr.hh>
+
+ typedef SortedCollection<DepTagEntry> DepListEntryTags;
}
#endif
diff --git a/paludis/dep_tag.sr b/paludis/dep_tag.sr
new file mode 100644
index 0000000..2dfd21b
--- /dev/null
+++ b/paludis/dep_tag.sr
@@ -0,0 +1,10 @@
+make_class_DepTagEntry()
+{
+ key tag DepTag::ConstPointer
+ key generation long
+
+ allow_named_args
+ comparison_operators "all" "*tag"
+}
+
+
diff --git a/paludis/files.m4 b/paludis/files.m4
index cf1a608..8aaccc7 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -15,7 +15,7 @@ add(`dep_atom', `hh', `cc', `test')
add(`dep_atom_flattener', `hh', `cc')
add(`dep_atom_pretty_printer', `hh', `cc')
add(`dep_list', `hh', `cc', `test', `sr')
-add(`dep_tag', `hh', `cc')
+add(`dep_tag', `hh', `cc', `sr')
add(`ebin', `hh', `cc', `sr')
add(`ebuild', `hh', `cc', `sr')
add(`environment', `hh', `cc')
diff --git a/src/paludis/install.cc b/src/paludis/install.cc
index dab08b9..fd1c538 100644
--- a/src/paludis/install.cc
+++ b/src/paludis/install.cc
@@ -78,7 +78,7 @@ namespace
_upgrade_virtual_count, _downgrade_virtual_count,
_new_slot_virtual_count, _rebuild_virtual_count;
- std::set<DepTag::ConstPointer, DepTag::Comparator> _all_tags;
+ std::set<DepTagEntry> _all_tags;
public:
OurInstallTask(const DepListOptions & options) :
@@ -345,11 +345,9 @@ namespace
TagDisplayer tag_displayer;
std::set<std::string> tag_categories;
- std::transform(
- indirect_iterator<const DepTag>(_all_tags.begin()),
- indirect_iterator<const DepTag>(_all_tags.end()),
- std::inserter(tag_categories, tag_categories.begin()),
- std::mem_fun_ref(&DepTag::category));
+ for (std::set<DepTagEntry>::const_iterator a(_all_tags.begin()),
+ a_end(_all_tags.end()) ; a != a_end ; ++a)
+ tag_categories.insert(a->tag->category());
for (std::set<std::string>::iterator cat(tag_categories.begin()),
cat_end(tag_categories.end()) ; cat != cat_end ; ++cat)
@@ -362,13 +360,12 @@ namespace
if (! c->pre_text().empty())
cout << c->pre_text() << endl << endl;
- for (std::set<DepTag::ConstPointer, DepTag::Comparator>::const_iterator
- t(_all_tags.begin()), t_end(_all_tags.end()) ;
+ for (std::set<DepTagEntry>::const_iterator t(_all_tags.begin()), t_end(_all_tags.end()) ;
t != t_end ; ++t)
{
- if ((*t)->category() != *cat)
+ if (t->tag->category() != *cat)
continue;
- (*t)->accept(&tag_displayer);
+ t->tag->accept(&tag_displayer);
}
cout << endl;
@@ -496,13 +493,13 @@ namespace
if (! d.tags->empty())
{
std::string tag_titles;
- for (SortedCollection<DepTag::ConstPointer, DepTag::Comparator>::Iterator
+ for (SortedCollection<DepTagEntry>::Iterator
tag(d.tags->begin()),
tag_end(d.tags->end()) ;
tag != tag_end ; ++tag)
{
_all_tags.insert(*tag);
- tag_titles.append((*tag)->short_text());
+ tag_titles.append(tag->tag->short_text());
tag_titles.append(",");
}
tag_titles.erase(tag_titles.length() - 1);