cleanup in ignore dependencies
authorStefan Schubert <schubi@suse.de>
Mon, 21 Apr 2008 12:12:09 +0000 (12:12 +0000)
committerStefan Schubert <schubi@suse.de>
Mon, 21 Apr 2008 12:12:09 +0000 (12:12 +0000)
zypp/solver/detail/ProblemSolutionIgnore.cc
zypp/solver/detail/ProblemSolutionIgnore.h
zypp/solver/detail/Resolver.cc
zypp/solver/detail/Resolver.h
zypp/solver/detail/SolutionAction.cc
zypp/solver/detail/SolutionAction.h

index 34ff2329790d5437494d133caecb4748683f9929..0cbb3733d8ca0f9ce9dc24a91fa56abd7a3585dd 100644 (file)
@@ -40,112 +40,30 @@ namespace zypp
     namespace detail
     { ///////////////////////////////////////////////////////////////////
 
-IMPL_PTR_TYPE(ProblemSolutionIgnoreConflicts);
-IMPL_PTR_TYPE(ProblemSolutionIgnoreRequires);
-IMPL_PTR_TYPE(ProblemSolutionIgnoreArchitecture);
-IMPL_PTR_TYPE(ProblemSolutionIgnoreVendor);    
-IMPL_PTR_TYPE(ProblemSolutionIgnoreInstalled); 
+IMPL_PTR_TYPE(ProblemSolutionIgnore);
 
 //---------------------------------------------------------------------------
 
-ProblemSolutionIgnoreRequires::ProblemSolutionIgnoreRequires( ResolverProblem_Ptr parent,
-                                                             PoolItem item,
-                                                             const Capability & capability)
+ProblemSolutionIgnore::ProblemSolutionIgnore( ResolverProblem_Ptr parent,
+                                             PoolItem item )
     : ProblemSolution (parent, "", "")
 {
-       _description = _("Ignore this requirement just here");
-       addAction ( new InjectSolutionAction (item, capability, REQUIRES));
-}      
-       
-ProblemSolutionIgnoreRequires::ProblemSolutionIgnoreRequires( ResolverProblem_Ptr parent,
-                                                             PoolItemList itemList,      
-                                                             const Capability & capability)
-    : ProblemSolution (parent, "", "")
-{
-       _description = _("Generally ignore this requirement");
-       for (PoolItemList::const_iterator iter = itemList.begin();
-            iter != itemList.end(); iter++) {
-           addAction ( new InjectSolutionAction (*iter, capability, REQUIRES));
-       }
-}
+    // TranslatorExplanation %s = name of package, patch, selection ...    
+    _description = str::form (_("Ignore some dependencies for %s"), item->name().c_str() );
 
-ProblemSolutionIgnoreArchitecture::ProblemSolutionIgnoreArchitecture( ResolverProblem_Ptr parent,
-                                                                 PoolItem item)
-    : ProblemSolution (parent, "", "")
-{
-        // TranslatorExplanation %s = name of package, patch, selection ...
-       _description = str::form(_("Install %s although it would change the architecture"),
-                                item->name().c_str());
-       // TranslatorExplanation %s = name of package, patch, selection ...     
-       _details = str::form(_("%s provides this dependency, but would change the architecture of the installed item"),
-                           Helper::itemToString (item).c_str());
-       addAction ( new InjectSolutionAction (item, ARCHITECTURE));
-}
-
-ProblemSolutionIgnoreVendor::ProblemSolutionIgnoreVendor( ResolverProblem_Ptr parent,
-                                                         PoolItem item)
-    : ProblemSolution (parent, "", "")
-{
-        // TranslatorExplanation %s = name of package, patch, selection ...
-       _description = str::form(_("Install %s although it would change the vendor"),
-                                item->name().c_str());
-       // TranslatorExplanation %s = name of package, patch, selection ...     
-       _details = str::form(_("%s provides this dependency, but would change the vendor of the installed item"),
-                           Helper::itemToString (item).c_str());
-       addAction ( new InjectSolutionAction (item, VENDOR));
-}
+//    addAction ( new InjectSolutionAction (item, capability, REQUIRES));
+}      
        
