From: Jan Kupec Date: Wed, 5 Dec 2007 12:36:20 +0000 (+0000) Subject: - reset selections after install/remove in zypper shell X-Git-Tag: BASE-SuSE-Linux-11_0-Branch~495 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f5b46557aaec8b1b5b3aa651cbbc73200e46f998;p=platform%2Fupstream%2Fzypper.git - reset selections after install/remove in zypper shell --- diff --git a/src/zypper-misc.cc b/src/zypper-misc.cc index 55e3142..1b17798 100644 --- a/src/zypper-misc.cc +++ b/src/zypper-misc.cc @@ -412,6 +412,47 @@ void mark_by_capability (const Zypper & zypper, } } +// ---------------------------------------------------------------------------- + +void remove_selections(Zypper & zypper) +{ + MIL << "Removing user selections from the solver pool" << endl; + + DBG << "Removing user setToBeInstalled()/Removed()" << endl; + + // iterate pool, searching for ResStatus::isByUser() + // TODO optimize: remember user selections and iterate by name + // TODO optimize: it seems this is actually needed only if the selection was + // not committed (user has chosen not to continue) + const ResPool & pool = God->pool(); + cout << "pool size" << pool.size() << endl; + for (ResPool::const_iterator it = pool.begin(); it != pool.end(); ++it) + if (it->status().isByUser()) + { + DBG << "Removing user setToBeInstalled()/Removed()" << endl; + it->status().resetTransact(zypp::ResStatus::USER); + } + + DBG << "Removing user addRequire() addConflict()" << endl; + + Resolver_Ptr solver = God->resolver(); + CapSet capSet = solver->getConflict(); + for (CapSet::const_iterator it = capSet.begin(); it != capSet.end(); ++it) + { + DBG << "removing conflict: " << (*it) << endl; + solver->removeConflict(*it); + } + capSet = solver->getRequire(); + for (CapSet::const_iterator it = capSet.begin(); it != capSet.end(); ++it) + { + DBG << "removing require: " << (*it) << endl; + solver->removeRequire(*it); + } + + MIL << "DONE" << endl; +} + +// ---------------------------------------------------------------------------- // debugging static diff --git a/src/zypper-misc.h b/src/zypper-misc.h index 691ad2e..89df08d 100644 --- a/src/zypper-misc.h +++ b/src/zypper-misc.h @@ -40,6 +40,12 @@ void mark_by_capability (const Zypper & zypper, const zypp::ResObject::Kind &kind, const std::string &capstr ); +/** + * Reset all selections made by mark_* methods. Needed in the shell to reset + * selections after the install and remove commands. + */ +void remove_selections(Zypper & zypper); + int show_summary(Zypper & zypper); //std::string calculate_token(); diff --git a/src/zypper.cc b/src/zypper.cc index 20d5190..132343a 100644 --- a/src/zypper.cc +++ b/src/zypper.cc @@ -451,6 +451,20 @@ void Zypper::commandShell() void Zypper::shellCleanup() { + MIL << "Cleaning up for the next command." << endl; + + switch(command().toEnum()) + { + case ZypperCommand::INSTALL_e: + case ZypperCommand::REMOVE_e: + //case Zyppercommand::UPDATE_e: TODO once the update will take arguments + { + remove_selections(*this); + break; + } + default:; + } + // clear any previous arguments _arguments.clear(); // clear command options @@ -490,7 +504,6 @@ void Zypper::safeDoCommand() if (exiting()) return; doCommand(); - setCommand(ZypperCommand::NONE); } catch (const AbortRequestException & ex) {