From: Klaus Kaempf Date: Fri, 24 Feb 2006 13:20:24 +0000 (+0000) Subject: eraseInstalled() is not a ResPool function, but an internal ZYpp one X-Git-Tag: BASE-SuSE-SLE-10-SP2-Branch~1920 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb3dd2efcfbcc614a9a3edb9c11e40851c7c8c62;p=platform%2Fupstream%2Flibzypp.git eraseInstalled() is not a ResPool function, but an internal ZYpp one when switching the target and after commit() --- diff --git a/zypp/ResPool.cc b/zypp/ResPool.cc index 184d33e..e77190b 100644 --- a/zypp/ResPool.cc +++ b/zypp/ResPool.cc @@ -87,10 +87,6 @@ namespace zypp ResPool::byCapabilityIndex_iterator ResPool::byCapabilityIndexEnd( const std::string & index_r, Dep depType_r ) const { return make_filter_iterator( ByCapabilityIndex(), _pimpl->_caphash.end( index_r, depType_r ), _pimpl->_caphash.end( index_r, depType_r ) ); } - void ResPool::eraseInstalled() - { // doesnotwork (const_pointer_cast(_pimpl))->eraseInstalled(); - return; } - /****************************************************************** ** ** FUNCTION NAME : operator<< diff --git a/zypp/ResPool.h b/zypp/ResPool.h index 58ac003..1c3c9ba 100644 --- a/zypp/ResPool.h +++ b/zypp/ResPool.h @@ -56,8 +56,6 @@ namespace zypp bool empty() const; /** */ size_type size() const; - /** erase all installed items (presumably coming from the target) */ - void eraseInstalled(); public: diff --git a/zypp/pool/PoolImpl.cc b/zypp/pool/PoolImpl.cc index 2297f15..a737bdd 100644 --- a/zypp/pool/PoolImpl.cc +++ b/zypp/pool/PoolImpl.cc @@ -184,28 +184,6 @@ namespace zypp PoolImpl::~PoolImpl() {} - /****************************************************************** - ** - ** FUNCTION NAME : eraseInstalled - ** FUNCTION TYPE : void - */ - void PoolImpl::eraseInstalled( ) - { - MIL << "eraseInstalled()" << endl; - for (ContainerT::iterator it = _store.begin(); it != _store.end();) { - PoolItem item = *it; - if (item.status().isInstalled()) { - ContainerT::iterator next = it; ++next; - _store.erase( item ); - _namehash.erase( item ); - _caphash.erase( item ); - it = next; - } - else { - ++it; - } - } - } /****************************************************************** ** diff --git a/zypp/pool/PoolImpl.h b/zypp/pool/PoolImpl.h index 2ff8b9d..4191a22 100644 --- a/zypp/pool/PoolImpl.h +++ b/zypp/pool/PoolImpl.h @@ -240,7 +240,7 @@ namespace zypp } /** erase all resolvables coming from the target */ - void eraseInstalled(); + void eraseInstalled() const; public: /** \name Save and restore state. */ diff --git a/zypp/zypp_detail/ZYppImpl.cc b/zypp/zypp_detail/ZYppImpl.cc index 6e9b0bf..f9eced0 100644 --- a/zypp/zypp_detail/ZYppImpl.cc +++ b/zypp/zypp_detail/ZYppImpl.cc @@ -89,12 +89,21 @@ namespace zypp void ZYppImpl::removeResolvables (const ResStore& store) { - for (ResStore::iterator it = store.begin(); it != store.end(); it++) + for (ResStore::iterator it = store.begin(); it != store.end(); ++it) { _pool.erase(*it); } } + void ZYppImpl::removeInstalledResolvables () + { + for (ResPool::const_iterator it = pool().begin(); it != pool().end(); ++it) + { + if (it->status().isInstalled()) + _pool.erase(*it); + } + } + Target_Ptr ZYppImpl::target() const { if (! _target) @@ -104,24 +113,25 @@ namespace zypp void ZYppImpl::initTarget(const Pathname & root, bool commit_only) { - if (_target && _target->root() == root) { - MIL << "Repeated call to initTarget()" << endl; - return; + if (_target) { + if (_target->root() == root) { + MIL << "Repeated call to initTarget()" << endl; + return; + } + removeInstalledResolvables( ); } - - _target = new Target(root); + _target = new Target( root ); if (!commit_only) { - _target->enableStorage(root); - addResolvables (_target->resolvables(), true); + _target->enableStorage( root ); + addResolvables( _target->resolvables(), true ); } } void ZYppImpl::finishTarget() { -#warning not removing target resolvables for now -// if (_target) -// removeResolvables (_target->resolvables()); + if (_target) + removeInstalledResolvables(); _target = 0; } @@ -134,17 +144,25 @@ namespace zypp ZYPP_THROW( Exception("Target not initialized.") ); ZYpp::CommitResult res; + // must redirect to Target::Impl. This kind of commit should not be // in the Target interface. + res._result = _target->commit( pool(), medianr_r, res._errors, res._remaining, res._srcremaining ); + // reload new status from target + + removeInstalledResolvables(); + addResolvables( _target->resolvables(), true ); + MIL << "Commit (medianr " << medianr_r << ") returned: " << res._result << " (errors " << res._errors.size() << ", remaining " << res._remaining.size() << ", srcremaining " << res._srcremaining.size() << ")" << endl; + return res; } diff --git a/zypp/zypp_detail/ZYppImpl.h b/zypp/zypp_detail/ZYppImpl.h index 3c9e411..cbe44de 100644 --- a/zypp/zypp_detail/ZYppImpl.h +++ b/zypp/zypp_detail/ZYppImpl.h @@ -43,6 +43,9 @@ namespace zypp /** Dtor */ ~ZYppImpl(); + private: + void removeInstalledResolvables (); + public: /** */ ResPool pool() const