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=7209&r1=7208&r2=7209&view=diff
==============================================================================
--- 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/ContextPool.cc?rev=7209&r1=7208&r2=7209&view=diff
==============================================================================
--- 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/ContextPool.h?rev=7209&r1=7208&r2=7209&view=diff
==============================================================================
--- 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/Resolver.cc?rev=7209&r1=7208&r2=7209&view=diff
==============================================================================
--- 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