aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2013-05-11 14:50:42 -0700
committerAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2013-05-18 14:07:32 -0700
commit26ad9436f05992068b94588fa1692f5a0d2ddb5a (patch)
tree73845ea28d328db8e0e449d110d4453aa9b974cf
parent37ab3e8fce69a97252e371576ddc423eefa3e983 (diff)
downloadpaludis-26ad9436f05992068b94588fa1692f5a0d2ddb5a.tar.gz
paludis-26ad9436f05992068b94588fa1692f5a0d2ddb5a.tar.xz
merger: refactor make_arrows
make_arrows is used to generate indicators for FS mergers. The arrows that are generated are similar for all FS mergers. Permit overriding of the arrow generation in the future if necessary by making the method virtual and hoist it into the base class FSMerger so that it may be shared across the VDB merger as well as the NDBAM merger. Signed-off-by: Saleem Abdulrasool <compnerd@compnerd.org>
-rw-r--r--paludis/fs_merger.cc55
-rw-r--r--paludis/fs_merger.hh2
-rw-r--r--paludis/ndbam_merger.cc55
-rw-r--r--paludis/ndbam_merger.hh1
-rw-r--r--paludis/repositories/e/vdb_merger.cc54
-rw-r--r--paludis/repositories/e/vdb_merger.hh1
6 files changed, 57 insertions, 111 deletions
diff --git a/paludis/fs_merger.cc b/paludis/fs_merger.cc
index 8567d16..bbe4466 100644
--- a/paludis/fs_merger.cc
+++ b/paludis/fs_merger.cc
@@ -19,6 +19,7 @@
*/
#include <paludis/fs_merger.hh>
+#include <paludis/util/enum_iterator.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/fd_holder.hh>
#include <paludis/util/log.hh>
@@ -1005,3 +1006,57 @@ FSMerger::do_dir_recursive(bool is_check, const FSPath & src, const FSPath & dst
Merger::do_dir_recursive(is_check, src, dst);
}
+std::string
+FSMerger::make_arrows(const FSMergerStatusFlags & flags) const
+{
+ std::string result(">>>");
+
+ for (EnumIterator<FSMergerStatusFlag> m, m_end(last_msi); m != m_end; ++m)
+ {
+ if (! flags[*m])
+ continue;
+
+ switch (*m)
+ {
+ case msi_unlinked_first:
+ result[0] = '<';
+ continue;
+
+ case msi_used_existing:
+ result[0] = '=';
+ continue;
+
+ case msi_parent_rename:
+ result[1] = '^';
+ continue;
+
+ case msi_rename:
+ result[1] = '-';
+ continue;
+
+ case msi_as_hardlink:
+ result[1] = '&';
+ continue;
+
+ case msi_fixed_ownership:
+ result[2] = '~';
+ continue;
+
+ case msi_setid_bits:
+ result[2] = '*';
+ continue;
+
+ case msi_xattr:
+ result[2] = '+';
+ continue;
+
+ case last_msi:
+ break;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Unhandled MergeStatusFlag '" + stringify(static_cast<long>(*m)) + "'");
+ }
+
+ return result;
+}
+
diff --git a/paludis/fs_merger.hh b/paludis/fs_merger.hh
index 0084171..e9bde0f 100644
--- a/paludis/fs_merger.hh
+++ b/paludis/fs_merger.hh
@@ -228,6 +228,8 @@ namespace paludis
///\}
+ virtual std::string make_arrows(const FSMergerStatusFlags & flags) const;
+
public:
///\name Basic operations
///\{
diff --git a/paludis/ndbam_merger.cc b/paludis/ndbam_merger.cc
index fa75287..7eed0a2 100644
--- a/paludis/ndbam_merger.cc
+++ b/paludis/ndbam_merger.cc
@@ -27,7 +27,6 @@
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/options.hh>
#include <paludis/util/make_named_values.hh>
-#include <paludis/util/enum_iterator.hh>
#include <paludis/util/safe_ofstream.hh>
#include <paludis/util/safe_ifstream.hh>
#include <paludis/util/timestamp.hh>
@@ -305,60 +304,6 @@ NDBAMMerger::make_config_protect_name(const FSPath & src, const FSPath & dst)
return result_name;
}
-std::string
-NDBAMMerger::make_arrows(const FSMergerStatusFlags & flags) const
-{
- std::string result(">>>");
- for (EnumIterator<FSMergerStatusFlag> m, m_end(last_msi) ;
- m != m_end ; ++m)
- {
- if (! flags[*m])
- continue;
-
- switch (*m)
- {
- case msi_unlinked_first:
- result[0] = '<';
- continue;
-
- case msi_used_existing:
- result[0] = '=';
- continue;
-
- case msi_parent_rename:
- result[1] = '^';
- continue;
-
- case msi_rename:
- result[1] = '-';
- continue;
-
- case msi_as_hardlink:
- result[1] = '&';
- continue;
-
- case msi_fixed_ownership:
- result[2] = '~';
- continue;
-
- case msi_setid_bits:
- result[2] = '*';
- continue;
-
- case msi_xattr:
- result[2] = '+';
- continue;
-
- case last_msi:
- break;
- }
-
- throw InternalError(PALUDIS_HERE, "Unhandled MergeStatusFlag '" + stringify(static_cast<long>(*m)) + "'");
- }
-
- return result;
-}
-
void
NDBAMMerger::merge()
{
diff --git a/paludis/ndbam_merger.hh b/paludis/ndbam_merger.hh
index 7bfa7fd..ddc5077 100644
--- a/paludis/ndbam_merger.hh
+++ b/paludis/ndbam_merger.hh
@@ -80,7 +80,6 @@ namespace paludis
{
private:
void display_override(const std::string &) const;
- std::string make_arrows(const FSMergerStatusFlags &) const;
Pimp<NDBAMMerger> _imp;
diff --git a/paludis/repositories/e/vdb_merger.cc b/paludis/repositories/e/vdb_merger.cc
index 244c646..9d033e3 100644
--- a/paludis/repositories/e/vdb_merger.cc
+++ b/paludis/repositories/e/vdb_merger.cc
@@ -31,7 +31,6 @@
#include <paludis/util/options.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_null_shared_ptr.hh>
-#include <paludis/util/enum_iterator.hh>
#include <paludis/util/timestamp.hh>
#include <paludis/util/env_var_names.hh>
#include <paludis/util/safe_ofstream.hh>
@@ -344,56 +343,3 @@ VDBMerger::display_override(const std::string & message) const
_imp->params.output_manager()->stdout_stream() << message << std::endl;
}
-std::string
-VDBMerger::make_arrows(const FSMergerStatusFlags & flags) const
-{
- std::string result(">>>");
- for (EnumIterator<FSMergerStatusFlag> m, m_end(last_msi) ;
- m != m_end ; ++m)
- {
- if (! flags[*m])
- continue;
-
- switch (*m)
- {
- case msi_unlinked_first:
- result[0] = '<';
- continue;
-
- case msi_used_existing:
- result[0] = '=';
- continue;
-
- case msi_parent_rename:
- result[1] = '^';
- continue;
-
- case msi_rename:
- result[1] = '-';
- continue;
-
- case msi_as_hardlink:
- result[1] = '&';
- continue;
-
- case msi_fixed_ownership:
- result[2] = '~';
- continue;
-
- case msi_setid_bits:
- result[2] = '*';
- continue;
-
- case msi_xattr:
- result[2] = '+';
- continue;
-
- case last_msi:
- break;
- }
- throw InternalError(PALUDIS_HERE, "Unhandled MergeStatusFlag '" + stringify(static_cast<long>(*m)) + "'");
- }
-
- return result;
-}
-
diff --git a/paludis/repositories/e/vdb_merger.hh b/paludis/repositories/e/vdb_merger.hh
index 16e4c68..753d19f 100644
--- a/paludis/repositories/e/vdb_merger.hh
+++ b/paludis/repositories/e/vdb_merger.hh
@@ -81,7 +81,6 @@ namespace paludis
{
private:
void display_override(const std::string &) const;
- std::string make_arrows(const FSMergerStatusFlags &) const;
Pimp<VDBMerger> _imp;