- Adapt to new product handling. Products are no longer pseudo
authorMichael Andres <ma@suse.de>
Fri, 8 Aug 2008 11:34:40 +0000 (11:34 +0000)
committerMichael Andres <ma@suse.de>
Fri, 8 Aug 2008 11:34:40 +0000 (11:34 +0000)
  installed objects verified by the solver, but actually installed.
  Thus removed satisfiedProduct iterator, fixed Selctables.
- Removed class ProductInfo as we keep Product.

16 files changed:
devel/devel.ma/NewPool.cc
package/libzypp.changes
zypp/CMakeLists.txt
zypp/Filter.h
zypp/ProductInfo.cc [deleted file]
zypp/ProductInfo.h [deleted file]
zypp/ResObject.cc
zypp/ResObject.h
zypp/ResPool.h
zypp/base/PtrTypes.h
zypp/solver/detail/Testcase.cc
zypp/ui/Selectable.cc
zypp/ui/Selectable.h
zypp/ui/SelectableImpl.cc
zypp/ui/SelectableImpl.h
zypp/ui/SelectableTraits.h

index 652ae2a..d8e769b 100644 (file)
@@ -441,6 +441,28 @@ try {
 
   if ( 1 )
   {
+    Measure x( "INIT TARGET" );
+    {
+      {
+        zypp::base::LogControl::TmpLineWriter shutUp;
+        getZYpp()->initializeTarget( sysRoot );
+      }
+      getZYpp()->target()->load();
+    }
+  }
+
+  dumpRange( USR, satpool.reposBegin(), satpool.reposEnd() );
+  USR << "pool: " << pool << endl;
+  ui::Selectable::Ptr t( getSel<Package>( "test" ) );
+  MIL << dump(t) << endl;
+
+   ///////////////////////////////////////////////////////////////////
+  INT << "===[END]============================================" << endl << endl;
+  zypp::base::LogControl::instance().logNothing();
+  return 0;
+
+  if ( 0 )
+  {
     RepoManager repoManager( makeRepoManager( sysRoot ) );
     RepoInfoList repos = repoManager.knownRepositories();
 
@@ -497,18 +519,6 @@ try {
     }
   }
 
-  if ( 0 )
-  {
-    Measure x( "INIT TARGET" );
-    {
-      {
-        zypp::base::LogControl::TmpLineWriter shutUp;
-        getZYpp()->initializeTarget( sysRoot );
-      }
-      getZYpp()->target()->load();
-    }
-  }
-
   dumpRange( USR, satpool.reposBegin(), satpool.reposEnd() );
   USR << "pool: " << pool << endl;
 
index 114dc48..42491a6 100644 (file)
@@ -1,4 +1,13 @@
 -------------------------------------------------------------------
+Fri Aug  8 13:27:42 CEST 2008 - ma@suse.de
+
+- Adapt to new product handling. Products are no longer pseudo
+  installed objects verified by the solver, but actually installed. 
+  Thus removed satisfiedProduct iterator, fixed Selctables. 
+- Removed class ProductInfo as we keep Product.
+- revision 10797
+
+-------------------------------------------------------------------
 Thu Aug  7 22:00:55 CEST 2008 - dmacvicar@suse.de
 
 - implement relogin suggested support (fate#304889)
index a0bfd6c..026c1b9 100644 (file)
@@ -41,7 +41,6 @@ SET( zypp_SRCS
   PoolQueryResult.cc
   ProblemSolution.cc
   Product.cc
-  ProductInfo.cc
   ProgressData.cc
   ProvideFilePolicy.cc
   PublicKey.cc
@@ -128,7 +127,6 @@ SET( zypp_HEADERS
   ProblemSolution.h
   ProblemTypes.h
   Product.h
-  ProductInfo.h
   ProgressData.h
   ProvideFilePolicy.h
   PublicKey.h
index 4363538..9bd16e1 100644 (file)
@@ -130,26 +130,6 @@ namespace zypp
     ///////////////////////////////////////////////////////////////////
 
     ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : SatisfiedProducts
-    //
-    /** Filter returning the satisfied products.
-    */
-    class SatisfiedProducts
-    {
-      public:
-        /** Filter on \ref PoolItem. */
-        bool operator()( const PoolItem & pi_r ) const
-        { return pi_r.satSolvable().isKind( ResKind::product ) && pi_r.isSatisfied(); }
-
-        /** Filter on satSolvabe/ResObject. */
-        template<class _Solv>
-        bool operator()( const _Solv & solv_r ) const
-        { return operator()( PoolItem( solv_r ) ); }
-    };
-    ///////////////////////////////////////////////////////////////////
-
-    ///////////////////////////////////////////////////////////////////
     //@}
     /////////////////////////////////////////////////////////////////
   } // namespace filter
diff --git a/zypp/ProductInfo.cc b/zypp/ProductInfo.cc
deleted file mode 100644 (file)
index 7a1a73c..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/ProductInfo.cc
- *
-*/
-#include <iostream>
-#include "zypp/base/LogTools.h"
-
-#include "zypp/ProductInfo.h"
-#include "zypp/PoolItem.h"
-#include "zypp/Package.h"
-
-using std::endl;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-  namespace
-  {
-    /** Fast check whether a \ref sat::Solvable provides product metadata.
-     * Return the solvable or \ref sat::noSolvable.
-     */
-    sat::Solvable ifProductInfoProvided( sat::Solvable solvable_r )
-    {
-#warning THIS SHOULD BE REPLACED BY A FAST TEST E.G. productName
-      // and use detail::IdType lookupIdAttribute for this test
-
-      if ( solvable_r.lookupStrAttribute( sat::SolvAttr::productShortlabel ).empty() )
-        return sat::Solvable::noSolvable;
-      return solvable_r;
-    }
-
-    /** List attribute helper */
-    void fillList( std::list<Url> & ret_r, sat::Solvable solv_r, sat::SolvAttr attr_r )
-    {
-      sat::LookupAttr query( attr_r, solv_r );
-      for_( it, query.begin(), query.end() )
-      {
-        try // ignore malformed urls
-        {
-          ret_r.push_back( Url( it.asString() ) );
-        }
-        catch( const url::UrlException & )
-        {}
-      }
-    }
-
-    /** List attribute helper */
-    void fillList( std::list<std::string> & ret_r, sat::Solvable solv_r, sat::SolvAttr attr_r )
-    {
-      sat::LookupAttr query( attr_r, solv_r );
-      for_( it, query.begin(), query.end() )
-      {
-        ret_r.push_back( it.asString() );
-      }
-    }
-  }
-
-  ///////////////////////////////////////////////////////////////////
-
-  const ProductInfo ProductInfo::noProductInfo;
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   METHOD NAME : ProductInfo::ProductInfo
-  //   METHOD TYPE : Ctor
-  //
-  ProductInfo::ProductInfo()
-  {}
-
-  ProductInfo::ProductInfo( sat::Solvable solvable_r )
-  : sat::Solvable( ifProductInfoProvided( solvable_r ) )
-  {}
-
-  ProductInfo::ProductInfo( const PoolItem & poolItem_r )
-  : sat::Solvable( ifProductInfoProvided( poolItem_r.satSolvable() ) )
-  {}
-
-  ProductInfo::ProductInfo( const ResTraits<ResObject>::constPtrType & package_r )
-  : sat::Solvable( package_r ? ifProductInfoProvided( package_r->satSolvable() )
-                             : sat::Solvable::noSolvable )
-  {}
-
-  /******************************************************************
-  **
-  **   FUNCTION NAME : operator<<
-  **   FUNCTION TYPE : std::ostream &
-  */
-  std::ostream & operator<<( std::ostream & str, const ProductInfo & obj )
-  {
-#warning provide reasonable output
-    return str << obj.satSolvable();
-  }
-
-  ///////////////////////////////////////////////////////////////////
-
-  PoolItem ProductInfo::poolItem() const
-  {
-    return PoolItem( *this );
-  }
-
-  ResTraits<Package>::constPtrType ProductInfo::package() const
-  {
-    return make<Package>( *this );
-  }
-
-  ///////////////////////////////////////////////////////////////////
-
-#warning DUMMIES RETURNING THE PACKAGE ATTRIBUTES
-  std::string ProductInfo::name() const
-  { return sat::Solvable::name(); }
-
-  Edition ProductInfo::edition() const
-  { return sat::Solvable::edition(); }
-
-  Arch ProductInfo::arch() const
-  { return sat::Solvable::arch(); }
-
-  Vendor ProductInfo::vendor() const
-  { return sat::Solvable::vendor().asString(); }
-
-  std::string ProductInfo::summary( const Locale & lang_r ) const
-  { return package() ? package()->summary( lang_r ) : std::string(); }
-
-  std::string ProductInfo::description( const Locale & lang_r ) const
-  { return package() ? package()->description( lang_r ) : std::string(); }
-
-
-#warning REVIEW THESE OLD PRODUCT ARTTRIBUTES
-
-  std::string ProductInfo::type() const
-  { return lookupStrAttribute( sat::SolvAttr::productType ); }
-
-  Url ProductInfo::releaseNotesUrl() const
-  {
-    std::list<Url> ret;
-    fillList( ret, satSolvable(), sat::SolvAttr::productRelnotesurl );
-    if ( ! ret.empty() )
-      return  ret.front();
-    return Url();
-  }
-
-  std::list<Url> ProductInfo::updateUrls() const
-  {
-    std::list<Url> ret;
-    fillList( ret, satSolvable(), sat::SolvAttr::productUpdateurls );
-    return ret;
-  }
-
-  std::list<Url> ProductInfo::extraUrls() const
-  {
-    std::list<Url> ret;
-    fillList( ret, satSolvable(), sat::SolvAttr::productExtraurls );
-    return ret;
-  }
-
-  std::list<Url> ProductInfo::optionalUrls() const
-  {
-    std::list<Url> ret;
-    fillList( ret, satSolvable(), sat::SolvAttr::productOptionalurls );
-    return ret;
-  }
-
-  std::list<std::string> ProductInfo::flags() const
-  {
-    std::list<std::string> ret;
-    fillList( ret, satSolvable(), sat::SolvAttr::productFlags );
-    return ret;
-  }
-
-  std::string ProductInfo::shortName() const
-  { return lookupStrAttribute( sat::SolvAttr::productShortlabel ); }
-
-  std::string ProductInfo::longName( const Locale & /*lang_r*/ ) const
-  { return std::string(); }
-
-  std::string ProductInfo::distributionName() const
-  { return lookupStrAttribute( sat::SolvAttr::productDistproduct ); }
-
-  Edition ProductInfo::distributionEdition() const
-  { return Edition( lookupStrAttribute( sat::SolvAttr::productDistversion ) ); }
-
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
diff --git a/zypp/ProductInfo.h b/zypp/ProductInfo.h
deleted file mode 100644 (file)
index 6b65758..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/ProductInfo.h
- *
-*/
-#ifndef ZYPP_PRODUCTINFO_H
-#define ZYPP_PRODUCTINFO_H
-
-#include <iosfwd>
-
-#include "zypp/sat/Solvable.h"
-#include "zypp/Locale.h"
-#include "zypp/Vendor.h"
-#include "zypp/Repository.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-  class Url;
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   CLASS NAME : ProductInfo
-  //
-  /** Product metadata.
-   *
-   * \ref ProductInfo allows to retrieve product related metadata, that
-   * might be associated with certain packages. This class basically
-   * provides the information stored in an \c /etc/products.d entry.
-   *
-   * \ref ProductInfo is provided by \ref Package.
-   *
-   * The underlying \c private \ref sat::Solvable either refers to
-   * an associated package providing product related metadata, or
-   * is \ref sat::noSolvable.
-   */
-  class ProductInfo : private sat::Solvable
-  {
-    public:
-      /** Represents no \ref ProductInfo. */
-      static const ProductInfo noProductInfo;
-
-    public:
-      /** Default ctor creates \ref noProductInfo. */
-      ProductInfo();
-
-      /** ProductInfo associated with a \ref sat::Solvable or \ref noProductInfo. */
-      explicit ProductInfo( sat::Solvable solvable_r );
-
-      /** ProductInfo associated with a \ref PoolItem or \ref noProductInfo. */
-      explicit ProductInfo( const PoolItem & poolItem_r );
-
-      /** ProductInfo associated with a \ref ResObject or \ref noProductInfo. */
-      explicit ProductInfo( const ResTraits<ResObject>::constPtrType & package_r );
-
-    public:
-#ifndef SWIG // Swig treats it as syntax error
-      /** Whether this represents a valid- or \ref noProductInfo. */
-      using sat::Solvable::operator bool_type;
-#endif
-
-    public:
-      /** \name Access the associated \ref Package.
-       */
-      //@{
-      /** Access the associated \ref sat:::Solvable. */
-      sat::Solvable satSolvable() const
-      { return *this; }
-
-      /** Access the associated \ref PoolItem. */
-      PoolItem poolItem() const;
-
-      /** Access the associated \ref Package. */
-      ResTraits<Package>::constPtrType package() const;
-      //@}
-
-    public:
-      /** \name Product metadata.
-       */
-      //@{
-      /** Whether this represents an installed Product. */
-      using sat::Solvable::isSystem;
-
-      std::string  name()     const;
-      Edition      edition()  const;
-      Arch         arch()     const;
-      Vendor       vendor()   const;
-
-      std::string  summary( const Locale & lang_r = Locale() ) const;
-      std::string  description( const Locale & lang_r = Locale() ) const;
-
-      /** The \ref Repository this \ref Product belongs to. */
-      using sat::Solvable::repository;
-
-      /** \ref RepoInfo associated with the repository
-       *  providing this product.
-       */
-      RepoInfo repoInfo() const { return repository().info(); }
-
-
-      //----------------------------------------------
-      // These are the old Product attibutes to be revieved:
-
-      /** Get the product type (base, add-on) */
-      std::string type() const;
-
-      /** The URL to download the release notes for this product */
-      Url releaseNotesUrl() const;
-
-      /**
-       * Online updates for the product.
-       * They are complementary, not alternatives. #163192
-       */
-      std::list<Url> updateUrls() const;
-
-      /**
-       * Additional software for the product
-       * They are complementary, not alternatives.
-       */
-      std::list<Url> extraUrls() const;
-
-      /**
-       * Optional software for the product
-       * (for example. Non OSS repositories)
-       * They are complementary, not alternatives.
-       */
-      std::list<Url> optionalUrls() const;
-
-      /** The product flags */
-      std::list<std::string> flags() const;
-
-      /** Untranslated short name like <tt>SLES 10</tt>*/
-      std::string shortName() const;
-
-      /** Translated long name like <tt>SUSE Linux Enterprise Server 10</tt>*/
-      std::string longName( const Locale & lang_r = Locale() ) const;
-
-      /** Vendor specific distribution id. */
-      std::string distributionName() const;
-
-      /** Vendor specific distribution version. */
-      Edition distributionEdition() const;
-      //@}
-  };
-  ///////////////////////////////////////////////////////////////////
-
-  /** \relates ProductInfo Stream output */
-  std::ostream & operator<<( std::ostream & str, const ProductInfo & obj );
-
-  /** \relates ProductInfo */
-  inline bool operator==( const ProductInfo & lhs, const ProductInfo & rhs )
-  { return lhs.satSolvable() == rhs.satSolvable(); }
-
-  /** \relates ProductInfo */
-  inline bool operator!=( const ProductInfo & lhs, const ProductInfo & rhs )
-  { return lhs.satSolvable() != rhs.satSolvable(); }
-
-  /** \relates ProductInfo */
-  inline bool operator<( const ProductInfo & lhs, const ProductInfo & rhs )
-  { return lhs.satSolvable() < rhs.satSolvable(); }
-
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PRODUCTINFO_H
index 0735439..d75b461 100644 (file)
  *
 */
 
-#include <zypp/base/Logger.h>
 #include "zypp/ResObject.h"
 #include "zypp/sat/SolvAttr.h"
 #include "zypp/sat/Solvable.h"
 #include "zypp/Repository.h"
 #include "zypp/RepoInfo.h"
-#include "zypp/ProductInfo.h"
 #include "zypp/IdString.h"
 
 using namespace zypp;
@@ -57,14 +55,6 @@ namespace zypp
 
   ///////////////////////////////////////////////////////////////////
 
-  bool ResObject::hasProductInfo() const
-  { return ProductInfo( *this ); } // this is basically one lookupIdAttribute call
-
-  ProductInfo ResObject::productInfo() const
-  { return ProductInfo( *this ); }
-
-  ///////////////////////////////////////////////////////////////////
-
   std::string ResObject::summary( const Locale & lang_r ) const
   { return lookupStrAttribute( sat::SolvAttr::summary, lang_r ); }
 
index 07bb1ae..ee4c46e 100644 (file)
@@ -30,8 +30,6 @@
 namespace zypp
 { /////////////////////////////////////////////////////////////////
 
-  class ProductInfo;
-
   ///////////////////////////////////////////////////////////////////
   //
   //   CLASS NAME : ResObject
@@ -67,19 +65,6 @@ namespace zypp
     //@}
 
   public:
-    /** \name Associated product metadata.
-     * Some \ref Packages may provide additional product metadata.
-     * \see \ref ProductInfo.
-     */
-    //@{
-    /** Whether there is associated \ref ProductInfo available. */
-    bool hasProductInfo() const;
-    /** Return associated \ref ProductInfo or \ref ProductInfo::noProductInfo. */
-    ProductInfo productInfo() const;
-    //@}
-
-  public:
-
     /**
      * \short Short text describing the resolvable.
      * This attribute is usually displayed in columns.
index 5e51288..5d29f8f 100644 (file)
@@ -214,20 +214,6 @@ namespace zypp
       /** \name Special iterators. */
       //@{
 
-      /** \name Iterate over all satisfied products.
-       * \note Is satisfied status is computed and updated on each solver
-       * run. So it does not reflect any changes made since the last solver run.
-       */
-      //@{
-      typedef filter_iterator<filter::SatisfiedProducts,const_iterator> satisfiedProducts_iterator;
-
-      satisfiedProducts_iterator satisfiedProductsBegin() const
-      { return filterBegin( filter::SatisfiedProducts() ); }
-
-      satisfiedProducts_iterator satisfiedProductsEnd() const
-      { return filterEnd( filter::SatisfiedProducts() ); }
-      //@}
-
       //@}
    public:
       /** \name Iterate over all Repositories that contribute ResObjects.
index deb3cfb..8af6174 100644 (file)
@@ -122,6 +122,14 @@ namespace std
       return str << *obj;
     return str << std::string("NULL");
   }
+  /** \relates zypp::shared_ptr Stream output. */
+  template<class _D>
+  inline std::ostream & dumpOn( std::ostream & str, const zypp::shared_ptr<_D> & obj )
+  {
+    if ( obj )
+      return dumpOn( str, *obj );
+    return str << std::string("NULL");
+  }
 
   /** \relates zypp::intrusive_ptr Stream output. */
   template<class _D>
@@ -131,6 +139,14 @@ namespace std
       return str << *obj;
     return str << std::string("NULL");
   }
+  /** \relates zypp::intrusive_ptr Stream output. */
+  template<class _D>
+  inline std::ostream & dumpOn( std::ostream & str, const zypp::intrusive_ptr<_D> & obj )
+  {
+    if ( obj )
+      return dumpOn( str, *obj );
+    return str << std::string("NULL");
+  }
   /////////////////////////////////////////////////////////////////
 } // namespace std
 ///////////////////////////////////////////////////////////////////
index ba49fad..9606442 100644 (file)
@@ -22,7 +22,7 @@
 #include "zypp/Product.h"
 #include "zypp/Package.h"
 #include "zypp/Edition.h"
-#include "zypp/parser/xml_escape_parser.hpp"
+#include "zypp/parser/xml/XmlEscape.h"
 #include "zypp/base/String.h"
 #include "zypp/base/PtrTypes.h"
 #include "zypp/Capabilities.h"
@@ -49,13 +49,12 @@ using namespace zypp::str;
 
 IMPL_PTR_TYPE(HelixResolvable);
 
-static std::string xml_escape( const std::string &text )
+inline std::string xml_escape( const std::string &text )
 {
-  iobind::parser::xml_escape_parser parser;
-  return parser.escape(text);
+  return zypp::xml::escape(text);
 }
 
-static std::string xml_tag_enclose( const std::string &text, const std::string &tag, bool escape = false )
+inline std::string xml_tag_enclose( const std::string &text, const std::string &tag, bool escape = false )
 {
   string result;
   result += "<" + tag + ">";
@@ -106,8 +105,8 @@ std::string helixXML( const Capability &cap )
            if (!detail.ed().release().empty())
                str << " release='" << xml_escape(detail.ed().release()) << "'";
            if (detail.ed().epoch() != Edition::noepoch)
-               str << " epoch='" << xml_escape(numstring(detail.ed().epoch())) << "'";    
-           str << " />" << endl;       
+               str << " epoch='" << xml_escape(numstring(detail.ed().epoch())) << "'";
+           str << " />" << endl;
        } else {
            str << "<dep name='" << xml_escape(cap.asString()) << "' />" << endl;
        }
@@ -117,7 +116,7 @@ std::string helixXML( const Capability &cap )
            && detail.rhs().detail().isNamed()) {
            // packageand dependency
            str << "<dep name='packageand("
-               << IdString(detail.lhs().id()) << ","           
+               << IdString(detail.lhs().id()) << ","
                << IdString(detail.rhs().id()) << ")' />" << endl;
        } else {
            // modalias ?
@@ -133,11 +132,11 @@ std::string helixXML( const Capability &cap )
                    str << packageName << ":";
                str << IdString(detail.rhs().id()) << ")' />" << endl;
            } else {
-               str << "<!--- ignoring '" << xml_escape(cap.asString()) << "' -->" << endl;     
+               str << "<!--- ignoring '" << xml_escape(cap.asString()) << "' -->" << endl;
            }
        }
     } else {
-       str << "<!--- ignoring '" << xml_escape(cap.asString()) << "' -->" << endl;     
+       str << "<!--- ignoring '" << xml_escape(cap.asString()) << "' -->" << endl;
     }
 
     return str.str();
