aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-13 00:02:11 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-13 00:02:11 +0100
commit490584b8c10f4e0c5610f7636dd809e46248bd53 (patch)
treeebf2ddc908932255ca1f9a5c9dd2cea1cbec1e80
parentbb659211a59d0e7a10d014a0efe15578c35fc49b (diff)
downloadpaludis-490584b8c10f4e0c5610f7636dd809e46248bd53.tar.gz
paludis-490584b8c10f4e0c5610f7636dd809e46248bd53.tar.xz
better notifier output
-rw-r--r--paludis/notifier_callback.cc11
-rw-r--r--paludis/notifier_callback.hh8
-rw-r--r--paludis/repositories/e/ebuild_id.cc3
-rw-r--r--src/clients/cave/cmd_resolve_display_callback.cc90
-rw-r--r--src/clients/cave/cmd_resolve_display_callback.hh21
5 files changed, 108 insertions, 25 deletions
diff --git a/paludis/notifier_callback.cc b/paludis/notifier_callback.cc
index 7425bbc..613fad6 100644
--- a/paludis/notifier_callback.cc
+++ b/paludis/notifier_callback.cc
@@ -24,6 +24,17 @@
using namespace paludis;
+NotifierCallbackGeneratingMetadataEvent::NotifierCallbackGeneratingMetadataEvent(const RepositoryName & r) :
+ _repo(r)
+{
+}
+
+const RepositoryName
+NotifierCallbackGeneratingMetadataEvent::repository() const
+{
+ return _repo;
+}
+
namespace paludis
{
template <>
diff --git a/paludis/notifier_callback.hh b/paludis/notifier_callback.hh
index 5709d84..e33ac11 100644
--- a/paludis/notifier_callback.hh
+++ b/paludis/notifier_callback.hh
@@ -24,6 +24,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/simple_visitor.hh>
#include <paludis/util/type_list.hh>
+#include <paludis/name.hh>
#include <paludis/environment-fwd.hh>
namespace paludis
@@ -39,6 +40,13 @@ namespace paludis
public NotifierCallbackEvent,
public ImplementAcceptMethods<NotifierCallbackEvent, NotifierCallbackGeneratingMetadataEvent>
{
+ private:
+ const RepositoryName _repo;
+
+ public:
+ NotifierCallbackGeneratingMetadataEvent(const RepositoryName & r);
+
+ const RepositoryName repository() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
class PALUDIS_VISIBLE NotifierCallbackResolverStepEvent :
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 12c6954..10470af 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -225,7 +225,8 @@ EbuildID::need_keys_added() const
Log::get_instance()->message("e.ebuild.cache.no_usable", ll_qa, lc_no_context)
<< "No usable cache entry for '" + canonical_form(idcf_full);
- _imp->environment->trigger_notifier_callback(NotifierCallbackGeneratingMetadataEvent());
+ _imp->environment->trigger_notifier_callback(NotifierCallbackGeneratingMetadataEvent(
+ _imp->repository->name()));
_imp->eapi = EAPIData::get_instance()->eapi_from_string(_imp->guessed_eapi);
diff --git a/src/clients/cave/cmd_resolve_display_callback.cc b/src/clients/cave/cmd_resolve_display_callback.cc
index e22d0e3..6f00051 100644
--- a/src/clients/cave/cmd_resolve_display_callback.cc
+++ b/src/clients/cave/cmd_resolve_display_callback.cc
@@ -20,15 +20,32 @@
#include "cmd_resolve_display_callback.hh"
#include <paludis/notifier_callback.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
#include <iostream>
+#include <map>
using namespace paludis;
using namespace cave;
+namespace paludis
+{
+ template <>
+ struct Implementation<DisplayCallback>
+ {
+ mutable Mutex mutex;
+ mutable unsigned width;
+ mutable std::map<std::string, int> metadata, steps;
+
+ Implementation() :
+ width(0)
+ {
+ }
+ };
+}
+
+
DisplayCallback::DisplayCallback() :
- width(0),
- metadata(0),
- steps(0)
+ PrivateImplementationPattern<DisplayCallback>(new Implementation<DisplayCallback>)
{
std::cout << "Resolving: " << std::flush;
}
@@ -45,18 +62,18 @@ DisplayCallback::operator() (const NotifierCallbackEvent & event) const
}
void
-DisplayCallback::visit(const NotifierCallbackGeneratingMetadataEvent &) const
+DisplayCallback::visit(const NotifierCallbackGeneratingMetadataEvent & e) const
{
- Lock lock(mutex);
- ++metadata;
+ Lock lock(_imp->mutex);
+ ++_imp->metadata.insert(std::make_pair(stringify(e.repository()), 0)).first->second;
update();
}
void
DisplayCallback::visit(const NotifierCallbackResolverStepEvent &) const
{
- Lock lock(mutex);
- ++steps;
+ Lock lock(_imp->mutex);
+ ++_imp->steps.insert(std::make_pair("steps", 0)).first->second;
update();
}
@@ -64,17 +81,62 @@ void
DisplayCallback::update() const
{
std::string s;
- if (0 != steps)
- s.append("steps: " + stringify(steps));
+ if (! _imp->steps.empty())
+ {
+ for (std::map<std::string, int>::const_iterator i(_imp->steps.begin()), i_end(_imp->steps.end()) ;
+ i != i_end ; ++i)
+ {
+ if (! s.empty())
+ s.append(", ");
+
+ s.append(stringify(i->second) + " " + i->first);
+ }
+ }
- if (0 != metadata)
+ if (! _imp->metadata.empty())
{
+ std::multimap<int, std::string> biggest;
+ for (std::map<std::string, int>::const_iterator i(_imp->metadata.begin()), i_end(_imp->metadata.end()) ;
+ i != i_end ; ++i)
+ biggest.insert(std::make_pair(i->second, i->first));
+
+ int t(0), n(0);
+ std::string ss;
+ for (std::multimap<int, std::string>::const_reverse_iterator i(biggest.rbegin()), i_end(biggest.rend()) ;
+ i != i_end ; ++i)
+ {
+ ++n;
+
+ if (n == 4)
+ {
+ ss.append(", ...");
+ break;
+ }
+
+ if (n < 4)
+ {
+ if (! ss.empty())
+ ss.append(", ");
+
+ ss.append(stringify(i->first) + " " + i->second);
+ }
+
+ t += i->first;
+ }
+
if (! s.empty())
s.append(", ");
- s.append("metadata: " + stringify(metadata) + " ");
+ s.append(stringify(t) + " metadata (" + ss + ")");
}
- std::cout << std::string(width, '\010') << s << std::flush;
- width = s.length();
+ std::cout << std::string(_imp->width, '\010') << s;
+
+ if (_imp->width > s.length())
+ std::cout
+ << std::string(_imp->width - s.length(), ' ')
+ << std::string(_imp->width - s.length(), '\010');
+
+ _imp->width = s.length();
+ std::cout << std::flush;
}
diff --git a/src/clients/cave/cmd_resolve_display_callback.hh b/src/clients/cave/cmd_resolve_display_callback.hh
index 8179a2c..bf5ab55 100644
--- a/src/clients/cave/cmd_resolve_display_callback.hh
+++ b/src/clients/cave/cmd_resolve_display_callback.hh
@@ -21,27 +21,28 @@
#define PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_RESOLVE_DISPLAY_CALLBACK_HH 1
#include <paludis/util/mutex.hh>
+#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/notifier_callback-fwd.hh>
namespace paludis
{
namespace cave
{
- struct DisplayCallback
+ struct DisplayCallback :
+ private PrivateImplementationPattern<DisplayCallback>
{
- mutable Mutex mutex;
- mutable int width, metadata, steps;
+ private:
+ void update() const;
- DisplayCallback();
- ~DisplayCallback();
+ public:
+ DisplayCallback();
+ ~DisplayCallback();
- void operator() (const NotifierCallbackEvent & event) const;
+ void operator() (const NotifierCallbackEvent & event) const;
- void visit(const NotifierCallbackGeneratingMetadataEvent &) const;
+ void visit(const NotifierCallbackGeneratingMetadataEvent &) const;
- void visit(const NotifierCallbackResolverStepEvent &) const;
-
- void update() const;
+ void visit(const NotifierCallbackResolverStepEvent &) const;
};
}
}