aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-28 17:14:38 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-28 17:14:38 +0000
commit98cfd6c8dd55506cfd4e8e74ace402832ca26c7d (patch)
treeb6daf2870d660b76baf9ccdb3d4f0c3137599155
parentedc76a54cbcc260e614271645b32b2affb775ce3 (diff)
downloadpaludis-98cfd6c8dd55506cfd4e8e74ace402832ca26c7d.tar.gz
paludis-98cfd6c8dd55506cfd4e8e74ace402832ca26c7d.tar.xz
Add tagging to uninstall unused
-rw-r--r--paludis/dep_list/uninstall_list.cc36
-rw-r--r--paludis/dep_list/uninstall_list.hh7
-rw-r--r--paludis/dep_list/uninstall_list.sr6
-rw-r--r--src/paludis/uninstall.cc42
4 files changed, 71 insertions, 20 deletions
diff --git a/paludis/dep_list/uninstall_list.cc b/paludis/dep_list/uninstall_list.cc
index c7cf0a6..85b2df8 100644
--- a/paludis/dep_list/uninstall_list.cc
+++ b/paludis/dep_list/uninstall_list.cc
@@ -160,21 +160,26 @@ UninstallList::~UninstallList()
}
void
-UninstallList::add(const PackageDatabaseEntry & e)
+UninstallList::add(const PackageDatabaseEntry & e, const PackageDatabaseEntry * const t)
{
- if (_imp->uninstall_list.end() != std::find_if(_imp->uninstall_list.begin(),
- _imp->uninstall_list.end(), MatchUninstallListEntry(e)))
+ std::list<UninstallListEntry>::iterator i;
+ if (_imp->uninstall_list.end() != ((i = std::find_if(_imp->uninstall_list.begin(),
+ _imp->uninstall_list.end(), MatchUninstallListEntry(e)))))
+ {
+ if (t)
+ i->tags->insert(DepTag::Pointer(new DependencyDepTag(*t)));
+
return;
+ }
Context context("When adding '" + stringify(e) + "' to the uninstall list:");
- add_package(e);
+ add_package(e, t);
if (_imp->options.with_dependencies)
add_dependencies(e);
- remove_package(e);
- add_package(e);
+ move_package_to_end(e);
if (_imp->options.with_unused_dependencies)
add_unused_dependencies();
@@ -208,7 +213,7 @@ UninstallList::add_unused()
for (PackageDatabaseEntryCollection::Iterator i(unused->begin()),
i_end(unused->end()) ; i != i_end ; ++i)
- add_package(*i);
+ add_package(*i, 0);
}
UninstallList::Iterator
@@ -230,25 +235,30 @@ UninstallListOptions::UninstallListOptions() :
}
void
-UninstallList::add_package(const PackageDatabaseEntry & e)
+UninstallList::add_package(const PackageDatabaseEntry & e, const PackageDatabaseEntry * t)
{
Context context("When adding package '" + stringify(e) + "' to the uninstall list:");
VersionMetadata::ConstPointer m(_imp->env->package_database()->fetch_repository(
e.repository)->version_metadata(e.name, e.version));
- _imp->uninstall_list.push_back(UninstallListEntry(e, m->get_virtual_interface()));
+ std::list<UninstallListEntry>::iterator i(_imp->uninstall_list.insert(
+ _imp->uninstall_list.end(), UninstallListEntry(
+ e, m->get_virtual_interface(), SortedCollection<DepTag::Pointer>::Pointer(
+ new SortedCollection<DepTag::Pointer>::Concrete))));
+ if (t)
+ i->tags->insert(DepTag::Pointer(new DependencyDepTag(*t)));
}
void
-UninstallList::remove_package(const PackageDatabaseEntry & e)
+UninstallList::move_package_to_end(const PackageDatabaseEntry & e)
{
Context context("When removing package '" + stringify(e) + "' from the uninstall list:");
std::list<UninstallListEntry>::iterator i(std::find_if(_imp->uninstall_list.begin(),
_imp->uninstall_list.end(), MatchUninstallListEntry(e)));
if (_imp->uninstall_list.end() != i)
- _imp->uninstall_list.erase(i);
+ _imp->uninstall_list.splice(_imp->uninstall_list.end(), _imp->uninstall_list, i);
}
PackageDatabaseEntryCollection::ConstPointer
@@ -417,7 +427,7 @@ UninstallList::add_unused_dependencies()
_imp->uninstall_list.end(), MatchUninstallListEntry(*i)))
continue;
- add_package(*i);
+ add_package(*i, 0);
added = true;
}
}
@@ -454,7 +464,7 @@ UninstallList::add_dependencies(const PackageDatabaseEntry & e)
Log::get_instance()->message(ll_debug, lc_context, "Adding '" + stringify(*i) +
"' because it depends upon '" + stringify(e) + "'");
- add(*i);
+ add(*i, &e);
}
}
diff --git a/paludis/dep_list/uninstall_list.hh b/paludis/dep_list/uninstall_list.hh
index ebe7cc2..a7eb2af 100644
--- a/paludis/dep_list/uninstall_list.hh
+++ b/paludis/dep_list/uninstall_list.hh
@@ -24,6 +24,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/sr.hh>
#include <paludis/package_database_entry.hh>
+#include <paludis/dep_tag.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -38,8 +39,8 @@ namespace paludis
public InstantiationPolicy<UninstallList, instantiation_method::NonCopyableTag>
{
private:
- void add_package(const PackageDatabaseEntry &);
- void remove_package(const PackageDatabaseEntry &);
+ void add_package(const PackageDatabaseEntry &, const PackageDatabaseEntry *);
+ void move_package_to_end(const PackageDatabaseEntry &);
void add_unused_dependencies();
void add_dependencies(const PackageDatabaseEntry &);
PackageDatabaseEntryCollection::ConstPointer collect_depped_upon(
@@ -53,7 +54,7 @@ namespace paludis
UninstallListOptions & options;
- void add(const PackageDatabaseEntry &);
+ void add(const PackageDatabaseEntry &, const PackageDatabaseEntry * const = 0);
void add_unused();
typedef libwrapiter::ForwardIterator<UninstallList, const UninstallListEntry> Iterator;
diff --git a/paludis/dep_list/uninstall_list.sr b/paludis/dep_list/uninstall_list.sr
index 940bdf6..ad6d5ae 100644
--- a/paludis/dep_list/uninstall_list.sr
+++ b/paludis/dep_list/uninstall_list.sr
@@ -3,8 +3,9 @@
make_class_UninstallListOptions()
{
- key with_unused_dependencies bool;
- key with_dependencies bool;
+ key with_unused_dependencies bool
+ key with_dependencies bool
+
extra_constructors <<END
UninstallListOptions();
END
@@ -26,6 +27,7 @@ make_class_UninstallListEntry()
{
key package PackageDatabaseEntry
key skip_uninstall bool
+ key tags "SortedCollection<DepTag::Pointer>::Pointer"
allow_named_args
diff --git a/src/paludis/uninstall.cc b/src/paludis/uninstall.cc
index ec25fbc..04342b9 100644
--- a/src/paludis/uninstall.cc
+++ b/src/paludis/uninstall.cc
@@ -77,10 +77,48 @@ namespace
virtual void on_display_unmerge_list_entry(const UninstallListEntry & d)
{
if (d.skip_uninstall)
- return;
+ if (CommandLine::get_instance()->a_show_install_reasons.argument() != "full")
+ return;
- cout << "* " << colour(cl_package_name, stringify(d.package)) << endl;
+ cout << "* " << colour(d.skip_uninstall ? cl_unimportant : cl_package_name, stringify(d.package));
++_count;
+
+ if ((CommandLine::get_instance()->a_show_install_reasons.argument() == "summary") ||
+ (CommandLine::get_instance()->a_show_install_reasons.argument() == "full"))
+ {
+ std::string deps;
+ unsigned count(0), max_count;
+ if (CommandLine::get_instance()->a_show_install_reasons.argument() == "summary")
+ max_count = 3;
+ else
+ max_count = std::numeric_limits<long>::max();
+
+ for (SortedCollection<DepTag::Pointer>::Iterator
+ tag(d.tags->begin()),
+ tag_end(d.tags->end()) ;
+ tag != tag_end ; ++tag)
+ {
+ if ((*tag)->category() != "dependency")
+ continue;
+
+ if (++count < max_count)
+ {
+ deps.append((*tag)->short_text());
+ deps.append(", ");
+ }
+ }
+ if (! deps.empty())
+ {
+ if (count >= max_count)
+ deps.append(stringify(count - max_count + 1) + " more, ");
+
+ deps.erase(deps.length() - 2);
+ cout << " " << colour(d.skip_uninstall ? cl_unimportant : cl_tag,
+ "<" + deps + ">");
+ }
+ }
+
+ cout << endl;
}
virtual void on_uninstall_all_pre()