From: Ján Kupec Date: Thu, 2 Apr 2009 13:15:11 +0000 (+0200) Subject: Write package counts in summary. X-Git-Tag: 1.2.6~93 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7d09740dd730dcbc627644d495047aa3d7854d0;p=platform%2Fupstream%2Fzypper.git Write package counts in summary. --- diff --git a/src/Summary.cc b/src/Summary.cc index 2900622..1f6bc38 100644 --- a/src/Summary.cc +++ b/src/Summary.cc @@ -607,6 +607,86 @@ void Summary::writeDownloadAndInstalledSizeSummary(ostream & out) out << endl; } +void Summary::writePackageCounts(ostream & out) +{ + if (!packagesToGetAndInstall() && !packagesToRemove()) + return; + + ostringstream s; + bool gotcha = false; + unsigned count; + KindToResPairSet::const_iterator i; + + i = toupgrade.find(ResKind::package); + if (i != toupgrade.end()) + { + count = i->second.size(); + s << format(_PL("%d package to upgrade", "%d packages to upgrade", count)) % count; + gotcha = true; + } + i = todowngrade.find(ResKind::package); + if (i != todowngrade.end()) + { + count = i->second.size(); + if (gotcha) + s << ", " << format(_PL("%d to downgrade", "%d to downgrade", count)) % count; + else + s << format(_PL("%d package to downgrade", "%d packages to downgrade", count)) % count; + } + i = toinstall.find(ResKind::package); + if (i != toinstall.end()) + { + count = i->second.size(); + if (gotcha) + s << ", " << format(_PL("%d new", "%d new", count)) % count; + else + s << format(_PL("%d new package to install", "%d new packages to install", count)) % count; + gotcha = true; + } + i = toreinstall.find(ResKind::package); + if (i != toreinstall.end()) + { + count = i->second.size(); + if (gotcha) + s << ", " << format(_PL("%d to reinstall", "%d to reinstall", count)) % count; + else + s << format(_PL("%d package to reinstall", "%d packages to reinstall", count)) % count; + gotcha = true; + } + i = toremove.find(ResKind::package); + if (i != toremove.end()) + { + count = i->second.size(); + if (gotcha) + s << ", " << format(_PL("%d to remove", "%d to remove", count)) % count; + else + s << format(_PL("%d package to remove", "%d packages to remove", count)) % count; + gotcha = true; + } + i = tochangevendor.find(ResKind::package); + if (i != tochangevendor.end()) + { + count = i->second.size(); + if (gotcha) + s << ", " << format(_PL("%d to change vendor", "%d to change vendor", count)) % count; + else + s << format(_PL("%d package will change vendor", "%d packages will change vendor", count)) % count; + gotcha = true; + } + i = tochangearch.find(ResKind::package); + if (i != tochangearch.end()) + { + count = i->second.size(); + if (gotcha) + s << ", " << format(_PL("%d to change arch", "%d to change arch", count)) % count; + else + s << format(_PL("%d package will change arch", "%d packages will change arch", count)) % count; + gotcha = true; + } + s << "." << endl; + wrap_text(out, s.str(), 0, _wrap_width); +} + // -------------------------------------------------------------------------- void Summary::dumpTo(ostream & out) @@ -627,7 +707,7 @@ void Summary::dumpTo(ostream & out) if (_viewop & SHOW_UNSUPPORTED) writeUnsupported(out); out << endl; - //! \todo write package counts + writePackageCounts(out); writeDownloadAndInstalledSizeSummary(out); } diff --git a/src/Summary.h b/src/Summary.h index 68a6c4b..44afcec 100644 --- a/src/Summary.h +++ b/src/Summary.h @@ -27,7 +27,7 @@ public: inline bool operator()(const ResPair & p1, const ResPair & p2) const; }; typedef std::set ResPairSet; - typedef std::map KindToResPairSet; + typedef std::map KindToResPairSet; enum _view_options { @@ -73,6 +73,7 @@ public: void writeChangedArch(std::ostream & out); void writeChangedVendor(std::ostream & out); void writeUnsupported(std::ostream & out); + void writePackageCounts(std::ostream & out); void writeDownloadAndInstalledSizeSummary(std::ostream & out); unsigned packagesToGetAndInstall() const diff --git a/src/solve-commit.cc b/src/solve-commit.cc index caf7760..b6738b9 100755 --- a/src/solve-commit.cc +++ b/src/solve-commit.cc @@ -464,6 +464,7 @@ void solve_and_commit (Zypper & zypper) // The anserws must be separated by slash characters '/' and must // correspond to yes/no/showproblems in that order. // The answers should be lower case letters. + //! \todo add c for changelog and x for explain (show the dep tree) popts.setOptions(_("y/n/p/v/a/r/m/d/g"), 0); popts.setShownCount(2); if (!(zypper.runtimeData().force_resolution && show_p_option))