ref: refs/heads/master
commit e25828dc5b92e99788e747b115abbbf2efff1b31
Author: Ján Kupec
Date: Tue Mar 31 23:52:16 2009 +0200
Allow to show version/arch/repo/vendor in summary.
- part of fixing bnc #389128
---
src/Summary.cc | 64 +++++++++++++++++++++----------
src/Summary.h | 2 +
src/solve-commit.cc | 103 ++++++++++++++++++++++++++++++++++----------------
3 files changed, 115 insertions(+), 54 deletions(-)
diff --git a/src/Summary.cc b/src/Summary.cc
index 3959c9e..50a209b 100644
--- a/src/Summary.cc
+++ b/src/Summary.cc
@@ -18,6 +18,7 @@
#include "main.h"
#include "utils/text.h"
#include "utils/misc.h"
+#include "Table.h"
#include "Summary.h"
@@ -237,33 +238,51 @@ void Summary::writeResolvableList(ostream & out, const ResPairSet & resolvables)
s << resit->second->name() << " ";
wrap_text(out, s.str(), 2, _wrap_width);
out << endl;
+ return;
}
-}
-// --------------------------------------------------------------------------
+ Table t; t.lineStyle(none); t.wrap(0); t.margin(2);
-// plus edition and architecture for verbose output
-/*
-if (out.verbosity() > Out::NORMAL)
-{
- s << "-" << res->edition() << "." << res->arch();
-
- const string & reponame = res->repoInfo().name();
- if (!res->vendor().empty() || !reponame.empty())
+ for (ResPairSet::const_iterator resit = resolvables.begin();
+ resit != resolvables.end(); ++resit)
{
- s << " (";
- // plus repo providing this package
- if (!reponame.empty())
- s << reponame;
- // plus package vendor
- if (!res->vendor().empty())
- s << (reponame.empty() ? "" : ", ") << res->vendor();
- s << ")";
+ TableRow tr;
+ tr << resit->second->name();
+ if (_viewop & SHOW_VERSION)
+ {
+ if (resit->first && resit->first->edition() != resit->second->edition())
+ tr << resit->first->edition().asString() + " -> " +
+ resit->second->edition().asString();
+ else
+ tr << resit->second->edition().asString();
+ }
+ if (_viewop & SHOW_ARCH)
+ {
+ if (resit->first && resit->first->arch() != resit->second->arch())
+ tr << resit->first->arch().asString() + " -> " +
+ resit->second->arch().asString();
+ else
+ tr << resit->second->arch().asString();
+ }
+ if (_viewop & SHOW_REPO)
+ {
+ // we do not know about repository changes, only show the repo from
+ // which the package will be installed
+ tr << resit->second->repoInfo().name();
+ }
+ if (_viewop & SHOW_VENDOR)
+ {
+ if (resit->first && resit->first->vendor() != resit->second->vendor())
+ tr << resit->first->vendor() + " -> " +
+ resit->second->vendor();
+ else
+ tr << resit->second->vendor();
+ }
+ t << tr;
}
- // new line after each package in the verbose mode
- s << endl;
+
+ out << t << endl;
}
-*/
// --------------------------------------------------------------------------
@@ -549,6 +568,9 @@ void Summary::writeUnsupported(ostream & out)
void Summary::writeDownloadAndInstalledSizeSummary(ostream & out)
{
+ if (!_inst_pkg_total && toremove.empty())
+ return; // nothing to do, keep silent
+
// download size info
ostringstream s;
if (_todownload > 0)
diff --git a/src/Summary.h b/src/Summary.h
index f22a09b..6ddd7fe 100644
--- a/src/Summary.h
+++ b/src/Summary.h
@@ -60,6 +60,8 @@ public:
{ _viewop = (ViewOptions) (_viewop | option); }
void unsetViewOption(const ViewOptions option)
{ _viewop = (ViewOptions) (_viewop & ~option); }
+ void toggleViewOption(const ViewOptions option)
+ { _viewop & option ? unsetViewOption(option) : setViewOption(option); }
void writeNewlyInstalled(std::ostream & out);
void writeRemoved(std::ostream & out);
diff --git a/src/solve-commit.cc b/src/solve-commit.cc
index 0d86996..8821675 100755
--- a/src/solve-commit.cc
+++ b/src/solve-commit.cc
@@ -365,7 +365,7 @@ static void make_solver_test_case(Zypper & zypper)
*/
void solve_and_commit (Zypper & zypper)
{
- bool show_forced_problems = true;
+ bool need_another_solver_run = true;
bool commit_done = false;
do
{
@@ -460,29 +460,48 @@ void solve_and_commit (Zypper & zypper)
zypper.command() == ZypperCommand::REMOVE);
bool do_commit = false;
- if (zypper.runtimeData().force_resolution && show_p_option)
+ PromptOptions popts;
+ // translators: Yes / No / show Problems. This prompt will appear
+ // after install/update command summary if there will be any package
+ // to-be-removed automatically to show why, if asked.
+ // Translate to whathever is suitable for your language
+ // 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.
+ popts.setOptions(_("y/n/p/v/a/r/m"), 0);
+ popts.setShownCount(2);
+ if (!(zypper.runtimeData().force_resolution && show_p_option))
+ popts.disable(2);
+ // translators: help text for 'y' option in the y/n/p prompt
+ popts.setOptionHelp(0, _("Yes, ccept the summary and proceed with installation/removal of packages."));
+ // translators: help text for 'n' option in the y/n/p prompt
+ popts.setOptionHelp(1, _("No, cancel the operation."));
+ // translators: help text for 'p' option in the y/n/p prompt
+ popts.setOptionHelp(2, _("Restart solver in no-force-resolution mode in order to show dependency problems."));
+ popts.setOptionHelp(3, _("Toggle display of package versions."));
+ popts.setOptionHelp(4, _("Toggle display of package architectures."));
+ popts.setOptionHelp(5, _("Toggle display of repositories from which the packages will be installed."));
+ popts.setOptionHelp(6, _("Toggle display of package vendor names."));
+ // popts.setOptionHelp(7, _("Explain why the packages are going to be installed."));
+ // popts.setOptionHelp(8, _("Show all details."));
+
+ string prompt_text = _("Continue?");
+
+ unsigned int reply;
+ do
{
- PromptOptions popts;
- // translators: Yes / No / show Problems. This prompt will appear
- // after install/update command summary if there will be any package
- // to-be-removed automatically to show why, if asked.
- // Translate to whathever is suitable for your language
- // 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.
- popts.setOptions(_("y/n/p"), 0);
- // translators: help text for 'y' option in the y/n/p prompt
- popts.setOptionHelp(0, _("Accept the summary and proceed with installation/removal of packages."));
- // translators: help text for 'n' option in the y/n/p prompt
- popts.setOptionHelp(1, _("Cancel the operation."));
- // translators: help text for 'p' option in the y/n/p prompt
- popts.setOptionHelp(2, _("Restart solver in no-force-resolution mode in order to show dependency problems."));
- string prompt_text = _("Continue?");
zypper.out().prompt(PROMPT_YN_INST_REMOVE_CONTINUE, prompt_text, popts);
- unsigned int reply =
- get_prompt_reply(zypper, PROMPT_YN_INST_REMOVE_CONTINUE, popts);
+ reply = get_prompt_reply(zypper, PROMPT_YN_INST_REMOVE_CONTINUE, popts);
- if (reply == 2)
+ switch(reply)
+ {
+ case 0: // y
+ {
+ do_commit = true;
+ need_another_solver_run = false;
+ break;
+ }
+ case 2: // p
{
// one more solver solver run with force-resoltion off
zypper.runtimeData().force_resolution = false;
@@ -490,20 +509,38 @@ void solve_and_commit (Zypper & zypper)
God->resolver()->undo();
continue;
}
- else if (reply == 1)
- show_forced_problems = false;
- else
+ case 3: // v
{
- do_commit = true;
- show_forced_problems = false;
+ summary.toggleViewOption(Summary::SHOW_VERSION);
+ summary.dumpTo(cout);
+ break;
+ }
+ case 4: // a
+ {
+ summary.toggleViewOption(Summary::SHOW_ARCH);
+ summary.dumpTo(cout);
+ break;
+ }
+ case 5: // r
+ {
+ summary.toggleViewOption(Summary::SHOW_REPO);
+ summary.dumpTo(cout);
+ break;
+ }
+ case 6: // m
+ {
+ summary.toggleViewOption(Summary::SHOW_VENDOR);
+ summary.dumpTo(cout);
+ break;
+ }
+ default: // n
+ need_another_solver_run = false;
}
}
- // no dependency problems
- else
- {
- do_commit = read_bool_answer(PROMPT_YN_INST_REMOVE_CONTINUE, _("Continue?"), true);
- show_forced_problems = false;
- }
+ while (reply > 2);
+
+ if (need_another_solver_run)
+ continue;
// COMMIT
@@ -663,5 +700,5 @@ void solve_and_commit (Zypper & zypper)
break;
}
}
- while (show_forced_problems);
+ while (need_another_solver_run);
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org