Author: mlandres Date: Tue Aug 12 12:12:23 2008 New Revision: 10814 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10814&view=rev Log: - Offer a simpler, fate based status manipulation in ui::Selectable. This is easier to handle, as the ui::Status always distinguishes wheter an object is installed or not. Modified: trunk/libzypp/devel/devel.ma/NewPool.cc trunk/libzypp/package/libzypp.changes trunk/libzypp/zypp/base/Flags.h trunk/libzypp/zypp/ui/Selectable.cc trunk/libzypp/zypp/ui/Selectable.h Modified: trunk/libzypp/devel/devel.ma/NewPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=10814&r1=10813&r2=10814&view=diff ============================================================================== --- trunk/libzypp/devel/devel.ma/NewPool.cc (original) +++ trunk/libzypp/devel/devel.ma/NewPool.cc Tue Aug 12 12:12:23 2008 @@ -261,7 +261,10 @@ bool install() { - SEC << getZYpp()->commit( ZYppCommitPolicy().dryRun(true) ) << endl; + ZYppCommitPolicy pol; + pol.dryRun(true); + pol.rpmInstFlags( pol.rpmInstFlags().setFlag( target::rpm::RPMINST_JUSTDB ) ); + SEC << getZYpp()->commit( pol ) << endl; return true; } @@ -420,28 +423,6 @@ #undef OUTS } -namespace zypp -{ - - class XRpmDb - { - public: - enum DbStateInfoBits { - DbSI_NO_INIT = 0x0000, - DbSI_HAVE_V4 = 0x0001, - DbSI_MADE_V4 = 0x0002, - DbSI_MODIFIED_V4 = 0x0004, - DbSI_HAVE_V3 = 0x0008, - DbSI_HAVE_V3TOV4 = 0x0010, - DbSI_MADE_V3TOV4 = 0x0020 - }; - - ZYPP_DECLARE_FLAGS(DbStateInfo,DbStateInfoBits); - }; - ZYPP_DECLARE_OPERATORS_FOR_FLAGS(XRpmDb::DbStateInfo); - -} - /****************************************************************** ** ** FUNCTION NAME : main @@ -453,20 +434,6 @@ ++argv; zypp::base::LogControl::instance().logToStdErr(); INT << "===[START]==========================================" << endl; - - enum Other { OTHERVAL = 13 }; - - XRpmDb::DbStateInfo s; - s = XRpmDb::DbSI_MODIFIED_V4|XRpmDb::DbSI_HAVE_V4; - DBG << s << endl; - DBG << s.testFlag( XRpmDb::DbSI_MODIFIED_V4 ) << endl; - DBG << s.testFlag( XRpmDb::DbSI_MADE_V3TOV4 ) << endl; - - /////////////////////////////////////////////////////////////////// - INT << "===[END]============================================" << endl << endl; - zypp::base::LogControl::instance().logNothing(); - return 0; - ZConfig::instance(); ResPool pool( ResPool::instance() ); @@ -557,7 +524,9 @@ /////////////////////////////////////////////////////////////////// ui::Selectable::Ptr item( ui::Selectable::get( "amarok" ) ); - MIL << dump(item) << endl; + item->setUpToDate(); + SEC << dump(item) << endl; + install(); /////////////////////////////////////////////////////////////////// INT << "===[END]============================================" << endl << endl; Modified: trunk/libzypp/package/libzypp.changes URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=10814&r1=10813&r2=10814&view=diff ============================================================================== --- trunk/libzypp/package/libzypp.changes (original) +++ trunk/libzypp/package/libzypp.changes Tue Aug 12 12:12:23 2008 @@ -1,4 +1,12 @@ ------------------------------------------------------------------- +Tue Aug 12 12:05:49 CEST 2008 - ma@suse.de + +- Offer a simpler, fate based status manipulation in ui::Selectable. + This is easier to handle, as the ui::Status always distinguishes + wheter an object is installed or not. +- revision 10814 + +------------------------------------------------------------------- Mon Aug 11 18:00:40 CEST 2008 - ma@suse.de - Propagate default rpm install flags from zypp.conf via ZConfig and Modified: trunk/libzypp/zypp/base/Flags.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/Flags.h?rev=10814&r1=10813&r2=10814&view=diff ============================================================================== --- trunk/libzypp/zypp/base/Flags.h (original) +++ trunk/libzypp/zypp/base/Flags.h Tue Aug 12 12:12:23 2008 @@ -88,11 +88,11 @@ Flags operator~() const { return ~_val; } public: - void setFlag( Enum flag_r, bool newval_r ) - { newval_r ? setFlag(flag_r) : unsetFlag(flag_r); } + Flags & setFlag( Enum flag_r, bool newval_r ) + { return( newval_r ? setFlag(flag_r) : unsetFlag(flag_r) ); } - void setFlag( Enum flag_r ) { _val |= flag_r; } - void unsetFlag( Enum flag_r ) { _val &= ~flag_r; } + Flags & setFlag( Enum flag_r ) { _val |= flag_r; return *this; } + Flags & unsetFlag( Enum flag_r ) { _val &= ~flag_r; return *this; } bool testFlag( Enum flag_r ) const { return _val & flag_r; } Modified: trunk/libzypp/zypp/ui/Selectable.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ui/Selectable.cc?rev=10814&r1=10813&r2=10814&view=diff ============================================================================== --- trunk/libzypp/zypp/ui/Selectable.cc (original) +++ trunk/libzypp/zypp/ui/Selectable.cc Tue Aug 12 12:12:23 2008 @@ -164,6 +164,46 @@ return UNMODIFIED; }; + bool Selectable::setFate( Fate fate_r ) + { + switch ( fate_r ) + { + case TO_INSTALL: + return setStatus( hasInstalledObj() ? S_Update : S_Install ); + break; + + case TO_DELETE: + return setStatus( S_Del ); + break; + + case UNMODIFIED: + return setStatus( hasInstalledObj() ? S_KeepInstalled : S_NoInst ); + break; + } + } + + bool Selectable::setInstalled() + { + return( hasInstalledObj() || setStatus( S_Install ) ); + } + + bool Selectable::setUpToDate() + { + if ( ! hasInstalledObj() ) + return setStatus( S_Install ); + + PoolItem cand( candidateObj() ); + if ( ! cand ) + return true; + + return( installedObj()->edition() >= cand->edition() + || setStatus( S_Update ) ); + } + + bool Selectable::setDeleted() + { + return( ! hasInstalledObj() || setStatus( S_Del ) ); + } /****************************************************************** ** Modified: trunk/libzypp/zypp/ui/Selectable.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ui/Selectable.h?rev=10814&r1=10813&r2=10814&view=diff ============================================================================== --- trunk/libzypp/zypp/ui/Selectable.h (original) +++ trunk/libzypp/zypp/ui/Selectable.h Tue Aug 12 12:12:23 2008 @@ -224,7 +224,7 @@ //@} public: - /** \name Query objects fate in case of commit. + /** \name Query and maip objects fate in case of commit. */ //@{ enum Fate { @@ -250,6 +250,30 @@ /** True if to install */ bool toInstall() const { return fate() == TO_INSTALL; } + + /** */ + bool setFate( Fate fate_r ); + + /** Set the item to be installed (new- or re-install). */ + bool setToInstall() + { return setFate( TO_INSTALL ); } + + /** Take care the item gets installed if it is not. */ + bool setInstalled(); + + /** Take care the item gets installed if it is not, or is older. */ + bool setUpToDate(); + + /** Set the item to be deleted (must be installed). */ + bool setToDelete() + { return setFate( TO_DELETE ); } + + /** Take care the item gets deleted if it is installed. */ + bool setDeleted(); + + /** Set the item to stay unmodified. */ + bool unset() + { return setFate( UNMODIFIED ); } //@} public: @@ -257,8 +281,7 @@ * \name Special inteface for Y2UI. * \note This interface acts on \ref ResStatus::USER level. * The \ref Status enum, and allowed state transitions are - * tightly related to the Y2UI. It might be not verry usefull - * outside the Y2UI. + * tightly related to the Y2UI. */ //@{ /** Return the current Status */ -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org