[zypp-commit] r9428 - in /trunk/libzypp: tests/zypp/PoolQuery_test.cc zypp/PoolQuery.cc zypp/PoolQuery.h
Author: jkupec Date: Mon Apr 7 16:21:22 2008 New Revision: 9428 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9428&view=rev Log: - by-status filter re-enabled - test case added Modified: trunk/libzypp/tests/zypp/PoolQuery_test.cc trunk/libzypp/zypp/PoolQuery.cc trunk/libzypp/zypp/PoolQuery.h Modified: trunk/libzypp/tests/zypp/PoolQuery_test.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/PoolQuery_test.cc?rev=9428&r1=9427&r2=9428&view=diff ============================================================================== --- trunk/libzypp/tests/zypp/PoolQuery_test.cc (original) +++ trunk/libzypp/tests/zypp/PoolQuery_test.cc Mon Apr 7 16:21:22 2008 @@ -21,6 +21,7 @@ { zypp::PoolItem pi( zypp::ResPool::instance().find( solvable ) ); cout << pi.resolvable() << endl; + // name: yast2-sound 2.16.2-9 i586 return true; } @@ -38,7 +39,8 @@ sat::Pool::instance().addRepoSolv(dir / "factory-nonoss.solv", i2); RepoInfo i3; i3.setAlias("zypp_svn"); sat::Pool::instance().addRepoSolv(dir / "zypp_svn.solv", i3); - sat::Pool::instance().addRepoSolv(dir / "@System.solv"); + RepoInfo i4; i4.setAlias("@System"); + sat::Pool::instance().addRepoSolv(dir / "@System.solv", i4); } BOOST_AUTO_TEST_CASE(pool_query_init) @@ -53,7 +55,10 @@ cout << "****1****" << endl; PoolQuery q; cout << q.size() << endl; - BOOST_CHECK(q.size() == 11449); + BOOST_CHECK(q.size() == 11451); + //!\todo should be 11453 probably according to: + // dumpsolv factory.solv factory-nonoss.solv zypp_svn.solv \@System.solv | \ + // grep '^name:.*\(noarch\|i386\|i586\|i686\|src\)$' | wc -l } // default query + one search string @@ -162,8 +167,29 @@ BOOST_CHECK(q1.empty()); } +// match by installed status (basically by system vs. repo) BOOST_AUTO_TEST_CASE(pool_query_8) { + cout << "****8****" << endl; + PoolQuery q; + q.addString("zypper"); + q.addAttribute(sat::SolvAttr::name); + q.setMatchExact(); + q.setInstalledOnly(); + + std::for_each(q.begin(), q.end(), &result_cb); + BOOST_CHECK(q.size() == 1); + + cout << endl; + + PoolQuery q1; + q1.addString("zypper"); + q1.addAttribute(sat::SolvAttr::name); + q1.setMatchExact(); + q1.setUninstalledOnly(); + + std::for_each(q1.begin(), q1.end(), &result_cb); + BOOST_CHECK(q1.size() == 5); } BOOST_AUTO_TEST_CASE(pool_query_save_restore) Modified: trunk/libzypp/zypp/PoolQuery.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.cc?rev=9428&r1=9427&r2=9428&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolQuery.cc (original) +++ trunk/libzypp/zypp/PoolQuery.cc Mon Apr 7 16:21:22 2008 @@ -447,9 +447,10 @@ o << "compiled: " << _compiled << endl; - o << "match flags:" << endl; + o << "string match flags:" << endl; o << "* sat: " << (_flags & SEARCH_STRINGMASK) << endl; o << "* SEARCH_REGEX: " << ((_flags & SEARCH_STRINGMASK) == SEARCH_REGEX ? "yes" : "no") << endl; + o << "status filter flags:" << _status_flags << endl; // raw @@ -533,16 +534,35 @@ { _sid = _rdit->solvid; + bool new_solvable = true; bool matches = !_do_matching; bool in_repo; + bool drop_by_kind_status; do { //! \todo FIXME Dataiterator returning resolvables belonging to current repo? - in_repo = _sid >= _rdit->repo->start; + in_repo = _sid >= _rdit->repo->start; - if (_do_matching) + if (in_repo && new_solvable) { - if ( !matches && in_repo /*_sid >= 2 *//*_rdit->repo->start*/) + drop_by_kind_status = false; + + // filter by installed uninstalled + if ( (_pqimpl->_status_flags & INSTALLED_ONLY) && + _rdit->repo->name != _pool.systemRepoName() ) + drop_by_kind_status = true; + + if (!drop_by_kind_status) + if ( (_pqimpl->_status_flags & UNINSTALLED_ONLY) && + _rdit->repo->name == _pool.systemRepoName() ) + drop_by_kind_status = true; + + matches = matches && !drop_by_kind_status; + } + + if (_do_matching && !drop_by_kind_status) + { + if (!matches && in_repo) { SolvAttr attr(_rdit->key->name); @@ -566,7 +586,8 @@ if ((_has_next = ::dataiterator_step(_rdit))) { - if (!in_repo /*_sid < 2 *//*_rdit->repo->start*/) + new_solvable = _rdit->solvid != _sid; + if (!in_repo) { INT << "repo start: " << _rdit->repo->start << endl; _sid = _rdit->solvid; @@ -579,7 +600,7 @@ return matches && in_repo; } } - while (_rdit->solvid == _sid || !in_repo /*_sid < 2 *//*_rdit->repo->start*/); + while (!new_solvable || !in_repo); return matches; } @@ -645,11 +666,11 @@ void PoolQuery::setInstalledOnly() - { _pimpl->_status_flags |= INSTALLED_ONLY; } + { _pimpl->_status_flags = INSTALLED_ONLY; } void PoolQuery::setUninstalledOnly() - { _pimpl->_status_flags |= UNINSTALLED_ONLY; } + { _pimpl->_status_flags = UNINSTALLED_ONLY; } void PoolQuery::setStatusFilterFlags( int flags ) - { _pimpl->_status_flags |= flags; } + { _pimpl->_status_flags = flags; } void PoolQuery::requireAll(const bool require_all) Modified: trunk/libzypp/zypp/PoolQuery.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.h?rev=9428&r1=9427&r2=9428&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolQuery.h (original) +++ trunk/libzypp/zypp/PoolQuery.h Mon Apr 7 16:21:22 2008 @@ -145,9 +145,9 @@ * Filter by status (installed uninstalled) */ enum StatusFilter { - ALL = 1, - INSTALLED_ONLY = 2, - UNINSTALLED_ONLY = 4 + ALL = 0, // both install filter and uninstall filter bits are 0 + INSTALLED_ONLY = 1, + UNINSTALLED_ONLY = 2 }; void setInstalledOnly(); void setUninstalledOnly(); -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
jkupec@svn.opensuse.org