-ProblemSolutionIgnoreConflicts::ProblemSolutionIgnoreConflicts( ResolverProblem_Ptr parent,
-                                                               PoolItem item,
-                                                               const Capability & capability,
-                                                               PoolItem otherItem)
+ProblemSolutionIgnore::ProblemSolutionIgnore( ResolverProblem_Ptr parent,
+                                             PoolItemList itemList )
     : ProblemSolution (parent, "", "")
 {
-       // TranslatorExplanation %s = name of package, patch, selection ...
-       _description = str::form (_("Ignore this conflict of %s"),
-                                 item->name().c_str());
-       addAction (new InjectSolutionAction (item, capability, CONFLICTS, otherItem));  
-}
-
-ProblemSolutionIgnoreConflicts::ProblemSolutionIgnoreConflicts( ResolverProblem_Ptr parent,
-                                                               PoolItem item,
-                                                               const Capability & capability,
-                                                               PoolItemList itemList)
-    : ProblemSolution (parent, "", "")
-{
-       // TranslatorExplanation %s = name of package, patch, selection ...
-       _description = str::form (_("Ignore this conflict of %s"),
-                                 item->name().c_str());
+       _description = _("Generally ignore of some dependecies");
        for (PoolItemList::const_iterator iter = itemList.begin();
             iter != itemList.end(); iter++) {
-           addAction (new InjectSolutionAction (item, capability, CONFLICTS, *iter));              
+//         addAction ( new InjectSolutionAction (*iter, capability, REQUIRES));
        }
 }
-
-ProblemSolutionIgnoreObsoletes::ProblemSolutionIgnoreObsoletes( ResolverProblem_Ptr parent,
-                                                               PoolItem item,
-                                                               const Capability & capability,
-                                                               PoolItem otherItem)
-    : ProblemSolution (parent, "", "")
-{
-       // TranslatorExplanation %s = name of package, patch, selection ...
-       _description = str::form (_("Ignore the obsolete %s in %s"),
-                                 Helper::capToString (capability).c_str(),
-                                 otherItem->name().c_str());
-       addAction (new InjectSolutionAction (item, capability, OBSOLETES, otherItem));  
-}
-
-
-ProblemSolutionIgnoreInstalled::ProblemSolutionIgnoreInstalled( ResolverProblem_Ptr parent,
-                                                               PoolItem item,
-                                                               PoolItem otherItem)
-    : ProblemSolution (parent, "", "")
-{
-       // TranslatorExplanation %s = name of package, patch, selection ...
-       _description = str::form (_("Ignore that %s is already set to install"),
-                                 item->name().c_str());
-       addAction (new InjectSolutionAction (item, Capability(), INSTALLED, otherItem));        
-}
        
       ///////////////////////////////////////////////////////////////////
     };// namespace detail
index 219e9856f902b589865ef48cb46d5adbd11de74d..376502341dac25bb0c536cbc1175f070e0f73bd4 100644 (file)
@@ -37,87 +37,22 @@ namespace zypp
 
        /**
         * Class representing one possible solution to one problem found during resolving
-        * This problem solution ignores one or more items
-        * 
+        * This problem solution ignores one or more items by setting his dependencies
+        * to weak
         **/
-       class ProblemSolutionIgnoreConflicts : public ProblemSolution
+       class ProblemSolutionIgnore : public ProblemSolution
        {
        public:
 
            /**
             * Constructor.
             **/
-           ProblemSolutionIgnoreConflicts( ResolverProblem_Ptr parent,
-                                           PoolItem item,
-                                           const Capability & capability,
-                                           PoolItem otherItem);
-           ProblemSolutionIgnoreConflicts( ResolverProblem_Ptr parent,
-                                           PoolItem item,
-                                           const Capability & capability,
-                                           PoolItemList itemList);         
+           ProblemSolutionIgnore( ResolverProblem_Ptr parent,
+                                  PoolItem item );
+           ProblemSolutionIgnore( ResolverProblem_Ptr parent,
+                                  PoolItemList itemList);          
        };
 
