Author: schubi2 Date: Wed Sep 12 15:48:13 2007 New Revision: 7209 URL: http://svn.opensuse.org/viewcvs/zypp?rev=7209&view=rev Log: Regarding keep state while recycle old valid solver results. Bug 286889 Modified: trunk/libzypp/zypp/ResFilters.h trunk/libzypp/zypp/solver/detail/ContextPool.cc trunk/libzypp/zypp/solver/detail/ContextPool.h trunk/libzypp/zypp/solver/detail/Resolver.cc trunk/libzypp/zypp/solver/detail/Resolver.h trunk/libzypp/zypp/solver/detail/ResolverContext.h Modified: trunk/libzypp/zypp/ResFilters.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResFilters.h?rev=720... ============================================================================== --- trunk/libzypp/zypp/ResFilters.h (original) +++ trunk/libzypp/zypp/ResFilters.h Wed Sep 12 15:48:13 2007 @@ -338,6 +338,16 @@ } }; + /** Select PoolItem by keep. */ + struct ByKeep : public PoolItemFilterFunctor + { + bool operator()( const PoolItem & p ) const + { + return p.status().isKept(); + } + }; + + /////////////////////////////////////////////////////////////////// Modified: trunk/libzypp/zypp/solver/detail/ContextPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Contex... ============================================================================== --- trunk/libzypp/zypp/solver/detail/ContextPool.cc (original) +++ trunk/libzypp/zypp/solver/detail/ContextPool.cc Wed Sep 12 15:48:13 2007 @@ -80,7 +80,8 @@ void ContextPool::addContext (ResolverContext_Ptr context, const PoolItemList & installItems, const PoolItemList & deleteItems, - const PoolItemList & lockUninstalledItems) + const PoolItemList & lockUninstalledItems, + const PoolItemList & keepItems) { if ((installItems.size() == 0 && deleteItems.size() == 0) @@ -93,7 +94,8 @@ new_context->setUserInstallItems (installItems); new_context->setUserDeleteItems (deleteItems); - new_context->setUserLockUninstalledItems (lockUninstalledItems); + new_context->setUserLockUninstalledItems (lockUninstalledItems); + new_context->setUserKeepItems (keepItems); if (contextList.size() <= 0) { contextList.push_front (new_context); @@ -156,6 +158,23 @@ } } } + + // checking keep items + left = (*it)->userKeepItems(); + right = context->userKeepItems(); + if (left.size() != right.size()) + continue; + found = true; + for (PoolItemList::iterator itleft = left.begin(); + (itleft != left.end()) && found ; ++itleft) { + found = false; + for (PoolItemList::iterator itright = right.begin(); itright != right.end(); ++itright) { + if (*itleft == *itright) { + found = true; + break; + } + } + } if (found) { exists = true; @@ -186,7 +205,9 @@ _XDEBUG(" deleted:"); dumpTaskList (new_context->userDeleteItems()); _XDEBUG(" locked:"); - dumpTaskList (new_context->userLockUninstalledItems()); + dumpTaskList (new_context->userLockUninstalledItems()); + _XDEBUG(" keep:"); + dumpTaskList (new_context->userKeepItems()); #if 0 _XDEBUG("CONTEXT : " << endl << *new_context ); #endif @@ -207,7 +228,8 @@ ResolverContext_Ptr ContextPool::findContext (PoolItemList & installItems, PoolItemList & deleteItems, - const PoolItemList & lockUninstalledItems) + const PoolItemList & lockUninstalledItems, + const PoolItemList & keepItems) { // searching for context with same entries int counter = 1; @@ -215,7 +237,8 @@ PoolItemList contextInstall = (*it)->userInstallItems(); PoolItemList contextDelete = (*it)->userDeleteItems(); - PoolItemList contextLockUninstalled = (*it)->userLockUninstalledItems(); + PoolItemList contextLockUninstalled = (*it)->userLockUninstalledItems(); + PoolItemList contextKeep = (*it)->userKeepItems(); _XDEBUG("ContextPool::findContext() trying " << counter++ << ". of " << contextList.size() ); _XDEBUG(" comparing"); @@ -225,6 +248,9 @@ dumpTaskList (contextDelete); _XDEBUG(" lockedUninstalled:"); dumpTaskList (contextLockUninstalled); + _XDEBUG(" keep:"); + dumpTaskList (contextKeep); + _XDEBUG(" with needed"); _XDEBUG(" installed:"); @@ -233,10 +259,13 @@ dumpTaskList (deleteItems); _XDEBUG(" lockedUninstalled:"); dumpTaskList (lockUninstalledItems); + _XDEBUG(" keep:"); + dumpTaskList (keepItems); if (contextInstall.size() > installItems.size() || contextDelete.size() > deleteItems.size() - || contextLockUninstalled.size() != lockUninstalledItems.size()) + || contextLockUninstalled.size() != lockUninstalledItems.size() + || contextKeep.size() != keepItems.size()) continue; // cannot fit at all bool found = true; @@ -257,6 +286,21 @@ } if (!found) continue; + // check if the keep items are the same. + // If not --> try the next context + for (PoolItemList::iterator itContext = contextKeep.begin(); + (itContext != contextKeep.end()) && found; ++itContext) { + found = false; + for (PoolItemList::const_iterator itInstall = keepItems.begin(); + itInstall != keepItems.end(); ++itInstall) { + if (*itContext == *itInstall) { + found = true; + break; + } + } + } + if (!found) continue; + // checking items which will be installed PoolItemList addInsItems = installItems; for (PoolItemList::iterator itContext = contextInstall.begin(); Modified: trunk/libzypp/zypp/solver/detail/ContextPool.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Contex... ============================================================================== --- trunk/libzypp/zypp/solver/detail/ContextPool.h (original) +++ trunk/libzypp/zypp/solver/detail/ContextPool.h Wed Sep 12 15:48:13 2007 @@ -94,12 +94,14 @@ * @param installItems List of items which are selected by the user * @param deleteItems List of items which are selected by the user * @param lockUninstalledItems List of items which are selected by the user + * @param keepItems List of items which are selected by the user * * */ void addContext (ResolverContext_Ptr context, const PoolItemList & installItems, const PoolItemList & deleteItems, - const PoolItemList & lockUninstalledItems); + const PoolItemList & lockUninstalledItems, + const PoolItemList & keepItems); /** * Find a solver result in order to use it for the next solver run. * @@ -107,11 +109,13 @@ * @param installItems List of items which are selected by the user * @param deleteItems List of items which are selected by the user * @param lockUninstalledItems List of items which are selected by the user + * @param keepItems List of items which are selected by the user * @return solver context * */ ResolverContext_Ptr findContext (PoolItemList & installItems, PoolItemList & deleteItems, - const PoolItemList & lockUninstalledItems); + const PoolItemList & lockUninstalledItems, + const PoolItemList & keepItems); /** * Delete all sucessful solver run. Modified: trunk/libzypp/zypp/solver/detail/Resolver.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Resolv... ============================================================================== --- trunk/libzypp/zypp/solver/detail/Resolver.cc (original) +++ trunk/libzypp/zypp/solver/detail/Resolver.cc Wed Sep 12 15:48:13 2007 @@ -151,6 +151,7 @@ _items_to_remove.clear(); _items_to_verify.clear(); _items_to_establish.clear(); + _items_to_keep.clear(); if (!keepExtras) { _extra_caps.clear(); @@ -374,6 +375,12 @@ _items_to_lockUninstalled.unique (); } +void +Resolver::addPoolItemToKepp (PoolItem_Ref item) +{ + _items_to_keep.push_back (item); + _items_to_keep.unique (); +} void Resolver::addPoolItemToEstablish (PoolItem_Ref item) @@ -1221,6 +1228,12 @@ resolver.addPoolItemToLockUninstalled (item); } + if (status.isKept() + && !by_solver) { + // collecting all keep states + resolver.addPoolItemToKepp (item); + } + return true; } }; @@ -1237,9 +1250,11 @@ if (!full_pool_shown // show item if not shown all before || it->status().transacts() // or transacts + || it->status().isKept() + || it->status().isLocked() || !it->status().isUndetermined()) // or established status { - _DEBUG( count << ": " << *it ); + _XDEBUG( count << ": " << *it ); } } _XDEBUG( "---------------------------------------" ); @@ -1312,13 +1327,19 @@ invokeOnEach ( _pool.begin(), _pool.end(), resfilter::ByLock( ), // collect locks from Pool to resolver queue functor::functorRef<bool,PoolItem>(info) ); + + invokeOnEach ( _pool.begin(), _pool.end(), + resfilter::ByKeep( ), // collect keeps from Pool to resolver queue + functor::functorRef<bool,PoolItem>(info) ); + // List of installing/removing items of the complete run (not regarding a recycled solver run) PoolItemList _completeItems_to_install = _items_to_install; PoolItemList _completeItems_to_remove = _items_to_remove; PoolItemList _completeItems_to_lockUninstalled = _items_to_lockUninstalled; + PoolItemList _completeItems_to_keep = _items_to_keep; // We have to find a valid context in order to recycle it. - saveContext = contextPool.findContext (_items_to_install, _items_to_remove, _items_to_lockUninstalled); + saveContext = contextPool.findContext (_items_to_install, _items_to_remove, _items_to_lockUninstalled, _items_to_keep); // _items_to_install, _items_to_remove contains addition items which has been selected but are // not solved with that context. They will be solved now. // If we have not found any former fitting context, saveContext is NULL. So the solver @@ -1342,7 +1363,9 @@ show_pool( _pool ); #endif // insert best_context in ContextPool for further solver runs - contextPool.addContext( solution,_completeItems_to_install, _completeItems_to_remove, _completeItems_to_lockUninstalled); + contextPool.addContext( solution,_completeItems_to_install, _completeItems_to_remove, + _completeItems_to_lockUninstalled, + _completeItems_to_keep); } else { Modified: trunk/libzypp/zypp/solver/detail/Resolver.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Resolv... ============================================================================== --- trunk/libzypp/zypp/solver/detail/Resolver.h (original) +++ trunk/libzypp/zypp/solver/detail/Resolver.h Wed Sep 12 15:48:13 2007 @@ -110,6 +110,7 @@ PoolItemList _items_to_remove; PoolItemList _items_to_verify; PoolItemList _items_to_lockUninstalled; + PoolItemList _items_to_keep; // pool of valid contexts which are "recycled" in order to fasten the solver ContextPool contextPool; @@ -216,6 +217,7 @@ void addPoolItemsToInstallFromList (PoolItemList & rl); void addPoolItemToLockUninstalled (PoolItem_Ref item); + void addPoolItemToKepp (PoolItem_Ref item); void addPoolItemToRemove (PoolItem_Ref item); void addPoolItemsToRemoveFromList (PoolItemList & rl); Modified: trunk/libzypp/zypp/solver/detail/ResolverContext.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Resolv... ============================================================================== --- trunk/libzypp/zypp/solver/detail/ResolverContext.h (original) +++ trunk/libzypp/zypp/solver/detail/ResolverContext.h Wed Sep 12 15:48:13 2007 @@ -108,6 +108,7 @@ PoolItemList _userDeleteItems; PoolItemList _userInstallItems; PoolItemList _userLockUninstalledItems; + PoolItemList _userKeepItems; bool _forceResolve; // remove items which are conflicts with others or // have unfulfilled requirements. @@ -199,9 +200,11 @@ void setUserDeleteItems ( const PoolItemList & deleteItems) { _userDeleteItems = deleteItems; } void setUserInstallItems ( const PoolItemList& installItems) { _userInstallItems = installItems; } void setUserLockUninstalledItems ( const PoolItemList& lockItems) { _userLockUninstalledItems = lockItems; } + void setUserKeepItems ( const PoolItemList& keepItems) { _userKeepItems = keepItems; } PoolItemList userDeleteItems () { return _userDeleteItems; } PoolItemList userInstallItems () { return _userInstallItems; } PoolItemList userLockUninstalledItems () { return _userLockUninstalledItems; } + PoolItemList userKeepItems () { return _userKeepItems; } // ---------------------------------- methods -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org