@@ -187,7 +186,7 @@ std::string helixXML( const PoolItem &item )
   str << "<" << toLower (resolvable->kind().asString()) << ">" << endl;
   str << TAB << xml_tag_enclose (resolvable->name(), "name", true) << endl;
   str << TAB << xml_tag_enclose (item->vendor(), "vendor", true) << endl;
-  str << TAB << xml_tag_enclose (item->buildtime().asSeconds(), "buildtime", true) << endl;  
+  str << TAB << xml_tag_enclose (item->buildtime().asSeconds(), "buildtime", true) << endl;
   if ( isKind<Package>(resolvable) ) {
       str << TAB << "<history>" << endl << TAB << "<update>" << endl;
       str << TAB2 << helixXML (resolvable->arch()) << endl;
@@ -246,9 +245,9 @@ bool Testcase::createTestcasePool(const ResPool &pool)
        // remove old stuff
        zypp::filesystem::clean_dir (dumpPath);
     }
-    
+
     RepositoryTable            repoTable;
-    HelixResolvable    system (dumpPath + "/solver-system.xml.gz");    
+    HelixResolvable    system (dumpPath + "/solver-system.xml.gz");
 
     for ( ResPool::const_iterator it = pool.begin(); it != pool.end(); ++it )
     {
@@ -265,7 +264,7 @@ bool Testcase::createTestcasePool(const ResPool &pool)
            }
            repoTable[repo]->addResolvable (*it);
        }