-       class ProblemSolutionIgnoreRequires : public ProblemSolution
-       {
-       public:
-
-           /**
-            * Constructor.
-            **/
-           ProblemSolutionIgnoreRequires( ResolverProblem_Ptr parent,
-                                          PoolItem item,
-                                          const Capability & capability);
-           ProblemSolutionIgnoreRequires( ResolverProblem_Ptr parent,
-                                          PoolItemList itemList,
-                                          const Capability & capability);
-       };
-
-       class ProblemSolutionIgnoreArchitecture : public ProblemSolution
-       {
-       public:
-
-           /**
-            * Constructor.
-            **/
-           ProblemSolutionIgnoreArchitecture( ResolverProblem_Ptr parent,
-                                              PoolItem item);
-       };
-
-       class ProblemSolutionIgnoreVendor : public ProblemSolution
-       {
-       public:
-
-           /**
-            * Constructor.
-            **/
-           ProblemSolutionIgnoreVendor( ResolverProblem_Ptr parent,
-                                        PoolItem item);
-       };              
-
-       class ProblemSolutionIgnoreObsoletes : public ProblemSolution
-       {
-       public:
-
-           /**
-            * Constructor.
-            **/
-           ProblemSolutionIgnoreObsoletes( ResolverProblem_Ptr parent,
-                                           PoolItem item,
-                                           const Capability & capability,
-                                           PoolItem otherItem);            
-       };
-
-       class ProblemSolutionIgnoreInstalled : public ProblemSolution
-       {
-       public:
-
-           /**
-            * Constructor.
-            **/
-           ProblemSolutionIgnoreInstalled( ResolverProblem_Ptr parent,
-                                           PoolItem item,
-                                           PoolItem otherItem);  
-       };
        
 
       ///////////////////////////////////////////////////////////////////
index 076b3a3094c4bf584cffb378fd27f1f9dfc4fe01..495b390aa5ad3cc4e55ad54b798506a9cb451dac 100644 (file)
@@ -139,42 +139,9 @@ Resolver::removeExtraConflict (const Capability & capability)
 }
 
 void
-Resolver::addIgnoreConflict (const PoolItem item,
-                  const Capability & capability)
+Resolver::addWeak (const PoolItem item)
 {
-    _ignoreConflicts.insert(make_pair(item, capability));
-}
-
-void
-Resolver::addIgnoreRequires (const PoolItem item,
-                            const Capability & capability)
-{
-    _ignoreRequires.insert(make_pair(item, capability));
-}
-
-void
-Resolver::addIgnoreObsoletes (const PoolItem item,
-                             const Capability & capability)
-{
-    _ignoreObsoletes.insert(make_pair(item, capability));
-}
-
-void
-Resolver::addIgnoreInstalledItem (const PoolItem item)
-{
-    _ignoreInstalledItem.push_back (item);
-}
-
-void
-Resolver::addIgnoreArchitectureItem (const PoolItem item)
-{
-    _ignoreArchitectureItem.push_back (item);
-}
-
-void
-Resolver::addIgnoreVendorItem (const PoolItem item)
-{
-    _ignoreVendorItem.push_back (item);
+    _addWeak.push_back (item);
 }
 
 //---------------------------------------------------------------------------
@@ -237,21 +204,8 @@ Resolver::undo(void)
     invokeOnEach ( _pool.begin(), _pool.end(),
                   resfilter::ByTransact( ),                    // collect transacts from Pool to resolver queue
                   functor::functorRef<bool,PoolItem>(info) );
-    // These conflict should be ignored of the concering item
-    _ignoreConflicts.clear();
-    // These requires should be ignored of the concering item
-    _ignoreRequires.clear();
-    // These obsoletes should be ignored of the concering item
-    _ignoreObsoletes.clear();
-    // Ignore architecture of the item
-    _ignoreArchitecture.clear();
-    // Ignore the status "installed" of the item
-    _ignoreInstalledItem.clear();
-    // Ignore the architecture of the item
-    _ignoreArchitectureItem.clear();
-    // Ignore the vendor of the item
-    _ignoreVendorItem.clear();
-
+    //  Regard dependencies of the item weak onl
+    _addWeak.clear();
 
     return;
 }
