aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-06 21:07:09 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-08 16:34:19 +0000
commitefa3668957f10f9e4a12dad8a203abd9bb58e85c (patch)
tree7cb71eac4c701d51cab9941ff3ccfed19fafec00
parentc93bf98d8a4fccf72efa12d776f1bfe6600ac05f (diff)
downloadpaludis-efa3668957f10f9e4a12dad8a203abd9bb58e85c.tar.gz
paludis-efa3668957f10f9e4a12dad8a203abd9bb58e85c.tar.xz
forward_on_failure -> forward_at_finished
Can now be used to forward on success too.
-rw-r--r--paludis/environments/paludis/default_output.conf4
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/forward_at_finish_output_manager-fwd.hh (renamed from paludis/forward_on_failure_output_manager-fwd.hh)8
-rw-r--r--paludis/forward_at_finish_output_manager.cc (renamed from paludis/forward_on_failure_output_manager.cc)53
-rw-r--r--paludis/forward_at_finish_output_manager.hh (renamed from paludis/forward_on_failure_output_manager.hh)19
-rw-r--r--paludis/output_manager_factory.cc4
6 files changed, 53 insertions, 37 deletions
diff --git a/paludis/environments/paludis/default_output.conf b/paludis/environments/paludis/default_output.conf
index 1174ad7..330058c 100644
--- a/paludis/environments/paludis/default_output.conf
+++ b/paludis/environments/paludis/default_output.conf
@@ -56,8 +56,10 @@ handler = standard
# For when we want to send output to stdout / stderr, but only if things failed:
[manager standard_on_failure]
-handler = forward_on_failure
+handler = forward_at_finish
child = standard
+if_success = false
+if_failure = true
# For when we're running with other processes, we send output to stdout /
# stderr, but only when we're told to do so, to avoid mixing up outputs from
diff --git a/paludis/files.m4 b/paludis/files.m4
index 62f2d1c..2767d66 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -40,7 +40,7 @@ add(`filtered_generator', `hh', `cc', `fwd', `test')
add(`find_unused_packages_task', `hh', `cc')
add(`format_messages_output_manager', `hh', `fwd', `cc')
add(`formatter', `hh', `fwd', `cc')
-add(`forward_on_failure_output_manager', `hh', `fwd', `cc')
+add(`forward_at_finish_output_manager', `hh', `fwd', `cc')
add(`fuzzy_finder', `hh', `cc', `test')
add(`generator', `hh', `cc', `fwd', `test')
add(`generator_handler', `hh', `cc', `fwd')
diff --git a/paludis/forward_on_failure_output_manager-fwd.hh b/paludis/forward_at_finish_output_manager-fwd.hh
index c3c8ec8..d0a8412 100644
--- a/paludis/forward_on_failure_output_manager-fwd.hh
+++ b/paludis/forward_at_finish_output_manager-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 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
@@ -17,12 +17,12 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef PALUDIS_GUARD_PALUDIS_FORWARD_ON_FAILURE_OUTPUT_MANAGER_FWD_HH
-#define PALUDIS_GUARD_PALUDIS_FORWARD_ON_FAILURE_OUTPUT_MANAGER_FWD_HH 1
+#ifndef PALUDIS_GUARD_PALUDIS_FORWARD_AT_FINISH_OUTPUT_MANAGER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_FORWARD_AT_FINISH_OUTPUT_MANAGER_FWD_HH 1
namespace paludis
{
- class ForwardOnFailureOutputManager;
+ class ForwardAtFinishOutputManager;
}
#endif
diff --git a/paludis/forward_on_failure_output_manager.cc b/paludis/forward_at_finish_output_manager.cc
index 52028c9..8c2a38b 100644
--- a/paludis/forward_on_failure_output_manager.cc
+++ b/paludis/forward_at_finish_output_manager.cc
@@ -17,7 +17,7 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/forward_on_failure_output_manager.hh>
+#include <paludis/forward_at_finish_output_manager.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/set.hh>
#include <paludis/util/map.hh>
@@ -32,16 +32,21 @@ using namespace paludis;
namespace paludis
{
template <>
- struct Implementation<ForwardOnFailureOutputManager>
+ struct Implementation<ForwardAtFinishOutputManager>
{
std::stringstream stdout_stream;
std::stringstream stderr_stream;
+ const bool if_success, if_failure;
const std::tr1::shared_ptr<OutputManager> child;
bool success;
Implementation(
+ const bool s,
+ const bool f,
const std::tr1::shared_ptr<OutputManager> & m
) :
+ if_success(s),
+ if_failure(f),
child(m),
success(false)
{
@@ -49,14 +54,18 @@ namespace paludis
};
}
-ForwardOnFailureOutputManager::ForwardOnFailureOutputManager(const std::tr1::shared_ptr<OutputManager> & m) :
- PrivateImplementationPattern<ForwardOnFailureOutputManager>(new Implementation<ForwardOnFailureOutputManager>(m))
+ForwardAtFinishOutputManager::ForwardAtFinishOutputManager(
+ const bool s,
+ const bool f,
+ const std::tr1::shared_ptr<OutputManager> & m) :
+ PrivateImplementationPattern<ForwardAtFinishOutputManager>(
+ new Implementation<ForwardAtFinishOutputManager>(s, f, m))
{
}
-ForwardOnFailureOutputManager::~ForwardOnFailureOutputManager()
+ForwardAtFinishOutputManager::~ForwardAtFinishOutputManager()
{
- if (! _imp->success)
+ if ((_imp->if_success && _imp->success) || (_imp->if_failure && ! _imp->success))
{
std::copy((std::istreambuf_iterator<char>(_imp->stdout_stream)),
std::istreambuf_iterator<char>(),
@@ -68,43 +77,43 @@ ForwardOnFailureOutputManager::~ForwardOnFailureOutputManager()
}
std::ostream &
-ForwardOnFailureOutputManager::stdout_stream()
+ForwardAtFinishOutputManager::stdout_stream()
{
return _imp->stdout_stream;
}
std::ostream &
-ForwardOnFailureOutputManager::stderr_stream()
+ForwardAtFinishOutputManager::stderr_stream()
{
return _imp->stderr_stream;
}
void
-ForwardOnFailureOutputManager::succeeded()
+ForwardAtFinishOutputManager::succeeded()
{
_imp->success = true;
}
void
-ForwardOnFailureOutputManager::message(const MessageType, const std::string &)
+ForwardAtFinishOutputManager::message(const MessageType, const std::string &)
{
}
void
-ForwardOnFailureOutputManager::flush()
+ForwardAtFinishOutputManager::flush()
{
}
bool
-ForwardOnFailureOutputManager::want_to_flush() const
+ForwardAtFinishOutputManager::want_to_flush() const
{
return false;
}
void
-ForwardOnFailureOutputManager::nothing_more_to_come()
+ForwardAtFinishOutputManager::nothing_more_to_come()
{
- if (_imp->success)
+ if (! ((_imp->if_success && _imp->success) || (_imp->if_failure && ! _imp->success)))
{
_imp->stdout_stream.clear();
_imp->stderr_stream.clear();
@@ -112,29 +121,31 @@ ForwardOnFailureOutputManager::nothing_more_to_come()
}
const std::tr1::shared_ptr<const Set<std::string> >
-ForwardOnFailureOutputManager::factory_managers()
+ForwardAtFinishOutputManager::factory_managers()
{
std::tr1::shared_ptr<Set<std::string> > result(new Set<std::string>);
- result->insert("forward_on_failure");
+ result->insert("forward_at_finish");
return result;
}
const std::tr1::shared_ptr<OutputManager>
-ForwardOnFailureOutputManager::factory_create(
+ForwardAtFinishOutputManager::factory_create(
const OutputManagerFactory::KeyFunction & key_func,
const OutputManagerFactory::CreateChildFunction & create_child_function,
const OutputManagerFactory::ReplaceVarsFunc &)
{
- std::string child_s(key_func("child"));
+ std::string child_s(key_func("child")), if_success_s(key_func("if_success")), if_failure_s(key_func("if_failure"));
if (child_s.empty())
throw ConfigurationError("Key 'child' not specified when creating a forward_on_failure output manager");
std::tr1::shared_ptr<OutputManager> child(create_child_function(child_s));
- return make_shared_ptr(new ForwardOnFailureOutputManager(child));
+ return make_shared_ptr(new ForwardAtFinishOutputManager(
+ destringify<bool>(if_success_s),
+ destringify<bool>(if_failure_s),
+ child));
}
-template class PrivateImplementationPattern<ForwardOnFailureOutputManager>;
-
+template class PrivateImplementationPattern<ForwardAtFinishOutputManager>;
diff --git a/paludis/forward_on_failure_output_manager.hh b/paludis/forward_at_finish_output_manager.hh
index d3ccd06..0c93540 100644
--- a/paludis/forward_on_failure_output_manager.hh
+++ b/paludis/forward_at_finish_output_manager.hh
@@ -17,10 +17,10 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef PALUDIS_GUARD_PALUDIS_FORWARD_ON_FAILURE_OUTPUT_MANAGER_HH
-#define PALUDIS_GUARD_PALUDIS_FORWARD_ON_FAILURE_OUTPUT_MANAGER_HH 1
+#ifndef PALUDIS_GUARD_PALUDIS_FORWARD_AT_FINISH_OUTPUT_MANAGER_HH
+#define PALUDIS_GUARD_PALUDIS_FORWARD_AT_FINISH_OUTPUT_MANAGER_HH 1
-#include <paludis/file_output_manager-fwd.hh>
+#include <paludis/forward_at_finish_output_manager-fwd.hh>
#include <paludis/output_manager.hh>
#include <paludis/output_manager_factory.hh>
#include <paludis/util/set-fwd.hh>
@@ -30,13 +30,16 @@
namespace paludis
{
- class PALUDIS_VISIBLE ForwardOnFailureOutputManager :
- private PrivateImplementationPattern<ForwardOnFailureOutputManager>,
+ class PALUDIS_VISIBLE ForwardAtFinishOutputManager :
+ private PrivateImplementationPattern<ForwardAtFinishOutputManager>,
public OutputManager
{
public:
- ForwardOnFailureOutputManager(const std::tr1::shared_ptr<OutputManager> & child);
- ~ForwardOnFailureOutputManager();
+ ForwardAtFinishOutputManager(
+ const bool if_success,
+ const bool if_failure,
+ const std::tr1::shared_ptr<OutputManager> & child);
+ ~ForwardAtFinishOutputManager();
virtual std::ostream & stdout_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -58,7 +61,7 @@ namespace paludis
};
#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
- extern template class PrivateImplementationPattern<ForwardOnFailureOutputManager>;
+ extern template class PrivateImplementationPattern<ForwardAtFinishOutputManager>;
#endif
}
diff --git a/paludis/output_manager_factory.cc b/paludis/output_manager_factory.cc
index a802734..03cc4d4 100644
--- a/paludis/output_manager_factory.cc
+++ b/paludis/output_manager_factory.cc
@@ -37,7 +37,7 @@
#include <paludis/buffer_output_manager.hh>
#include <paludis/file_output_manager.hh>
#include <paludis/format_messages_output_manager.hh>
-#include <paludis/forward_on_failure_output_manager.hh>
+#include <paludis/forward_at_finish_output_manager.hh>
#include <paludis/standard_output_manager.hh>
#include <paludis/tee_output_manager.hh>
@@ -97,7 +97,7 @@ OutputManagerFactory::OutputManagerFactory() :
add_manager(BufferOutputManager::factory_managers(), BufferOutputManager::factory_create);
add_manager(FileOutputManager::factory_managers(), FileOutputManager::factory_create);
add_manager(FormatMessagesOutputManager::factory_managers(), FormatMessagesOutputManager::factory_create);
- add_manager(ForwardOnFailureOutputManager::factory_managers(), ForwardOnFailureOutputManager::factory_create);
+ add_manager(ForwardAtFinishOutputManager::factory_managers(), ForwardAtFinishOutputManager::factory_create);
add_manager(StandardOutputManager::factory_managers(), StandardOutputManager::factory_create);
add_manager(TeeOutputManager::factory_managers(), TeeOutputManager::factory_create);
}