From a4efb6f557172bfab2326291a0e313402ca532dd Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Thu, 8 May 2008 12:21:32 +0000 Subject: [PATCH] - new solution action for removing requirements/conflicts Bug 387631 --- zypp/solver/detail/ProblemSolutionCombi.cc | 6 ++++++ zypp/solver/detail/ProblemSolutionCombi.h | 7 ++++++- zypp/solver/detail/SATResolver.cc | 18 ++---------------- zypp/solver/detail/SolutionAction.cc | 19 +++++++++++++------ zypp/solver/detail/SolutionAction.h | 10 +++++++++- 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/zypp/solver/detail/ProblemSolutionCombi.cc b/zypp/solver/detail/ProblemSolutionCombi.cc index ba6e522..3273fcb 100644 --- a/zypp/solver/detail/ProblemSolutionCombi.cc +++ b/zypp/solver/detail/ProblemSolutionCombi.cc @@ -53,6 +53,12 @@ ProblemSolutionCombi::ProblemSolutionCombi( ResolverProblem_Ptr parent) _details = ""; } +void ProblemSolutionCombi::addSingleAction( Capability capability, const TransactionKind action) +{ + addAction (new TransactionSolutionAction(capability, action)); + actNumber++; +} + void ProblemSolutionCombi::addSingleAction( PoolItem item, const TransactionKind action) { addAction (new TransactionSolutionAction(item, action)); diff --git a/zypp/solver/detail/ProblemSolutionCombi.h b/zypp/solver/detail/ProblemSolutionCombi.h index 4fd18ff..a996411 100644 --- a/zypp/solver/detail/ProblemSolutionCombi.h +++ b/zypp/solver/detail/ProblemSolutionCombi.h @@ -53,11 +53,16 @@ namespace zypp **/ ProblemSolutionCombi( ResolverProblem_Ptr parent ); /** - * Add a single action + * Add a single action of an item */ void addSingleAction( PoolItem item, const TransactionKind action); /** + * Add a single action of an capability + */ + void addSingleAction( Capability capability, const TransactionKind action); + + /** * returns the number of actions */ int actionCount() { return actNumber;} diff --git a/zypp/solver/detail/SATResolver.cc b/zypp/solver/detail/SATResolver.cc index 35367d0..d98731f 100644 --- a/zypp/solver/detail/SATResolver.cc +++ b/zypp/solver/detail/SATResolver.cc @@ -1067,14 +1067,7 @@ SATResolver::problems () break; case SOLVER_INSTALL_SOLVABLE_PROVIDES: { - Id p, *pp; - FOR_PROVIDES(p, pp, what); - { - PoolItem poolItem = _pool.find (sat::Solvable(p)); - if (poolItem.status().isToBeInstalled() - || poolItem.status().staysUninstalled()) - problemSolution->addSingleAction (poolItem, KEEP); - } + problemSolution->addSingleAction (Capability(what), REMOVE_REQUIRE); string description = str::form (_("do not ask to install a solvable providing %s"), dep2str(pool, what)); MIL << description << endl; problemSolution->addDescription (description); @@ -1082,14 +1075,7 @@ SATResolver::problems () break; case SOLVER_ERASE_SOLVABLE_PROVIDES: { - Id p, *pp; - FOR_PROVIDES(p, pp, what); - { - PoolItem poolItem = _pool.find (sat::Solvable(p)); - if (poolItem.status().isToBeUninstalled() - || poolItem.status().staysInstalled()) - problemSolution->addSingleAction (poolItem, KEEP); - } + problemSolution->addSingleAction (Capability(what), REMOVE_CONFLICT); string description = str::form (_("do not ask to delete all solvables providing %s"), dep2str(pool, what)); MIL << description << endl; problemSolution->addDescription (description); diff --git a/zypp/solver/detail/SolutionAction.cc b/zypp/solver/detail/SolutionAction.cc index bc9a71d..1c4d48e 100644 --- a/zypp/solver/detail/SolutionAction.cc +++ b/zypp/solver/detail/SolutionAction.cc @@ -63,13 +63,14 @@ TransactionSolutionAction::dumpOn( ostream& os) const { os << "TransactionSolutionAction: "; switch (_action) { - case KEEP: os << "Keep"; break; - case INSTALL: os << "Install"; break; - case REMOVE: os << "Remove"; break; - case UNLOCK: os << "Unlock"; break; + case KEEP: os << "Keep " << _item; break; + case INSTALL: os << "Install " << _item; break; + case REMOVE: os << "Remove " << _item; break; + case UNLOCK: os << "Unlock " << _item; break; + case REMOVE_REQUIRE: os << "Remove require " << _capability; break; + case REMOVE_CONFLICT: os << "Remove conflict " << _capability; break; } - os << " "; - os << _item; + os << endl; return os; } @@ -151,6 +152,12 @@ TransactionSolutionAction::execute(Resolver & resolver) const ret = _item.status().setLock (false, ResStatus::USER); if (!ret) ERR << "Cannot unlock " << _item << endl; break; + case REMOVE_REQUIRE: + resolver.removeExtraRequire (_capability); + break; + case REMOVE_CONFLICT: + resolver.removeExtraConflict (_capability); + break; default: ERR << "Wrong TransactionKind" << endl; ret = false; diff --git a/zypp/solver/detail/SolutionAction.h b/zypp/solver/detail/SolutionAction.h index 8ca9b2c..e38d309 100644 --- a/zypp/solver/detail/SolutionAction.h +++ b/zypp/solver/detail/SolutionAction.h @@ -67,7 +67,9 @@ namespace zypp KEEP, INSTALL, REMOVE, - UNLOCK + UNLOCK, + REMOVE_REQUIRE, + REMOVE_CONFLICT, } TransactionKind; @@ -79,6 +81,11 @@ namespace zypp : SolutionAction(), _item( item ), _action( action ) {} + TransactionSolutionAction( Capability capability, + TransactionKind action ) + : SolutionAction(), + _capability( capability ), _action( action ) {} + TransactionSolutionAction( TransactionKind action ) : SolutionAction(), _item(), _action( action ) {} @@ -99,6 +106,7 @@ namespace zypp protected: PoolItem _item; + Capability _capability; const TransactionKind _action; }; -- 2.7.4