From 3786c8ffcd3689eee39ce5e1389d2ee2c636e141 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Tue, 4 Apr 2006 12:48:08 +0000 Subject: [PATCH] - Fixed candidate handling in ui::Selectable. (#156589) --- devel/devel.ma/Parse.cc | 108 +++++++++++++++++++++++++--------------------- package/libzypp.changes | 13 ++++-- zypp/ui/SelectableImpl.cc | 46 +++++++++++++++++--- zypp/ui/SelectableImpl.h | 4 +- 4 files changed, 109 insertions(+), 62 deletions(-) diff --git a/devel/devel.ma/Parse.cc b/devel/devel.ma/Parse.cc index aeedf50..a440d0e 100644 --- a/devel/devel.ma/Parse.cc +++ b/devel/devel.ma/Parse.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include "zypp/NVRAD.h" #include "zypp/ResPool.h" @@ -58,49 +59,35 @@ namespace container /////////////////////////////////////////////////////////////////// -struct XByInstalled : public std::unary_function -{ - bool operator()( const ui::Selectable::constPtr & obj ) const +template + inline _Function for_each_if( _Iterator begin_r, _Iterator end_r, + _Filter filter_r, + _Function fnc_r ) { - return obj->hasInstalledObj(); + for ( _Iterator it = begin_r; it != end_r; ++it ) + { + if ( filter_r( *it ) ) + { + fnc_r( *it ); + } + } + return fnc_r; } -}; -template<> - struct PrintPtr : public std::unary_function +struct PoolItemSelect +{ + void operator()( const PoolItem & pi ) const { - bool operator()( const ui::Selectable::Ptr & obj ) - { - if ( obj ) { - MIL << obj->modifiedBy() << " " << obj->hasLicenceConfirmed() << endl; - obj->set_status( ui::S_Install ); - obj->setLicenceConfirmed( true ); - MIL << "a " << obj->modifiedBy() << " " << obj->hasLicenceConfirmed() << endl; - obj->set_status( ui::S_Del ); - obj->setLicenceConfirmed( false ); - MIL << "b " << obj->modifiedBy() << " " << obj->hasLicenceConfirmed() << endl; - -#if 0 - USR << *obj << std::endl; - std::for_each( obj->availableBegin(), obj->availableEnd(), - PrintPtr() ); - if ( obj->availableBegin() != obj->availableEnd() ) - SEC << PrintPtr()(*obj->availableBegin() ) - << " " << asKind(*obj->availableBegin())->vendor() << endl; -#endif - } - else - USR << "(NULL)" << std::endl; - return true; - } - }; + if ( pi->source().numericId() == 2 ) + pi.status().setTransact( true, ResStatus::USER ); + } +}; -struct Mpool +struct PrintPoolItem { - bool operator()( const PoolItem & pi ) + void operator()( const PoolItem & pi ) const { - return pi.status().isLocked(); - return true; + USR << pi->source().numericId() << " " << pi << endl; } }; @@ -113,10 +100,9 @@ int main( int argc, char * argv[] ) { //zypp::base::LogControl::instance().logfile( "xxx" ); INT << "===[START]==========================================" << endl; - ResPool pool( getZYpp()->pool() ); - if ( 1 ) + if ( 0 ) { Measure x( "initTarget " + sysRoot.asString() ); getZYpp()->initTarget( sysRoot ); @@ -124,21 +110,47 @@ int main( int argc, char * argv[] ) INT << "Added target: " << pool << endl; } - SourceManager::sourceManager()->restore( sysRoot ); - if ( SourceManager::sourceManager()->allSources().empty() ) - { - Source_Ref src( createSource( instSrc ) ); - SourceManager::sourceManager()->addSource( src ); - SourceManager::sourceManager()->store( sysRoot, true ); - } + if ( 0 ) { + SourceManager::sourceManager()->restore( sysRoot ); + if ( SourceManager::sourceManager()->allSources().empty() ) + { + Source_Ref src( createSource( instSrc ) ); + SourceManager::sourceManager()->addSource( src ); + SourceManager::sourceManager()->store( sysRoot, true ); + } - Source_Ref src( *SourceManager::sourceManager()->Source_begin() ); - getZYpp()->addResolvables( src.resolvables() ); - INT << "Added source: " << pool << endl; + Source_Ref src( *SourceManager::sourceManager()->Source_begin() ); + getZYpp()->addResolvables( src.resolvables() ); + INT << "Added source: " << pool << endl; + } + + + Source_Ref src1( createSource( "dir:/mounts/machcd2/CDs/SUSE-Linux-10.1-Build_830-Addon-BiArch/CD1" ) ); + Source_Ref src2( createSource( "dir:/mounts/machcd2/CDs/SUSE-Linux-10.1-Build_830-i386/CD1" ) ); + INT << "Pool: " << pool << endl; + getZYpp()->addResolvables( src1.resolvables() ); + INT << "Added source1: " << pool << endl; + getZYpp()->addResolvables( src2.resolvables() ); + INT << "Added source2: " << pool << endl; NameKindProxy s( nameKindProxy( pool, "default" ) ); MIL << s << endl; + if ( ! s.availableEmpty() ) + { + PoolItem def( * s.availableBegin() ); + def.status().setTransact( true, ResStatus::USER ); + } + MIL << "est " << getZYpp()->resolver()->establishPool() << endl; + MIL << "slv " << getZYpp()->resolver()->resolvePool() << endl; + + + for_each( pool.byKindBegin(), pool.byKindEnd(), + PoolItemSelect() ); + INT << "FIN: " << pool << endl; + for_each_if( pool.begin(), pool.end(), + resfilter::ByTransact(), + PrintPoolItem() ); #if 0 Source_Ref src( *SourceManager::sourceManager()->Source_begin() ); diff --git a/package/libzypp.changes b/package/libzypp.changes index d861f15..cee1f2f 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,10 +1,15 @@ ------------------------------------------------------------------- +Tue Apr 4 14:43:15 CEST 2006 - ma@suse.de + +- Fixed candidate handling in ui::Selectable. (#156589) + +------------------------------------------------------------------- Tue Apr 4 14:06:23 CEST 2006 - dmacvicar@suse.de -- fix #162984 , gpg hangs because the matching data file +- fix #162984 , gpg hangs because the matching data file for the key cannot be find. (dmacvicar) - Fix restore of YUM source using the same cache dir semantics as -  susetags instead of assuming there is a cache if a cache_dir +  susetags instead of assuming there is a cache if a cache_dir was given. (dmacvicar) ------------------------------------------------------------------- @@ -55,8 +60,8 @@ Fri Mar 31 18:53:55 CEST 2006 - schubi@suse.de ------------------------------------------------------------------- Fri Mar 31 18:28:59 CEST 2006 - sh@suse.de -- Added zypp/ui/UserWantedPackages to support the UI's - "automatic changes" dialog (bug #152700) +- Added zypp/ui/UserWantedPackages to support the UI's + "automatic changes" dialog (bug #152700) ------------------------------------------------------------------- Fri Mar 31 18:02:05 CEST 2006 - jsrain@suse.de diff --git a/zypp/ui/SelectableImpl.cc b/zypp/ui/SelectableImpl.cc index f0c23f7..a5da628 100644 --- a/zypp/ui/SelectableImpl.cc +++ b/zypp/ui/SelectableImpl.cc @@ -200,21 +200,53 @@ namespace zypp PoolItem Selectable::Impl::setCandidate( ResObject::constPtr byUser_r ) { + PoolItem oldCand = _candidate; _candidate = PoolItem(); - for ( availableItem_const_iterator it = availableBegin(); - it != availableEnd(); ++it ) + + if ( byUser_r ) // must be in available list { - if ( it->resolvable() == byUser_r ) + for ( availableItem_const_iterator it = availableBegin(); + it != availableEnd(); ++it ) { - _candidate = *it; - break; + if ( it->resolvable() == byUser_r ) + { + _candidate = *it; + break; + } } } + if ( ! ( _candidate || _availableItems.empty() ) ) { -#warning actually select with respect to an installed items arch - _candidate = *_availableItems.begin(); + if ( installedObj() ) + { + for ( availableItem_const_iterator it = availableBegin(); + it != availableEnd(); ++it ) + { + if ( installedObj()->arch() == (*it)->arch() ) + _candidate = *it; + break; + } + } + else + _candidate = *_availableItems.begin(); } + + if ( _candidate != oldCand ) + { + if ( oldCand ) + { + ResStatus::TransactValue tv( oldCand.status().getTransactValue() ); + ResStatus::TransactByValue tb( oldCand.status().getTransactByValue() ); + oldCand.status().resetTransact( ResStatus::USER ); + if ( _candidate ) + { + _candidate.status().resetTransact( ResStatus::USER ); + _candidate.status().setTransactValue( tv, tb ); + } + } + } + return _candidate; } diff --git a/zypp/ui/SelectableImpl.h b/zypp/ui/SelectableImpl.h index 6ff69be..92eda54 100644 --- a/zypp/ui/SelectableImpl.h +++ b/zypp/ui/SelectableImpl.h @@ -84,9 +84,7 @@ namespace zypp */ PoolItem candidateObj() const { - if ( _candidate ) - return _candidate; - return( _availableItems.empty() ? PoolItem() : *_availableItems.begin() ); + return _candidate; } /** Set a userCandidate (out of available objects). -- 2.7.4