enabled locking in SAT solver
authorStefan Schubert <schubi@suse.de>
Thu, 17 Jan 2008 15:23:46 +0000 (15:23 +0000)
committerStefan Schubert <schubi@suse.de>
Thu, 17 Jan 2008 15:23:46 +0000 (15:23 +0000)
zypp/sat/SATResolver.cc
zypp/sat/SATResolver.h

index 039612d1583d603c6b34c193d909b3a9941f89e7..5078234979a279fd14f7e23da909c96ac1f7c58c 100644 (file)
@@ -166,17 +166,10 @@ SATResolver::addPoolItemsToRemoveFromList (PoolItemList & rl)
 }
 
 void
-SATResolver::addPoolItemToLockUninstalled (PoolItem_Ref item)
+SATResolver::addPoolItemToLock (PoolItem_Ref item)
 {
-    _items_to_lockUninstalled.push_back (item);
-    _items_to_lockUninstalled.unique ();
-}
-
-void
-SATResolver::addPoolItemToKepp (PoolItem_Ref item)
-{
-    _items_to_keep.push_back (item);
-    _items_to_keep.unique ();
+    _items_to_lock.push_back (item);
+    _items_to_lock.unique ();
 }
 
 
@@ -333,17 +326,11 @@ struct SATCollectTransact : public resfilter::PoolItemFilterFunctor
        }
 
         if (status.isLocked()
-            && status.isUninstalled()) {
-            // This item could be selected by solver in a former run. Now it
-            // is locked. So we will have to evaluate a new solver run.
-            resolver.addPoolItemToLockUninstalled (item);
+            || (status.isKept()
+               && !by_solver)) {
+            resolver.addPoolItemToLock (item);
         }
 
-        if (status.isKept()
-            && !by_solver) {
-           // collecting all keep states
-           resolver.addPoolItemToKepp (item);
-       }
 
        return true;
     }
@@ -397,6 +384,7 @@ SATResolver::resolvePool(const CapSet & requires_caps,
     queue_init( &jobQueue );
     _items_to_install.clear();
     _items_to_remove.clear();
+    _items_to_lock.clear();    
 
     invokeOnEach ( _pool.begin(), _pool.end(),
                   resfilter::ByTransact( ),                    // collect transacts from Pool to resolver queue
@@ -440,6 +428,20 @@ SATResolver::resolvePool(const CapSet & requires_caps,
        queue_push( &(jobQueue), str2id( _SATPool, (iter->asString()).c_str(), 1 ));
        MIL << "Conflicts " << iter->asString() << endl;        
     }
+
+    for (PoolItemList::const_iterator iter = _items_to_lock.begin(); iter != _items_to_lock.end(); iter++) {
+       Solvable *s = _SATPool->solvables + iter->satSolvable().id();
+       Id id = iter->satSolvable().id();
+       if (iter->status().isInstalled()) {
+           MIL << "Lock installed item " << *iter << " with the string ID: " << s->name << endl;
+           queue_push( &(jobQueue), SOLVER_INSTALL_SOLVABLE );     
+           queue_push( &(jobQueue), id );
+       } else {
+           MIL << "Lock NOT installed item " << *iter << " with the string ID: " << s->name << endl;
+           queue_push( &(jobQueue), SOLVER_ERASE_SOLVABLE );
+           queue_push( &(jobQueue), id );
+       }
+    }
     
     solv = solver_create( _SATPool, sat::Pool::instance().systemRepo().get() );
     sat::Pool::instance().setDirty();
index fdb28bd2f8405fa697cc491bcd43ebd5c9762516..abfb820f60bf06e230a981349a5f38338a2b064d 100644 (file)
@@ -74,8 +74,7 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
     // list populated by calls to addPoolItemTo*()
     PoolItemList _items_to_install;
     PoolItemList _items_to_remove;
-    PoolItemList _items_to_lockUninstalled;
-    PoolItemList _items_to_keep;
+    PoolItemList _items_to_lock;
     
     // ---------------------------------- methods
     std::string SATprobleminfoString (Id problem);
@@ -114,8 +113,7 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
     void addPoolItemToInstall (PoolItem_Ref item);
     void addPoolItemsToInstallFromList (PoolItemList & rl);
 
-    void addPoolItemToLockUninstalled (PoolItem_Ref item);
-    void addPoolItemToKepp (PoolItem_Ref item);
+    void addPoolItemToLock (PoolItem_Ref item);
 
     void addPoolItemToRemove (PoolItem_Ref item);
     void addPoolItemsToRemoveFromList (PoolItemList & rl);