From 83347bca429d93d8b79315c73f521e8f93798aa3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Kupec?= Date: Mon, 11 Oct 2010 09:33:22 +0200 Subject: [PATCH] Version for multiver. pkgs in summary (bnc #644820) Not only show version if multiple version of the same package is shown in one summary category, but wherever a package which has multiple versions (to be) installed is shown. --- src/Summary.cc | 75 +++++++++++++++++++++++++++++++++------------------------- src/Summary.h | 5 ++++ 2 files changed, 48 insertions(+), 32 deletions(-) diff --git a/src/Summary.cc b/src/Summary.cc index cdcfcd3..518df2c 100644 --- a/src/Summary.cc +++ b/src/Summary.cc @@ -273,6 +273,18 @@ void Summary::readPool(const zypp::ResPool & pool) ++it; } + // find multi-version packages, which actually have mult. versions installed + const set & multies = ZConfig::instance().multiversionSpec(); + for_(name, multies.begin(), multies.end()) + { + ui::Selectable::Ptr s = pool.proxy().lookup(ResKind::package, *name); + bool got_multi = s && ( + s->installedSize() > 1 || + (s->installedSize() == 1 && s->toInstall()) ); + if (got_multi) + multi_installed.insert(*name); + } + m.stop(); } @@ -316,37 +328,29 @@ unsigned Summary::packagesToDowngrade() const void Summary::writeResolvableList(ostream & out, const ResPairSet & resolvables) { - // find multi-version packages - map dupes; - // no need to do this if SHOW_VERSION is on - if (!(_viewop & SHOW_VERSION)) - { - for_(resit, resolvables.begin(), resolvables.end()) - dupes[resit->second->name()]++; - // remove the single-versions from the map - for (map::iterator it = dupes.begin(); it != dupes.end(); /**/) - { - if (it->second == 1) - dupes.erase(it++); // postfix! Incrementing before erase - else - ++it; - } - } - if ((_viewop & DETAILS) == 0) { ostringstream s; for (ResPairSet::const_iterator resit = resolvables.begin(); resit != resolvables.end(); ++resit) - // name + { + // name s << (resit->second->kind() == ResKind::product ? - resit->second->summary() : - resit->second->name()) - // version (if multiple versions are present) - << (dupes.find(resit->second->name()) != dupes.end() ? - string("-") + resit->second->edition().asString() : - string()) - << " "; + resit->second->summary() : + resit->second->name()); + + // version (if multiple versions are present) + if (!(_viewop & SHOW_VERSION) && multi_installed.find(resit->second->name()) != multi_installed.end()) + { + if (resit->first && resit->first->edition() != resit->second->edition()) + s << "-" << resit->first->edition().asString() + << "->" << resit->second->edition().asString(); + else + s << "-" << resit->second->edition().asString(); + } + + s << " "; + } mbs_write_wrapped(out, s.str(), 2, _wrap_width); out << endl; return; @@ -359,14 +363,21 @@ void Summary::writeResolvableList(ostream & out, const ResPairSet & resolvables) { TableRow tr; - // name - tr << (resit->second->kind() == ResKind::product ? + string name = (resit->second->kind() == ResKind::product ? resit->second->summary() : - resit->second->name()) + - // version (if multiple versions are present) - (dupes.find(resit->second->name()) != dupes.end() && !(_viewop & SHOW_VERSION) ? - string("-") + resit->second->edition().asString() : - string()); + resit->second->name()); + + // version (if multiple versions are present) + if (!(_viewop & SHOW_VERSION) && multi_installed.find(resit->second->name()) != multi_installed.end()) + { + if (resit->first && resit->first->edition() != resit->second->edition()) + name += string("-") + resit->first->edition().asString() + + "->" + resit->second->edition().asString(); + else + name += string("-") + resit->second->edition().asString(); + } + + tr << name; if (_viewop & SHOW_VERSION) { diff --git a/src/Summary.h b/src/Summary.h index e63c36f..8e55f61 100644 --- a/src/Summary.h +++ b/src/Summary.h @@ -14,6 +14,7 @@ #include "zypp/base/PtrTypes.h" #include "zypp/ByteCount.h" +#include "zypp/base/DefaultIntegral.h" #include "zypp/ResObject.h" #include "zypp/ResPool.h" @@ -144,6 +145,10 @@ private: /** objects from previous lists that need additional customer contract */ KindToResPairSet support_needacc; + /** names of packages which have multiple versions (to-be-)installed */ + std::set multi_installed; + + /** \name For weak deps info. * @{ */ -- 2.7.4