- On demand translate patch requirements into a list of atoms.
authorMichael Andres <ma@suse.de>
Fri, 31 Aug 2007 17:58:27 +0000 (17:58 +0000)
committerMichael Andres <ma@suse.de>
Fri, 31 Aug 2007 17:58:27 +0000 (17:58 +0000)
  Required by the UI to display packages acssociated with a patch.

VERSION.cmake
package/libzypp.changes
zypp/detail/PatchImplIf.cc
zypp/detail/PatchImplIf.h

index 6235f92..1e2019b 100644 (file)
@@ -47,4 +47,4 @@
 SET(LIBZYPP_MAJOR "3")
 SET(LIBZYPP_MINOR "21")
 SET(LIBZYPP_COMPATMINOR "21")
-SET(LIBZYPP_PATCH "0")
+SET(LIBZYPP_PATCH "1")
index c6c038e..d78c1b6 100644 (file)
@@ -1,4 +1,12 @@
 -------------------------------------------------------------------
+Fri Aug 31 19:56:40 CEST 2007 - ma@suse.de
+
+- On demand translate patch requirements into a list of atoms.
+  Required by the UI to display packages acssociated with a patch.
+  (#300612)
+- version 3.21.1
+
+-------------------------------------------------------------------
 Fri Aug 31 13:59:54 CEST 2007 - kkaempf@suse.de
 
 - enrich ResolverInfo with the reason if a user-initiated request
index 72cff85..959f3a2 100644 (file)
@@ -9,8 +9,17 @@
 /** \file      zypp/detail/PatchImplIf.cc
  *
 */
+#include <iostream>
+
+#include "zypp/base/Easy.h"
+#include "zypp/base/Logger.h"
+#include "zypp/ResStore.h"
+#include "zypp/CapMatchHelper.h"
+
 #include "zypp/detail/PatchImplIf.h"
 
+using std::endl;
+
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
@@ -61,7 +70,43 @@ namespace zypp
 
     PatchImplIf::AtomList PatchImplIf::all_atoms() const
     {
-      return AtomList();
+      if ( ! _atomlist )
+      {
+        if ( ! hasBackRef() )
+        {
+          // We are not jet connected to the Resolvable that
+          // contains our dependencies.
+          return AtomList();
+        }
+
+        // lazy init
+        _atomlist.reset( new AtomList );
+
+        // Build the list using the repositories resolvables.
+        // Installed Patches (no repository) have this method overloaded.
+        if ( repository() )
+        {
+          const CapSet &   requires( self()->dep( Dep::REQUIRES ) );
+          const ResStore & store( repository().resolvables() );
+
+          for_( req, requires.begin(), requires.end() )
+          {
+            // lookup Patch requirements that refer to an Atom, Script or Message.
+            if ( refersTo<Atom>( *req ) || refersTo<Script>( *req ) || refersTo<Message>( *req ) )
+            {
+              for_( res, store.begin(), store.end() )
+              {
+                // Collect ALL matches in the store.
+                if ( hasMatches( (*res)->dep( Dep::PROVIDES ), (*req) ) )
+                {
+                  _atomlist->push_back( *res );
+                }
+              }
+            }
+          }
+        }
+      }
+      return *_atomlist;
     }
 
     /////////////////////////////////////////////////////////////////
index 87bfbed..6b43c10 100644 (file)
@@ -60,6 +60,9 @@ namespace zypp
        * \warning Computed here, usually no need to overload this.
       */
       virtual AtomList all_atoms() const PURE_VIRTUAL;
+
+    private:
+      mutable scoped_ptr<AtomList> _atomlist;
     };
     ///////////////////////////////////////////////////////////////////