index 6423e6b06c00d5d903f9f4904b28fd7b89392cf9..adbd6267f337a0fc05efd51ef980ee6ffd405077 100644 (file)
@@ -79,23 +79,8 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable {
     CapabilitySet _extra_requires;
     CapabilitySet _extra_conflicts;
     
-    typedef std::multimap<PoolItem,Capability> IgnoreMap;
-
-    // These conflict should be ignored of the concering item
-    IgnoreMap _ignoreConflicts;
-    // These requires should be ignored of the concering item
-    IgnoreMap _ignoreRequires;
-    // These obsoletes should be ignored of the concering item
-    IgnoreMap _ignoreObsoletes;
-    // Ignore architecture of the item
-    PoolItemList _ignoreArchitecture;
-    // Ignore the status "installed" of the item
-    PoolItemList _ignoreInstalledItem;
-    // Ignore the architecture of the item
-    PoolItemList _ignoreArchitectureItem;
-    // Ignore the vendor of the item
-    PoolItemList _ignoreVendorItem;
-
+    // Regard dependencies of the item weak onl
+    PoolItemList _addWeak;
 
     bool _forceResolve;           // remove items which are conflicts with others or
                                   // have unfulfilled requirements.
@@ -140,15 +125,7 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable {
     const CapabilitySet extraRequires () { return _extra_requires; }
     const CapabilitySet extraConflicts () { return _extra_conflicts; }
 
-    void addIgnoreConflict (const PoolItem item,
-                           const Capability & capability);
-    void addIgnoreRequires (const PoolItem item,
-                           const Capability & capability);
-    void addIgnoreObsoletes (const PoolItem item,
-                            const Capability & capability);
-    void addIgnoreInstalledItem (const PoolItem item);
-    void addIgnoreArchitectureItem (const PoolItem item);
-    void addIgnoreVendorItem (const PoolItem item);    
+    void addWeak (const PoolItem item);
 
     void setForceResolve (const bool force) { _forceResolve = force; }
     bool forceResolve() { return _forceResolve; }
index 4a92424619ba8de0b5c97eded83b8df999df8f4e..bc9a71df09f4237d1acee993119d781fb3975f29 100644 (file)
@@ -102,15 +102,8 @@ ostream &
 InjectSolutionAction::dumpOn( ostream& os ) const
 {
     os << "InjectSolutionAction: ";
-    os << _capability;
-    os << ", ";
     switch (_kind) {
-       case REQUIRES:  os << "Requires"; break;
-       case CONFLICTS: os << "Conflicts"; break;
-       case OBSOLETES: os << "Obsoletes"; break;
-       case INSTALLED: os << "Installed"; break;
-       case ARCHITECTURE: os << "Architecture"; break;
-       case VENDOR: os << "Vendor"; break;
+       case WEAK:      os << "Weak"; break;
        default: os << "Wrong kind"; break;
     }
     os << " ";
@@ -138,7 +131,6 @@ TransactionSolutionAction::execute(Resolver & resolver) const
     bool ret = true;
     switch (action()) {
        case KEEP:
-           resolver.addIgnoreInstalledItem( _item );
            /*FALLTHRU*/
        case INSTALL:
            if (_item.status().isToBeUninstalled())
@@ -169,72 +161,11 @@ TransactionSolutionAction::execute(Resolver & resolver) const
 bool
 InjectSolutionAction::execute(Resolver & resolver) const
 {
-    Capabilities depList;
-    if (_item != PoolItem()) {
-       depList = _item.resolvable()->dep(Dep::CONFLICTS);
-    }
     switch (_kind) {
-        case CONFLICTS:
-           // removing conflict in both resolvables
-           for (Capabilities::const_iterator iter = depList.begin(); iter != depList.end(); iter++) {
-               if (iter->matches (_capability) == CapMatch::yes )
-               {
-                   resolver.addIgnoreConflict (_item, _capability);
-               }
-           }
-           // Obsoletes are conflicts too
-           depList = _item.resolvable()->dep(Dep::OBSOLETES);
-           for (Capabilities::const_iterator iter = depList.begin(); iter != depList.end(); iter++) {
-               if (iter->matches (_capability) == CapMatch::yes )
-               {
-                   resolver.addIgnoreConflict (_otherItem, _capability);
-               }
-           }
-
-           depList = _otherItem.resolvable()->dep(Dep::CONFLICTS);
-           for (Capabilities::const_iterator iter = depList.begin(); iter != depList.end(); iter++) {
-               if (iter->matches (_capability) == CapMatch::yes )
-               {
-                   resolver.addIgnoreConflict (_otherItem, _capability);
-               }
-           }
-           // Obsoletes are conflicts too
-           depList = _otherItem.resolvable()->dep(Dep::OBSOLETES);
-           for (Capabilities::const_iterator iter = depList.begin(); iter != depList.end(); iter++) {
-               if (iter->matches (_capability) == CapMatch::yes )
-               {
-                   resolver.addIgnoreConflict (_otherItem, _capability);
-               }
-           }
-
-           break;
-        case REQUIRES:
-           // removing the requires dependency from the item
-           if (_item == PoolItem()) {
-               // this was a requirement via Resolver::addExtraCapability
-               // so we have to delete it.
-               resolver.removeExtraRequire (_capability);
-           } else {
-               resolver.addIgnoreRequires (_item, _capability);
-           }
-           break;
-        case ARCHITECTURE:
-           // This item is for ALL architectures available
-           resolver.addIgnoreArchitectureItem (_item);
-           break;
-        case VENDOR:
-           // This item is for ALL vendor available
-           resolver.addIgnoreVendorItem (_item);
-           break;
-        case OBSOLETES:
-           // removing the obsoletes dependency from the item
-           resolver.addIgnoreObsoletes (_otherItem, _capability);
-           break;
-        case INSTALLED:
-           // ignoring already installed items
-           resolver.addIgnoreInstalledItem (_item);
-           resolver.addIgnoreInstalledItem (_otherItem);
-           break;
+        case WEAK:
+           // set item dependencies to weak
+           resolver.addWeak (_item);
+            break;
         default:
            ERR << "No valid InjectSolutionAction kind found" << endl;
            return false;
index b2d83ae759cae2c021dc9efa0ef20cc97fa94a84..8ca9b2c0a256c824e9dfb5c2a183d83ff078f698 100644 (file)
@@ -104,17 +104,12 @@ namespace zypp
 
 
        /**
-        * Type of ignoring dependencies, architectures and vendor
+        * Type of ignoring; currently only WEAK
         **/
 
        typedef enum
        {
-           REQUIRES,
-           CONFLICTS,
-           OBSOLETES,
-           INSTALLED,
-           ARCHITECTURE,
-           VENDOR
+           WEAK
        } InjectSolutionKind;
 
 
@@ -130,25 +125,10 @@ namespace zypp
        public:
 
            InjectSolutionAction( PoolItem item,
-                                 const Capability & capability,
                                  const InjectSolutionKind & kind)
                : SolutionAction(),
-                 _item( item ), _capability( capability ),
-                 _kind( kind ), _otherItem() {}
-
-           InjectSolutionAction( PoolItem item,
-                                 const InjectSolutionKind & kind)
-               : SolutionAction(),
-                 _item( item ), _capability(),
-                 _kind( kind ), _otherItem() {}
-
-           InjectSolutionAction( PoolItem item,
-                                 const Capability & capability,
-                                 const InjectSolutionKind & kind,
-                                 PoolItem otherItem)
-               : SolutionAction(),
-                 _item( item ), _capability( capability ),
-                 _kind( kind ), _otherItem( otherItem ) {}
+                 _item( item ), 
+                 _kind( kind ) {}
 
          // ---------------------------------- I/O
          virtual std::ostream & dumpOn( std::ostream & str ) const;
@@ -156,7 +136,6 @@ namespace zypp
                { return action.dumpOn (str); }
 
          // ---------------------------------- accessors
-           const Capability & capability() const { return _capability; };
            const PoolItem item() const { return _item; }
 
          // ---------------------------------- methods
@@ -164,9 +143,7 @@ namespace zypp
 
        protected:
            PoolItem _item;
-           const Capability _capability;
            const InjectSolutionKind _kind;
-           PoolItem _otherItem;
        };