- new solution action for removing requirements/conflicts Bug 387631
authorStefan Schubert <schubi@suse.de>
Thu, 8 May 2008 12:21:32 +0000 (12:21 +0000)
committerStefan Schubert <schubi@suse.de>
Thu, 8 May 2008 12:21:32 +0000 (12:21 +0000)
zypp/solver/detail/ProblemSolutionCombi.cc
zypp/solver/detail/ProblemSolutionCombi.h
zypp/solver/detail/SATResolver.cc
zypp/solver/detail/SolutionAction.cc
zypp/solver/detail/SolutionAction.h

index ba6e522..3273fcb 100644 (file)
@@ -53,6 +53,12 @@ ProblemSolutionCombi::ProblemSolutionCombi( ResolverProblem_Ptr parent)
     _details = "";
 }
 
+void ProblemSolutionCombi::addSingleAction( Capability capability, const TransactionKind action)
+{
+    addAction (new TransactionSolutionAction(capability, action));
+    actNumber++;
+}
+       
 void ProblemSolutionCombi::addSingleAction( PoolItem item, const TransactionKind action)
 {
     addAction (new TransactionSolutionAction(item, action));
index 4fd18ff..a996411 100644 (file)
@@ -53,11 +53,16 @@ namespace zypp
             **/
            ProblemSolutionCombi( ResolverProblem_Ptr parent );
            /**
-            * Add a single action
+            * Add a single action of an item
             */
            void addSingleAction( PoolItem item, const TransactionKind action);
 
            /**
+            * Add a single action of an capability
+            */
+           void addSingleAction( Capability capability, const TransactionKind action);     
+
+           /**
             * returns the number of actions
             */
            int actionCount() { return actNumber;}
index 35367d0..d98731f 100644 (file)
@@ -1067,14 +1067,7 @@ SATResolver::problems ()
                                break;
                            case SOLVER_INSTALL_SOLVABLE_PROVIDES:
                                {
-                               Id p, *pp;
-                               FOR_PROVIDES(p, pp, what);
-                               {
-                                   PoolItem poolItem = _pool.find (sat::Solvable(p));
-                                   if (poolItem.status().isToBeInstalled()
-                                       || poolItem.status().staysUninstalled())
-                                       problemSolution->addSingleAction (poolItem, KEEP);
-                               }
+                               problemSolution->addSingleAction (Capability(what), REMOVE_REQUIRE);
                                string description = str::form (_("do not ask to install a solvable providing %s"), dep2str(pool, what));
                                MIL << description << endl;
                                problemSolution->addDescription (description);
@@ -1082,14 +1075,7 @@ SATResolver::problems ()
                                break;
                            case SOLVER_ERASE_SOLVABLE_PROVIDES:
                                {
-                               Id p, *pp;
-                               FOR_PROVIDES(p, pp, what);
-                               {
-                                   PoolItem poolItem = _pool.find (sat::Solvable(p));
-                                   if (poolItem.status().isToBeUninstalled()
-                                       || poolItem.status().staysInstalled())
-                                       problemSolution->addSingleAction (poolItem, KEEP);
-                               }
+                               problemSolution->addSingleAction (Capability(what), REMOVE_CONFLICT);                               
                                string description = str::form (_("do not ask to delete all solvables providing %s"), dep2str(pool, what));
                                MIL << description << endl;
                                problemSolution->addDescription (description);
index bc9a71d..1c4d48e 100644 (file)
@@ -63,13 +63,14 @@ TransactionSolutionAction::dumpOn( ostream& os) const
 {
     os << "TransactionSolutionAction: ";
     switch (_action) {
-       case KEEP:      os << "Keep"; break;
-       case INSTALL:   os << "Install"; break;
-       case REMOVE:    os << "Remove"; break;
-       case UNLOCK:    os << "Unlock"; break;
+       case KEEP:              os << "Keep " << _item; break;
+       case INSTALL:           os << "Install " << _item; break;
+       case REMOVE:            os << "Remove " << _item; break;
+       case UNLOCK:            os << "Unlock " << _item; break;
+       case REMOVE_REQUIRE:    os << "Remove require " << _capability; break;
+       case REMOVE_CONFLICT:   os << "Remove conflict " << _capability; break;     
     }
-    os << " ";
-    os << _item;
+
     os << endl;
     return os;
 }
@@ -151,6 +152,12 @@ TransactionSolutionAction::execute(Resolver & resolver) const
            ret = _item.status().setLock (false, ResStatus::USER);
            if (!ret) ERR << "Cannot unlock " << _item << endl;
            break;
+       case REMOVE_REQUIRE:
+           resolver.removeExtraRequire (_capability);
+           break;          
+       case REMOVE_CONFLICT:
+           resolver.removeExtraConflict (_capability);
+           break;          
        default:
            ERR << "Wrong TransactionKind" << endl;
            ret = false;
index 8ca9b2c..e38d309 100644 (file)
@@ -67,7 +67,9 @@ namespace zypp
            KEEP,
            INSTALL,
            REMOVE,
-           UNLOCK
+           UNLOCK,
+           REMOVE_REQUIRE,
+           REMOVE_CONFLICT,
        } TransactionKind;
 
 
@@ -79,6 +81,11 @@ namespace zypp
                : SolutionAction(),
                  _item( item ), _action( action ) {}
 
+           TransactionSolutionAction( Capability capability,
+                                      TransactionKind action )
+               : SolutionAction(),
+                 _capability( capability ), _action( action ) {}
+
            TransactionSolutionAction( TransactionKind action )
                : SolutionAction(),
                  _item(), _action( action ) {}
@@ -99,6 +106,7 @@ namespace zypp
        protected:
 
            PoolItem _item;
+           Capability _capability;
            const TransactionKind _action;
        };