Author: jkupec Date: Mon Jul 28 18:58:15 2008 New Revision: 10682 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10682&view=rev Log: - fixed some stupid and some clever bugs in seach (bnc #411339, bnc #410008) Modified: trunk/zypper/src/Zypper.cc trunk/zypper/src/search.h Modified: trunk/zypper/src/Zypper.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/Zypper.cc?rev=10682&r1=10681&r2=10682&view=diff ============================================================================== --- trunk/zypper/src/Zypper.cc (original) +++ trunk/zypper/src/Zypper.cc Mon Jul 28 18:58:15 2008 @@ -2803,10 +2803,15 @@ if (runningHelp()) { out().info(_command_help, Out::QUIET); return; } + TriBool inst_notinst = indeterminate; if (globalOpts().disable_system_resolvables || copts.count("uninstalled-only")) + { query.setUninstalledOnly(); // beware: this is not all to it, look at zypper-search, _only_not_installed + inst_notinst = false; + } if (copts.count("installed-only")) - query.setInstalledOnly(); + inst_notinst = true; + // query.setInstalledOnly(); //if (copts.count("match-any")) options.setMatchAny(); if (copts.count("match-words")) query.setMatchWord(); @@ -2877,17 +2882,17 @@ { if (command() == ZypperCommand::RUG_PATCH_SEARCH) { - FillPatchesTable callback(t, query.statusFilterFlags() & PoolQuery::UNINSTALLED_ONLY); + FillPatchesTable callback(t, inst_notinst); invokeOnEach(query.poolItemBegin(), query.poolItemEnd(), callback); } else if (_gopts.is_rug_compatible || _copts.count("details")) { - FillSearchTableSolvable callback(t, query.statusFilterFlags() & PoolQuery::UNINSTALLED_ONLY); + FillSearchTableSolvable callback(t, inst_notinst); invokeOnEach(query.selectableBegin(), query.selectableEnd(), callback); } else { - FillSearchTableSelectable callback(t, query.statusFilterFlags() & PoolQuery::UNINSTALLED_ONLY); + FillSearchTableSelectable callback(t, inst_notinst); invokeOnEach(query.selectableBegin(), query.selectableEnd(), callback); } Modified: trunk/zypper/src/search.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/search.h?rev=10682&r1=10681&r2=10682&view=diff ============================================================================== --- trunk/zypper/src/search.h (original) +++ trunk/zypper/src/search.h Mon Jul 28 18:58:15 2008 @@ -1,11 +1,9 @@ -/*-----------------------------------------------------------*- c++ -*-\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*\ + ____ _ _ __ _ __ ___ _ _ + |_ / || | '_ \ '_ \/ -_) '_| + /__|\_, | .__/ .__/\___|_| + |__/|_| |_| +\*---------------------------------------------------------------------------*/ #ifndef ZYPPERSEARCH_H_ #define ZYPPERSEARCH_H_ @@ -14,6 +12,7 @@ #include "zypp/sat/Solvable.h" #include "zypp/PoolItem.h" #include "zypp/Patch.h" +#include "zypp/TriBool.h" #include "Zypper.h" #include "utils/misc.h" // for kind_to_string_localized @@ -30,12 +29,12 @@ // the table used for output Table * _table; const GlobalOptions & _gopts; - bool _only_not_installed; + zypp::TriBool _inst_notinst; - FillSearchTableSolvable( Table & table, bool only_not_installed = false ) + FillSearchTableSolvable( Table & table, zypp::TriBool inst_notinst = zypp::indeterminate ) : _table( &table ) , _gopts(Zypper::instance()->globalOpts()) - , _only_not_installed(only_not_installed) + , _inst_notinst(inst_notinst) { TableHeader header; @@ -102,21 +101,34 @@ if (installed) { - if (_only_not_installed) + // show only not installed + if (_inst_notinst == false) continue; row << "i"; } - else + else + { + // show only installed + if (_inst_notinst == true) + continue; row << "v"; + } } - else if (pi.isSatisfied()) // patches/patterns/products are installed if satisfied + // patches/patterns/products are installed if satisfied + else if (pi->kind() != zypp::ResKind::srcpackage && pi.isSatisfied()) { - if (_only_not_installed) + // show only not installed + if (_inst_notinst == false) continue; row << "i"; } else + { + // show only installed + if (_inst_notinst == true) + continue; row << ""; + } if (_gopts.is_rug_compatible) { @@ -140,7 +152,7 @@ *_table << row; } - if (_only_not_installed) + if (_inst_notinst == false) return true; // show installed objects only if there is no counterpart in repos @@ -187,12 +199,12 @@ // the table used for output Table * _table; const GlobalOptions & _gopts; - bool _only_not_installed; + zypp::TriBool inst_notinst; - FillSearchTableSelectable( Table & table, bool only_not_installed = false ) + FillSearchTableSelectable( Table & table, zypp::TriBool installed_only = zypp::indeterminate ) : _table( &table ) , _gopts(Zypper::instance()->globalOpts()) - , _only_not_installed(only_not_installed) + , inst_notinst(installed_only) { TableHeader header; // translators: S for installed Status @@ -208,14 +220,21 @@ { TableRow row; - if (!s->installedEmpty() | s->theObj().isSatisfied()) + if (s->kind() != zypp::ResKind::srcpackage && + (!s->installedEmpty() || s->theObj().isSatisfied())) { - if (_only_not_installed) + // not-installed only + if (inst_notinst == false) return true; row << "i"; } else + { + // installed only + if (inst_notinst == true) + return true; row << ""; + } row << s->name(); row << s->theObj()->summary(); row << kind_to_string_localized(s->kind(), 1); @@ -233,12 +252,12 @@ // the table used for output Table * _table; const GlobalOptions & _gopts; - bool _only_not_installed; + zypp::TriBool _inst_notinst; - FillPatchesTable( Table & table, bool only_not_installed = false ) + FillPatchesTable( Table & table, zypp::TriBool inst_notinst = zypp::indeterminate ) : _table( &table ) , _gopts(Zypper::instance()->globalOpts()) - , _only_not_installed(only_not_installed) + , _inst_notinst(inst_notinst) { TableHeader header; @@ -257,7 +276,11 @@ bool operator()(const zypp::PoolItem & pi) const { - if (pi.isSatisfied() && _only_not_installed) + // only not installed + if (pi.isSatisfied() && _inst_notinst == false) + return true; + // only installed + else if (!pi.isSatisfied() && _inst_notinst == true) return true; TableRow row; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org