-    }  
+    }
     return true;
 }
 
@@ -374,7 +373,7 @@ bool Testcase::createTestcase(Resolver & resolver, bool dumpPool, bool runSolver
 
     control.addDependencies (resolver.extraRequires(), resolver.extraConflicts());
     control.addDependencies (SystemCheck::instance().requiredSystemCap(),
-                            SystemCheck::instance().conflictSystemCap());    
+                            SystemCheck::instance().conflictSystemCap());
 
     return true;
 }
@@ -448,12 +447,12 @@ HelixControl::HelixControl(const std::string & controlPath,
        *file << TAB << "<locale name=\"" <<  iter->code()
              << "\" />" << endl;
     }
-    
+
     if (forceResolve)
        *file << TAB << "<forceResolve/>" << endl;
     if (onlyRequires)
        *file << TAB << "<onlyRequires/>" << endl;
-    
+
     *file << "</setup>" << endl
          << "<trial>" << endl
          << "<showpool all=\"yes\"/>" << endl;
@@ -469,7 +468,7 @@ HelixControl::~HelixControl()
 {
     *file << "</trial>" << endl
          << "</test>" << endl;
-    delete(file);    
+    delete(file);
 }
 
 void HelixControl::installResolvable(const ResObject::constPtr &resObject,
index 627349f..df960a8 100644 (file)
@@ -167,9 +167,10 @@ namespace zypp
     ** FUNCTION TYPE : std::ostream &
     */
     std::ostream & operator<<( std::ostream & str, const Selectable & obj )
-    {
-      return str << *obj._pimpl;
-    }
+    { return str << *(obj._pimpl); }
+
+    std::ostream & dumpOn( std::ostream & str, const Selectable & obj )
+    { return dumpOn( str, *(obj._pimpl) ); }
 
     /////////////////////////////////////////////////////////////////
   } // namespace ui
