From: Michael Andres Date: Fri, 15 Aug 2008 12:30:44 +0000 (+0000) Subject: - Add method ZYpp::getTarget that returns the Target or a NULL pointer, X-Git-Tag: BASE-SuSE-Code-11-Branch~489 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c4139245d6005e07c87024cc10d9ff313ee18fa;p=platform%2Fupstream%2Flibzypp.git - 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. --- diff --git a/VERSION.cmake b/VERSION.cmake index 9a88115..ff9ed6b 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -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) diff --git a/package/libzypp.changes b/package/libzypp.changes index 51aab9b..7f8db7a 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -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) diff --git a/zypp/Target.h b/zypp/Target.h index db3ad54..8c7f58b 100644 --- a/zypp/Target.h +++ b/zypp/Target.h @@ -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 ). diff --git a/zypp/ZYpp.cc b/zypp/ZYpp.cc index 721f776..08900fb 100644 --- a/zypp/ZYpp.cc +++ b/zypp/ZYpp.cc @@ -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 ); } diff --git a/zypp/ZYpp.h b/zypp/ZYpp.h index 80bc020..9452972 100644 --- a/zypp/ZYpp.h +++ b/zypp/ZYpp.h @@ -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. diff --git a/zypp/solver/detail/SystemCheck.cc b/zypp/solver/detail/SystemCheck.cc index 1e913ff..cd6da86 100644 --- a/zypp/solver/detail/SystemCheck.cc +++ b/zypp/solver/detail/SystemCheck.cc @@ -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; } - + /****************************************************************** ** diff --git a/zypp/zypp_detail/ZYppImpl.h b/zypp/zypp_detail/ZYppImpl.h index f821d05..2294d8c 100644 --- a/zypp/zypp_detail/ZYppImpl.h +++ b/zypp/zypp_detail/ZYppImpl.h @@ -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