- Add method ZYpp::getTarget that returns the Target or a NULL pointer,
authorMichael Andres <ma@suse.de>
Fri, 15 Aug 2008 12:30:44 +0000 (12:30 +0000)
committerMichael Andres <ma@suse.de>
Fri, 15 Aug 2008 12:30:44 +0000 (12:30 +0000)
  if it is not yet initialized. This is to avoid try/catch blocks just
  to test whether the Target is initialized. (bnc #417556)
- Add method Target::assertRootPrefix. Pass a pathname and get back the
  path prefixed with the tragets root, unless it already had that prefix.

VERSION.cmake
package/libzypp.changes
zypp/Target.h
zypp/ZYpp.cc
zypp/ZYpp.h
zypp/solver/detail/SystemCheck.cc
zypp/zypp_detail/ZYppImpl.h

index 9a88115..ff9ed6b 100644 (file)
@@ -60,8 +60,8 @@
 #
 SET(LIBZYPP_MAJOR "5")
 SET(LIBZYPP_COMPATMINOR "5")
-SET(LIBZYPP_MINOR "5")
-SET(LIBZYPP_PATCH "2")
+SET(LIBZYPP_MINOR "6")
+SET(LIBZYPP_PATCH "0")
 #
 # LAST RELEASED: 5.5.1 (5)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
index 51aab9b..7f8db7a 100644 (file)
@@ -1,4 +1,14 @@
 -------------------------------------------------------------------
+Fri Aug 15 14:23:02 CEST 2008 - ma@suse.de
+
+- Add method ZYpp::getTarget that returns the Target or a NULL pointer,
+  if it is not yet initialized. This is to avoid try/catch blocks just 
+  to test whether the Target is initialized. (bnc #417556)
+- Add method Target::assertRootPrefix. Pass a pathname and get back the
+  path prefixed with the tragets root, unless it already had that prefix.
+- revision 10870
+
+-------------------------------------------------------------------
 Thu Aug 14 18:44:45 CEST 2008 - schubi@suse.de
 
 - Regarding error messages for Products correctly (FATE #304502)
index db3ad54..8c7f58b 100644 (file)
@@ -100,6 +100,10 @@ namespace zypp
     /** Return the root set for this target */
     Pathname root() const;
 
+    /** Return the path prefixed by the target root, unless it already is prefixed. */
+    Pathname assertRootPrefix( const Pathname & path_r ) const
+    { return Pathname::assertprefix( root(), path_r ); }
+
     /** return the last modification date of the target */
     Date timestamp() const;
 
@@ -119,7 +123,7 @@ namespace zypp
      *
      */
     std::string anonymousUniqueId() const;
-    
+
   public:
     /** Ctor. If \c doRebuild_r is \c true, an already existing
      * database is rebuilt (rpm --rebuilddb ).
index 721f776..08900fb 100644 (file)
@@ -85,6 +85,9 @@ namespace zypp
   Target_Ptr ZYpp::target() const
   { return _pimpl->target(); }
 
+  Target_Ptr ZYpp::getTarget() const
+  { return _pimpl->getTarget(); }
+
   void ZYpp::initializeTarget( const Pathname & root, bool doRebuild_r )
   { _pimpl->initializeTarget( root, doRebuild_r ); }
 
index 80bc020..9452972 100644 (file)
@@ -84,6 +84,11 @@ namespace zypp
      */
     Target_Ptr target() const;
 
+    /** Same as \ref target but returns NULL if target is not
+     *  initialized, instead of throwing.
+     */
+    Target_Ptr getTarget() const;
+
     /**
      * \throws Exception
      * Just init the target, dont populate store or pool.
index 1e913ff..cd6da86 100644 (file)
@@ -40,8 +40,8 @@ namespace zypp
        static SystemCheck _val;
        return _val;
     }
-    
-      
+
+
     SystemCheck::SystemCheck() {
        if (_file.empty()) {
            _file = ZConfig::instance().solver_checkSystemFile();
@@ -69,26 +69,19 @@ namespace zypp
     }
 
     bool SystemCheck::loadFile() const{
-       try
-       {
-           Target_Ptr trg( getZYpp()->target() );
-           if ( trg )
-               _file = trg->root() / _file;
-       }
-       catch ( ... )
-       {
-           // noop: Someone decided to let target() throw if the ptr is NULL ;(
-       }
+        Target_Ptr trg( getZYpp()->getTarget() );
+        if ( trg )
+          _file = trg->assertRootPrefix( _file );
 
        PathInfo pi( _file );
        if ( ! pi.isFile() ) {
            WAR << "Can't read " << _file << " " << pi << endl;
            return false;
        }
-       
+
        _require.clear();
        _conflict.clear();
-       
+
        std::ifstream infile( _file.c_str() );
        for( iostr::EachLine in( infile ); in; in.next() ) {
            std::string l( str::trim(*in) );
@@ -113,7 +106,7 @@ namespace zypp
        MIL << "Read " << pi << endl;
        return true;
     }
-      
+
 
     /******************************************************************
     **
index f821d05..2294d8c 100644 (file)
@@ -69,6 +69,12 @@ namespace zypp
        */
       Target_Ptr target() const;
 
+      /** Same as \ref target but returns NULL if target is not
+       *  initialized, instead of throwing.
+       */
+      Target_Ptr getTarget() const
+      { return _target; }
+
       /**
        * \throws Exception
        * true, just init the target, dont populate store or pool