aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-02-03 16:53:09 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-02-03 16:53:09 +0000
commit35831832b06566d7dd316c9a4cf6d12f4727b978 (patch)
tree3e3bb03983e9554a0d278a6928d48e2bb7cc72b4
parent6a432ad8d444deda7fc65746e8028e21dfde2d1e (diff)
downloadpaludis-35831832b06566d7dd316c9a4cf6d12f4727b978.tar.gz
paludis-35831832b06566d7dd316c9a4cf6d12f4727b978.tar.xz
OutputManager::ignore_succeeded
-rw-r--r--paludis/buffer_output_manager.cc6
-rw-r--r--paludis/buffer_output_manager.hh1
-rw-r--r--paludis/command_output_manager.cc12
-rw-r--r--paludis/command_output_manager.hh1
-rw-r--r--paludis/file_output_manager.cc14
-rw-r--r--paludis/file_output_manager.hh1
-rw-r--r--paludis/format_messages_output_manager.cc6
-rw-r--r--paludis/format_messages_output_manager.hh1
-rw-r--r--paludis/forward_at_finish_output_manager.cc13
-rw-r--r--paludis/forward_at_finish_output_manager.hh1
-rw-r--r--paludis/ipc_output_manager.cc20
-rw-r--r--paludis/ipc_output_manager.hh1
-rw-r--r--paludis/output_manager.hh16
-rw-r--r--paludis/standard_output_manager.cc7
-rw-r--r--paludis/standard_output_manager.hh3
-rw-r--r--paludis/tee_output_manager.cc20
-rw-r--r--paludis/tee_output_manager.hh1
17 files changed, 115 insertions, 9 deletions
diff --git a/paludis/buffer_output_manager.cc b/paludis/buffer_output_manager.cc
index 0841c07..03c744e 100644
--- a/paludis/buffer_output_manager.cc
+++ b/paludis/buffer_output_manager.cc
@@ -73,6 +73,12 @@ BufferOutputManager::succeeded()
}
void
+BufferOutputManager::ignore_succeeded()
+{
+ _imp->child->ignore_succeeded();
+}
+
+void
BufferOutputManager::message(const MessageType, const std::string &)
{
}
diff --git a/paludis/buffer_output_manager.hh b/paludis/buffer_output_manager.hh
index 0888545..e255f6b 100644
--- a/paludis/buffer_output_manager.hh
+++ b/paludis/buffer_output_manager.hh
@@ -45,6 +45,7 @@ namespace paludis
virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void succeeded();
+ virtual void ignore_succeeded();
virtual void flush();
virtual bool want_to_flush() const;
virtual void nothing_more_to_come();
diff --git a/paludis/command_output_manager.cc b/paludis/command_output_manager.cc
index c9dbb5e..da128f1 100644
--- a/paludis/command_output_manager.cc
+++ b/paludis/command_output_manager.cc
@@ -59,6 +59,7 @@ namespace paludis
std::unique_ptr<SafeOFStream> stderr_stream;
bool already_nothing_more_to_come;
+ bool ignore_succeeded;
Imp(
const std::string & s,
@@ -74,7 +75,8 @@ namespace paludis
stderr_command(se),
succeeded_command(su),
nothing_more_to_come_command(n),
- already_nothing_more_to_come(false)
+ already_nothing_more_to_come(false),
+ ignore_succeeded(false)
{
}
};
@@ -180,7 +182,7 @@ CommandOutputManager::message(const MessageType, const std::string &)
void
CommandOutputManager::succeeded()
{
- if (! _imp->succeeded_command.empty())
+ if ((! _imp->ignore_succeeded) && (! _imp->succeeded_command.empty()))
{
Process process(ProcessCommand(_imp->succeeded_command));
if (0 != process.run().wait())
@@ -189,6 +191,12 @@ CommandOutputManager::succeeded()
}
void
+CommandOutputManager::ignore_succeeded()
+{
+ _imp->ignore_succeeded = true;
+}
+
+void
CommandOutputManager::flush()
{
}
diff --git a/paludis/command_output_manager.hh b/paludis/command_output_manager.hh
index 87850e7..f953b2e 100644
--- a/paludis/command_output_manager.hh
+++ b/paludis/command_output_manager.hh
@@ -59,6 +59,7 @@ namespace paludis
virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void succeeded();
+ virtual void ignore_succeeded();
virtual void flush();
virtual bool want_to_flush() const;
virtual void nothing_more_to_come();
diff --git a/paludis/file_output_manager.cc b/paludis/file_output_manager.cc
index b0b0124..e50ef21 100644
--- a/paludis/file_output_manager.cc
+++ b/paludis/file_output_manager.cc
@@ -41,7 +41,7 @@ namespace paludis
const std::shared_ptr<OutputManager> summary_output_manager;
const std::string summary_output_message;
- bool succeeded, unlinked, nothing_more_to_come;
+ bool succeeded, unlinked, nothing_more_to_come, ignore_succeeded;
Imp(
const FSPath & o,
@@ -58,7 +58,8 @@ namespace paludis
summary_output_message(s),
succeeded(false),
unlinked(false),
- nothing_more_to_come(false)
+ nothing_more_to_come(false),
+ ignore_succeeded(false)
{
}
};
@@ -102,6 +103,9 @@ FileOutputManager::message(const MessageType, const std::string &)
void
FileOutputManager::succeeded()
{
+ if (_imp->ignore_succeeded)
+ return;
+
_imp->succeeded = true;
if (! _imp->keep_on_success)
@@ -112,6 +116,12 @@ FileOutputManager::succeeded()
}
void
+FileOutputManager::ignore_succeeded()
+{
+ _imp->ignore_succeeded = true;
+}
+
+void
FileOutputManager::flush()
{
}
diff --git a/paludis/file_output_manager.hh b/paludis/file_output_manager.hh
index 0ad54f7..f87510a 100644
--- a/paludis/file_output_manager.hh
+++ b/paludis/file_output_manager.hh
@@ -50,6 +50,7 @@ namespace paludis
virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void succeeded();
+ virtual void ignore_succeeded();
virtual void flush();
virtual bool want_to_flush() const;
virtual void nothing_more_to_come();
diff --git a/paludis/format_messages_output_manager.cc b/paludis/format_messages_output_manager.cc
index c483067..67605b0 100644
--- a/paludis/format_messages_output_manager.cc
+++ b/paludis/format_messages_output_manager.cc
@@ -151,6 +151,12 @@ FormatMessagesOutputManager::succeeded()
}
void
+FormatMessagesOutputManager::ignore_succeeded()
+{
+ _imp->child->ignore_succeeded();
+}
+
+void
FormatMessagesOutputManager::flush()
{
_imp->child->flush();
diff --git a/paludis/format_messages_output_manager.hh b/paludis/format_messages_output_manager.hh
index 822c6ef..95203c0 100644
--- a/paludis/format_messages_output_manager.hh
+++ b/paludis/format_messages_output_manager.hh
@@ -66,6 +66,7 @@ namespace paludis
virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void succeeded();
+ virtual void ignore_succeeded();
virtual void flush();
virtual bool want_to_flush() const;
virtual void nothing_more_to_come();
diff --git a/paludis/forward_at_finish_output_manager.cc b/paludis/forward_at_finish_output_manager.cc
index c271e27..3c54f0d 100644
--- a/paludis/forward_at_finish_output_manager.cc
+++ b/paludis/forward_at_finish_output_manager.cc
@@ -38,6 +38,7 @@ namespace paludis
const std::shared_ptr<OutputManager> child;
bool success;
bool nothing_more_to_come;
+ bool ignore_succeeded;
Imp(
const bool s,
@@ -48,7 +49,8 @@ namespace paludis
if_failure(f),
child(m),
success(false),
- nothing_more_to_come(false)
+ nothing_more_to_come(false),
+ ignore_succeeded(false)
{
}
};
@@ -90,7 +92,14 @@ ForwardAtFinishOutputManager::stderr_stream()
void
ForwardAtFinishOutputManager::succeeded()
{
- _imp->success = true;
+ if (! _imp->ignore_succeeded)
+ _imp->success = true;
+}
+
+void
+ForwardAtFinishOutputManager::ignore_succeeded()
+{
+ _imp->ignore_succeeded = true;
}
void
diff --git a/paludis/forward_at_finish_output_manager.hh b/paludis/forward_at_finish_output_manager.hh
index 954827f..fc6c6cd 100644
--- a/paludis/forward_at_finish_output_manager.hh
+++ b/paludis/forward_at_finish_output_manager.hh
@@ -47,6 +47,7 @@ namespace paludis
virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void succeeded();
+ virtual void ignore_succeeded();
virtual void flush();
virtual bool want_to_flush() const;
virtual void message(const MessageType, const std::string &);
diff --git a/paludis/ipc_output_manager.cc b/paludis/ipc_output_manager.cc
index 0e4ba42..1b97e26 100644
--- a/paludis/ipc_output_manager.cc
+++ b/paludis/ipc_output_manager.cc
@@ -151,6 +151,18 @@ IPCOutputManager::succeeded()
}
void
+IPCOutputManager::ignore_succeeded()
+{
+ *_imp->pipe_command_write_stream << "IGNORE_SUCCEEDED 1" << '\0' << std::flush;
+
+ std::string response;
+ if (! std::getline(*_imp->pipe_command_read_stream, response, '\0'))
+ throw InternalError(PALUDIS_HERE, "couldn't get a pipe command response");
+ if (response != "O")
+ throw InternalError(PALUDIS_HERE, "got response '" + response + "'");
+}
+
+void
IPCOutputManager::flush()
{
}
@@ -293,6 +305,14 @@ IPCInputManager::_pipe_command_handler(const std::string & s)
return "O";
}
+ else if (tokens[0] == "IGNORE_SUCCEEDED")
+ {
+ if (tokens.size() != 2 || tokens[1] != "1")
+ return "Ebad IGNORE_SUCCEEDED subcommand";
+ _imp->output_manager->ignore_succeeded();
+
+ return "O";
+ }
else if (tokens[0] == "NOTHING_MORE_TO_COME")
{
if (tokens.size() != 2 || tokens[1] != "1")
diff --git a/paludis/ipc_output_manager.hh b/paludis/ipc_output_manager.hh
index a01d6ec..33b2506 100644
--- a/paludis/ipc_output_manager.hh
+++ b/paludis/ipc_output_manager.hh
@@ -51,6 +51,7 @@ namespace paludis
virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void succeeded();
+ virtual void ignore_succeeded();
virtual void flush();
virtual bool want_to_flush() const;
virtual void nothing_more_to_come();
diff --git a/paludis/output_manager.hh b/paludis/output_manager.hh
index d938ce9..ce06d49 100644
--- a/paludis/output_manager.hh
+++ b/paludis/output_manager.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -77,10 +77,24 @@ namespace paludis
*
* Calls to this method are done by the caller, not by whatever
* carries out the action in question.
+ *
+ * If ignore_succeeded() has previously been called, does nothing.
*/
virtual void succeeded() = 0;
/**
+ * Instructs the output manager to ignore future calls to
+ * succeeded().
+ *
+ * Typically this is used to force log files to be kept even if
+ * an error has occurred, if the error does not trigger the usual
+ * failure mechanisms.
+ *
+ * \since 0.59
+ */
+ virtual void ignore_succeeded() = 0;
+
+ /**
* May be called to indicate that no further output or messages
* will occur, allowing for files to be closed off etc.
*
diff --git a/paludis/standard_output_manager.cc b/paludis/standard_output_manager.cc
index 021473b..87d7c9d 100644
--- a/paludis/standard_output_manager.cc
+++ b/paludis/standard_output_manager.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -49,6 +49,11 @@ StandardOutputManager::succeeded()
}
void
+StandardOutputManager::ignore_succeeded()
+{
+}
+
+void
StandardOutputManager::flush()
{
}
diff --git a/paludis/standard_output_manager.hh b/paludis/standard_output_manager.hh
index 027bbe2..ebce384 100644
--- a/paludis/standard_output_manager.hh
+++ b/paludis/standard_output_manager.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -40,6 +40,7 @@ namespace paludis
virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void succeeded();
+ virtual void ignore_succeeded();
virtual void flush();
virtual bool want_to_flush() const;
virtual void message(const MessageType, const std::string &);
diff --git a/paludis/tee_output_manager.cc b/paludis/tee_output_manager.cc
index 530533f..7e33c36 100644
--- a/paludis/tee_output_manager.cc
+++ b/paludis/tee_output_manager.cc
@@ -139,6 +139,26 @@ TeeOutputManager::succeeded()
}
void
+TeeOutputManager::ignore_succeeded()
+{
+ for (OutputManagerSequence::ConstIterator i(_imp->streams->begin()), i_end(_imp->streams->end()) ;
+ i != i_end ; ++i)
+ (*i)->ignore_succeeded();
+
+ for (OutputManagerSequence::ConstIterator i(_imp->messages_streams->begin()), i_end(_imp->messages_streams->end()) ;
+ i != i_end ; ++i)
+ (*i)->ignore_succeeded();
+
+ for (OutputManagerSequence::ConstIterator i(_imp->stdout_streams->begin()), i_end(_imp->stdout_streams->end()) ;
+ i != i_end ; ++i)
+ (*i)->ignore_succeeded();
+
+ for (OutputManagerSequence::ConstIterator i(_imp->stderr_streams->begin()), i_end(_imp->stderr_streams->end()) ;
+ i != i_end ; ++i)
+ (*i)->ignore_succeeded();
+}
+
+void
TeeOutputManager::flush()
{
for (OutputManagerSequence::ConstIterator i(_imp->streams->begin()), i_end(_imp->streams->end()) ;
diff --git a/paludis/tee_output_manager.hh b/paludis/tee_output_manager.hh
index 8cd603f..52b9568 100644
--- a/paludis/tee_output_manager.hh
+++ b/paludis/tee_output_manager.hh
@@ -54,6 +54,7 @@ namespace paludis
virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void succeeded();
+ virtual void ignore_succeeded();
virtual void flush();
virtual bool want_to_flush() const;
virtual void nothing_more_to_come();