aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-05 21:40:43 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-05 22:05:31 +0000
commitf7a5e9195547cbe005e7a60804dd28b50a4608e9 (patch)
treee31e844b2717e7fb9316f9f57daa89a49be8063b
parent71238060b3f098780e1455e233a83b0e654362f3 (diff)
downloadpaludis-f7a5e9195547cbe005e7a60804dd28b50a4608e9.tar.gz
paludis-f7a5e9195547cbe005e7a60804dd28b50a4608e9.tar.xz
Correct counts when mixing installs and uninstalls
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index 016ce6d..951a0aa 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -127,13 +127,13 @@ namespace
const std::tr1::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
const ChangesToMakeDecision & decision,
- const int x, const int y,
+ const int x, const int y, const int last_x,
std::tr1::shared_ptr<OutputManager> & output_manager_goes_here)
{
Context context("When pretending for '" + stringify(*decision.origin_id()) + "':");
- if (x > 1)
- std::cout << std::string(stringify(x - 1).length() + stringify(y).length() + 4, '\010');
+ if (0 != last_x)
+ std::cout << std::string(stringify(last_x).length() + stringify(y).length() + 4, '\010');
std::cout << x << " of " << y << std::flush;
std::string command(cmdline.program_options.a_perform_program.argument());
@@ -1015,29 +1015,33 @@ namespace
const std::tr1::shared_ptr<Environment> env;
const ExecuteResolutionCommandLine & cmdline;
JobCounts & counts;
+ int & last_x;
DoOnePretendVisitor(
const std::tr1::shared_ptr<Environment> & e,
const ExecuteResolutionCommandLine & c,
- JobCounts & k) :
+ JobCounts & k,
+ int & l) :
env(e),
cmdline(c),
- counts(k)
+ counts(k),
+ last_x(l)
{
}
bool visit(const SimpleInstallJob & c) const
{
- if (0 == counts.x_installs)
+ if (0 == last_x)
std::cout << "Executing pretend actions: " << std::flush;
std::tr1::shared_ptr<OutputManager> output_manager_goes_here;
return do_pretend(env, cmdline, *c.changes_to_make_decision(), ++counts.x_installs, counts.y_installs,
- output_manager_goes_here);
+ last_x++, output_manager_goes_here);
}
bool visit(const UninstallJob &) const
{
+ ++counts.x_installs;
return true;
}
@@ -1069,6 +1073,7 @@ namespace
{
bool failed(false);
JobCounts counts;
+ int last_x(0);
for (JobIDSequence::ConstIterator c(lists.taken_job_ids()->begin()),
c_end(lists.taken_job_ids()->end()) ;
@@ -1083,9 +1088,10 @@ namespace
for (JobIDSequence::ConstIterator c(lists.taken_job_ids()->begin()),
c_end(lists.taken_job_ids()->end()) ;
c != c_end ; ++c)
- failed = failed || ! lists.jobs()->fetch(*c)->accept_returning<bool>(DoOnePretendVisitor(env, cmdline, counts));
+ failed = failed || ! lists.jobs()->fetch(*c)->accept_returning<bool>(DoOnePretendVisitor(
+ env, cmdline, counts, last_x));
- if (0 != counts.x_installs)
+ if (0 != last_x)
cout << endl;
if (0 != env->perform_hook(Hook("pretend_all_post")