added -IgnoreMap _ignoreConflicts- and -IgnoreMap _ignoreRequires- to Resolver for...
authorStefan Schubert <schubi@suse.de>
Wed, 1 Feb 2006 11:09:02 +0000 (11:09 +0000)
committerStefan Schubert <schubi@suse.de>
Wed, 1 Feb 2006 11:09:02 +0000 (11:09 +0000)
zypp/solver/detail/ProblemSolutionIgnore.cc
zypp/solver/detail/ProblemSolutionIgnore.h
zypp/solver/detail/Resolver.cc
zypp/solver/detail/Resolver.h
zypp/solver/detail/ResolverQueue.h
zypp/solver/detail/Resolver_problems.cc
zypp/solver/detail/SolutionAction.cc
zypp/solver/detail/SolutionAction.h

index cb798d6..ef5edfe 100644 (file)
@@ -50,18 +50,35 @@ ProblemSolutionIgnore::ProblemSolutionIgnore( ResolverProblem_Ptr parent,
     : ProblemSolution (parent, "", "")
 {
     if (kind == Dep::CONFLICTS) {
+       ERR << "Need BOTH resolvalbes; use the other constructor of  ProblemSolutionIgnore" << endl;
+    } else if (kind == Dep::REQUIRES) { 
+       _description = _("Ignoring this requirement");
+       addAction ( new InjectSolutionAction (item, capability, kind));         
+    } else {  
+       ERR << "Wrong kind of capability: " << kind << endl;
+    }
+}
+
+ProblemSolutionIgnore::ProblemSolutionIgnore( ResolverProblem_Ptr parent,
+                                             const Dep &kind, 
+                                             PoolItem_Ref item,
+                                             const Capability & capability,
+                                             PoolItem_Ref otherItem)
+    : ProblemSolution (parent, "", "")
+{
+    if (kind == Dep::CONFLICTS) {
        // TranslatorExplanation %s = name of package, patch, selection ...
        _description = str::form (_("Ignoring conflict of %s"),
                                  item->name().c_str());
-       addAction (new InjectSolutionAction (item, capability, kind));  
-    } else if (kind == Dep::PROVIDES) { 
+       addAction (new InjectSolutionAction (item, capability, kind, otherItem));       
+    } else if (kind == Dep::REQUIRES) { 
        _description = _("Ignoring this requirement");
        addAction ( new InjectSolutionAction (item, capability, kind));         
     } else {  
        ERR << "Wrong kind of capability: " << kind << endl;
     }
 }
-
+       
       ///////////////////////////////////////////////////////////////////
     };// namespace detail
     /////////////////////////////////////////////////////////////////////
index 310ad47..6751fc9 100644 (file)
@@ -52,6 +52,11 @@ namespace zypp
                                   const Dep &dep,
                                   PoolItem_Ref item,
                                   const Capability & capability);
+           ProblemSolutionIgnore( ResolverProblem_Ptr parent,
+                                  const Dep &dep,
+                                  PoolItem_Ref item,
+                                  const Capability & capability,
+                                  PoolItem_Ref otherItem);         
        };
 
       ///////////////////////////////////////////////////////////////////
index 21637ee..4e11cc1 100644 (file)
@@ -201,6 +201,20 @@ Resolver::addExtraConflict (const Capability & capability)
     _extra_conflicts.insert (capability);
 }
 
+void
+Resolver::addIgnoreConflict (const PoolItem_Ref item,
+                  const Capability & capability)
+{
+    _ignoreConflicts[item] = capability;
+}
+void
+Resolver::addIgnoreRequires (const PoolItem_Ref item,
+                            const Capability & capability)
+{
+    _ignoreRequires[item] = capability;
+}
+
+
 
 //---------------------------------------------------------------------------
 
index c37b3c2..7db1253 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <iosfwd>
 #include <list>
+#include <map>
 #include <string>
 
 #include "zypp/base/ReferenceCounted.h"