index 996fd38..620de6c 100644 (file)
@@ -48,6 +48,7 @@ namespace zypp
     class Selectable : public base::ReferenceCounted, private base::NonCopyable
     {
       friend std::ostream & operator<<( std::ostream & str, const Selectable & obj );
+      friend std::ostream & dumpOn( std::ostream & str, const Selectable & obj );
 
     public:
       typedef intrusive_ptr<Selectable>        Ptr;
@@ -74,28 +75,14 @@ namespace zypp
       /** The ResObjects name.  */
       const std::string & name() const;
 
-      /**
-       * return the first Installed object
-       * of available
-       */
+      /** The last Installed object. */
       PoolItem installedObj() const;
 
-      /**
-       * \deprecated use installedObj
-       * PoolItem corresponding to the installed object.
-       */
-      ZYPP_DEPRECATED PoolItem installedPoolItem() const
-      { return installedObj(); }
-
       /** Best among available objects.
-       + The user selected candiate, or a default.
-      */
+       * The user selected candiate, or a default.
+       */
       PoolItem candidateObj() const;
 
-      /** PoolItem corresponding to the candidate object. */
-      ZYPP_DEPRECATED PoolItem candidatePoolItem() const
-      { return candidateObj(); }
-
       /** Set a candidate (out of available objects).
        * \return The new candidate, or NULL if choice was invalid
        * (NULL or not among availableObjs). An invalid choice
@@ -108,50 +95,27 @@ namespace zypp
 
       ////////////////////////////////////////////////////////////////////////
 
-      /**
-       * Are there available objects?
-       */
+      /** \name Available objects iterators.
+       * Oredered according to solver policy. 'Best' first.
+      */
+      //@{
       bool availableEmpty() const;
-
-      /**
-       * Number of available objects.
-       */
       available_size_type availableSize() const;
-
-      /**
-       * Number of available objects.
-       * \deprecated Use availableSize
-       */
-      ZYPP_DEPRECATED available_size_type availableObjs() const
-      { return availableSize(); }
-
-      /** */
       available_iterator availableBegin() const;
-
-      /** */
       available_iterator availableEnd() const;
+      //@}
 
       ////////////////////////////////////////////////////////////////////////
 
-      /**
-       * Installed object iterators
-       */
-
-      /**
-       * Are there installed objects?
-       */
+      /** \name Insatlled objects iterators.
+       * Ordered by install time. Latest first.
+      */
+      //@{
       bool installedEmpty() const;
-
-      /**
-       * Number of available objects.
-       */
       installed_size_type installedSize() const;
-
-      /** */
       installed_iterator installedBegin() const;
-
-      /** */
       installed_iterator installedEnd() const;
+      //}
 
       ////////////////////////////////////////////////////////////////////////
 
@@ -190,11 +154,11 @@ namespace zypp
        */
       bool isUnmaintained() const;
 
-      /** \name Classification of available patches (patterns, products).
+      /** \name Classification of available patches (patterns).
        * A patch is either \c not \c relevant, \c satisfied or \c broken.
-      */
+       */
       //@{
-      /** Returns true for packages, because  packages are not
+      /** Returns true for packages, because packages are not
        * classified by the solver.
       */
       bool isUndetermined() const;
@@ -265,12 +229,6 @@ namespace zypp
        */
       bool setStatus( const Status state_r );
 
-      /** Try to set a new Status.
-       * Returns \c false if the transitions is not allowed.
-      */
-      ZYPP_DEPRECATED bool set_status( const Status state_r )
-      { return setStatus( state_r ); }
-
       /** Return who caused the modification. */
       ResStatus::TransactByValue modifiedBy() const;
 
@@ -299,6 +257,9 @@ namespace zypp
     /** \relates Selectable Stream output */
     std::ostream & operator<<( std::ostream & str, const Selectable & obj );
 
+    /** \relates Selectable More verbose stream output */
+    std::ostream & dumpOn( std::ostream & str, const Selectable & obj );
+
     /** Solvable to Selectable transform functor.
      * \relates Selectable
      * \relates sat::SolvIterMixin
index 9c6e3b6..573429b 100644 (file)
@@ -185,13 +185,15 @@ namespace zypp
       if ( !installedObj() && allCandidatesLocked() )
          return S_Taboo;
 
-      // KEEP state: non packages count as installed if they are satisfied.
+      // KEEP state:
+      // Report not installable items as installed, if they are satisfied.
       if ( installedObj() )
-          return S_KeepInstalled;
+        return S_KeepInstalled;
 
-      if ( kind() != ResKind::package
+      if ( (  kind() == ResKind::patch
+           || kind() == ResKind::pattern )
            && cand.status().isSatisfied() ) // no installed, so we must have candidate
-          return S_KeepInstalled;
+        return S_KeepInstalled;
 
       return S_NoInst;
     }
index 889e889..18e7f0f 100644 (file)
 #ifndef ZYPP_UI_SELECTABLEIMPL_H
 #define ZYPP_UI_SELECTABLEIMPL_H
 
-#include <iosfwd>
+#include <iostream>
+#include "zypp/base/LogTools.h"
 
 #include "zypp/base/PtrTypes.h"
 
 #include "zypp/ui/Selectable.h"
 #include "zypp/ui/SelectableTraits.h"
 
+using std::endl;
+
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
@@ -36,8 +39,6 @@ namespace zypp
     */
     struct Selectable::Impl
     {
-      friend std::ostream & operator<<( std::ostream & str, const Selectable::Impl & obj );
-
     public:
 
       typedef SelectableTraits::AvailableItemSet         AvailableItemSet;
@@ -258,11 +259,21 @@ namespace zypp
     inline std::ostream & operator<<( std::ostream & str, const Selectable::Impl & obj )
     {
       return str << '[' << obj.kind() << ']' << obj.name() << ": " << obj.status()
-                 << " (I " << obj._installedItems.size() << ")"
-                 << " (A " << obj._availableItems.size() << ")"
+                 << " (I " << obj.installedSize() << ")"
+                 << " (A " << obj.availableSize() << ")"
                  << obj.candidateObj();
     }
 
+    /** \relates Selectable::Impl Stream output */
+    inline std::ostream & dumpOn( std::ostream & str, const Selectable::Impl & obj )
+    {
+      str << '[' << obj.kind() << ']' << obj.name() << ": " << obj.status() << endl;
+      dumpRange( str << "  (I " << obj.installedSize() << ") ", obj.installedBegin(), obj.installedEnd() );
+      if ( obj.installedEmpty() )
+        str << endl << " ";
+      dumpRange( str << " (A " << obj.availableSize() << ") ", obj.availableBegin(), obj.availableEnd() ) << endl;
+      return str;
+    }
     /////////////////////////////////////////////////////////////////
   } // namespace ui
   ///////////////////////////////////////////////////////////////////
index 29ffe69..f713880 100644 (file)
@@ -32,7 +32,7 @@ namespace zypp
     /** */
     struct SelectableTraits
     {
-      /** Oder on AvalableItemSet.
+      /** Oder on AvailableItemSet.
        * \li repository priority
        * \li best Arch
        * \li best Edition
@@ -65,12 +65,38 @@ namespace zypp
         }
       };
 
+      /** Oder on InstalledItemSet.
+       * \li repository priority
+       * \li best Arch
+       * \li best Edition
+       * \li ResObject::constPtr as fallback.
+      */
+      struct IOrder : public std::binary_function<PoolItem,PoolItem,bool>
+      {
+        // NOTE: operator() provides LESS semantics to order the set.
+        // So LESS means 'prior in set'. We want 'newer' install time
+        // at the beginning of the set.
+        //
+        bool operator()( const PoolItem & lhs, const PoolItem & rhs ) const
+        {
+          Date ldate = lhs->installtime();
+          Date rdate = rhs->installtime();
+          if ( ldate != rdate )
+            return( ldate > rdate );
+
+          // no more criteria, still equal:
+          // use the ResObject::constPtr (the poiner value)
+          // (here it's arbitrary whether < or > )
+          return lhs.resolvable() < rhs.resolvable();
+        }
+      };
+
       typedef std::set<PoolItem,AVOrder>       AvailableItemSet;
       typedef AvailableItemSet::iterator       available_iterator;
       typedef AvailableItemSet::const_iterator available_const_iterator;
       typedef AvailableItemSet::size_type      available_size_type;
 
-      typedef std::set<PoolItem,AVOrder>       InstalledItemSet;
+      typedef std::set<PoolItem,IOrder>        InstalledItemSet;
       typedef AvailableItemSet::iterator       installed_iterator;
       typedef AvailableItemSet::const_iterator installed_const_iterator;
       typedef AvailableItemSet::size_type      installed_size_type;