@@ -74,6 +75,9 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable {
     CapSet _extra_caps;
     CapSet _extra_conflicts;
 
+    IgnoreMap _ignoreConflicts;
+    IgnoreMap _ignoreRequires;    
+
     ResolverQueueList _pending_queues;
     ResolverQueueList _pruned_queues;
     ResolverQueueList _complete_queues;
@@ -137,6 +141,11 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable {
     void addExtraCapability (const Capability & capability);
     void addExtraConflict (const Capability & capability);
 
+    void addIgnoreConflict (const PoolItem_Ref item,
+                           const Capability & capability);
+    void addIgnoreRequires (const PoolItem_Ref item,
+                           const Capability & capability);
+
     void verifySystem (void);
     void establishState (const ResolverContext_Ptr context = NULL);
     void establishPool (void);
index 7faa73f..e676ec5 100644 (file)
@@ -47,6 +47,8 @@ namespace zypp
     { ///////////////////////////////////////////////////////////////////
 
 typedef std::list <ResolverQueue_Ptr> ResolverQueueList;
+typedef std::map<PoolItem_Ref,Capability> IgnoreMap;
+           
 
 ///////////////////////////////////////////////////////////////////
 //
@@ -58,6 +60,8 @@ class ResolverQueue : public base::ReferenceCounted, private base::NonCopyable {
 
     ResolverContext_Ptr _context;
     QueueItemList _qitems;
+    IgnoreMap _ignoreConflicts;
+    IgnoreMap _ignoreRequires;
 
   public:
     ResolverQueue (const ResPool & pool, ResolverContext_Ptr context = NULL);
@@ -83,6 +87,12 @@ class ResolverQueue : public base::ReferenceCounted, private base::NonCopyable {
     void addExtraConflict (const Capability & cap);
     void addItem (QueueItem_Ptr qtem);
 
+    void setIgnoreConflicts(const IgnoreMap & ignoreMap)
+       { _ignoreConflicts = ignoreMap; }
+
+    void setIgnoreRequires(const IgnoreMap & ignoreMap)
+       { _ignoreRequires = ignoreMap; }
+
     bool isEmpty () const { return _qitems.empty(); }
     bool isInvalid ();
     bool containsOnlyBranches ();
index 9ac042d..f3bb1ef 100644 (file)
@@ -279,7 +279,7 @@ Resolver::problems (void) const
                details = misc_info->message();
                ResolverProblem_Ptr problem = new ResolverProblem (what, details);
                // Add dummy provides
-               problem->addSolution (new ProblemSolutionIgnore (problem, Dep::PROVIDES, item, misc_info->capability())); 
+               problem->addSolution (new ProblemSolutionIgnore (problem, Dep::REQUIRES, item, misc_info->capability())); 
                problems.push_back (problem);
                problem_created = true;
            }
@@ -291,7 +291,7 @@ Resolver::problems (void) const
                details = misc_info->message();
                ResolverProblem_Ptr problem = new ResolverProblem (what, details);
                // Add dummy provides
-               problem->addSolution (new ProblemSolutionIgnore (problem, Dep::PROVIDES, item, misc_info->capability())); 
+               problem->addSolution (new ProblemSolutionIgnore (problem, Dep::REQUIRES, item, misc_info->capability())); 
                problems.push_back (problem);
                problem_created = true;         
            }
@@ -347,7 +347,7 @@ Resolver::problems (void) const
                what = misc_info->message();
                ResolverProblem_Ptr problem = new ResolverProblem (what, details);
                // Add dummy provides
-               problem->addSolution (new ProblemSolutionIgnore (problem, Dep::PROVIDES, item, misc_info->capability())); 
+               problem->addSolution (new ProblemSolutionIgnore (problem, Dep::REQUIRES, item, misc_info->capability())); 
                problems.push_back (problem);
                problem_created = true;         
            }
@@ -392,7 +392,8 @@ Resolver::problems (void) const
                // Uninstall p
                problem->addSolution (new ProblemSolutionUninstall (problem, resItem));
                // Remove conflict in the resolvable which has to be installed
-               problem->addSolution (new ProblemSolutionIgnore (problem, Dep::CONFLICTS, resItem, misc_info->capability())); 
+               problem->addSolution (new ProblemSolutionIgnore (problem, Dep::CONFLICTS, resItem, misc_info->capability(),
+                                                                misc_info->other())); 
                problems.push_back (problem);
                problem_created = true;
 #endif
@@ -412,7 +413,8 @@ Resolver::problems (void) const
                // Uninstall p
                problem->addSolution (new ProblemSolutionUninstall (problem, resItem));
                // Remove conflict in the resolvable which has to be installed
-               problem->addSolution (new ProblemSolutionIgnore (problem, Dep::CONFLICTS, resItem, misc_info->capability())); 
+               problem->addSolution (new ProblemSolutionIgnore (problem, Dep::CONFLICTS, resItem, misc_info->capability(),
+                                                                misc_info->other())); 
                problems.push_back (problem);
                problem_created = true;         
 #endif
index 4ac9af4..25a7222 100644 (file)
@@ -142,20 +142,23 @@ TransactionSolutionAction::execute(Resolver & resolver) const
 bool
 InjectSolutionAction::execute(Resolver & resolver) const
 {
-    ResObject::constPtr resolvable = _item.resolvable();
-    CapSet dep;
-    
-    dep.insert(_capability);
-    Dependencies dependencies;
-
     if (_kind == Dep::CONFLICTS) {
-       // removing provide, it the other resolvable has the conflict
-       dependencies[Dep::PROVIDES] = dep;
-       // removing conflict
-       dependencies[Dep::CONFLICTS] = dep;             
+       // removing conflict in both resolvables
+       Dependencies dependencies = _item.resolvable()->deps();
+       CapSet depList = dependencies[Dep::CONFLICTS];
+       if (depList.find(_capability) != depList.end())
+       {
+           resolver.addIgnoreConflict (_item, _capability);
+       }
+       dependencies = _otherItem.resolvable()->deps();
+       depList = dependencies[Dep::CONFLICTS];
+       if (depList.find(_capability) != depList.end())
+       {
+           resolver.addIgnoreConflict (_otherItem, _capability);
+       }
     } else if (_kind  == Dep::PROVIDES) {
        // removing the requires dependency from the item
-       dependencies[Dep::REQUIRES] = dep;
+       resolver.addIgnoreRequires (_item, _capability);
     } else {
        ERR << "No valid InjectSolutionAction kind found" << endl;
        return false;
index eea706f..bdc2f8f 100644 (file)
@@ -107,10 +107,20 @@ namespace zypp
        class InjectSolutionAction: public SolutionAction
        {
        public:
+
+           InjectSolutionAction( PoolItem_Ref item,
+                                 const Capability & capability,
+                                 const Dep & kind)
+               : SolutionAction(),
+                 _capability( capability ), _kind( kind ),
+                 _otherItem() {}
            
-           InjectSolutionAction( PoolItem_Ref item, const Capability & capability, const Dep & kind )
+           InjectSolutionAction( PoolItem_Ref item,
+                                 const Capability & capability,
+                                 const Dep & kind,
+                                 PoolItem_Ref otherItem)
                : SolutionAction(),
-                 _capability( capability ), _kind( kind ) {}
+                 _capability( capability ), _kind( kind ), _otherItem( otherItem ) {}
 
          // ---------------------------------- I/O
 
@@ -126,8 +136,8 @@ namespace zypp
        protected:
 
            const Capability & _capability;
-           PoolItem_Ref _item;     
            const Dep & _kind;
+           PoolItem_Ref _item, _otherItem;         
        };