aboutsummaryrefslogtreecommitdiff
path: root/paludis/ndbam_merger.cc
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2013-05-12 11:32:59 -0700
committerAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2013-05-18 14:07:32 -0700
commit6bdc2e7523f8b2eebf78401356f568cace26f301 (patch)
treef625a1dcb31286850744387d4172a3c86cc82fff /paludis/ndbam_merger.cc
parent97d0f19557cbc209dab9fbfe8fcf74d9238d6161 (diff)
downloadpaludis-6bdc2e7523f8b2eebf78401356f568cace26f301.tar.gz
paludis-6bdc2e7523f8b2eebf78401356f568cace26f301.tar.xz
merger: refactor merge display
This moves the stringification of the classification, and the formatting of the merge display into FSMerger so that it may be shared across the VDB merger and the NDBAM merger. This will be used internally in FSMerger for selective parts. Signed-off-by: Saleem Abdulrasool <compnerd@compnerd.org>
Diffstat (limited to 'paludis/ndbam_merger.cc')
-rw-r--r--paludis/ndbam_merger.cc40
1 files changed, 22 insertions, 18 deletions
diff --git a/paludis/ndbam_merger.cc b/paludis/ndbam_merger.cc
index 7eed0a2a7..24ce4e2c7 100644
--- a/paludis/ndbam_merger.cc
+++ b/paludis/ndbam_merger.cc
@@ -159,24 +159,24 @@ namespace
void
NDBAMMerger::record_install_file(const FSPath & src, const FSPath & dst_dir, const std::string & dst_name, const FSMergerStatusFlags & flags)
{
- std::string tidy(stringify((dst_dir / dst_name).strip_leading(_imp->realroot))),
- tidy_real(stringify((dst_dir / src.basename()).strip_leading(_imp->realroot)));
+ const auto file(dst_dir / src.basename());
+ const auto renamed_file(dst_dir / dst_name);
- FSPath dst_dir_name(dst_dir / dst_name);
- FSStat dst_dir_name_stat(dst_dir_name);
+ const std::string tidy(stringify(renamed_file.strip_leading(_imp->realroot))),
+ tidy_real(stringify(file.strip_leading(_imp->realroot)));
+
+ FSStat dst_dir_name_stat(renamed_file);
time_t timestamp(dst_dir_name_stat.mtim().seconds());
- SafeIFStream infile(dst_dir_name);
+ SafeIFStream infile(renamed_file);
if (! infile)
- throw FSMergerError("Cannot read '" + stringify(dst_dir_name) + "'");
+ throw FSMergerError("Cannot read '" + stringify(renamed_file) + "'");
MD5 md5(infile);
- std::string line(make_arrows(flags) + " [obj] " + tidy_real);
- if (tidy_real != tidy)
- line.append(" (" + FSPath(tidy).basename() + ")");
- display_override(line);
+ display_merge(et_file, file, flags,
+ src.basename() == dst_name ? "" : dst_name);
std::string part;
if (_imp->params.parts())
@@ -194,8 +194,10 @@ NDBAMMerger::record_install_file(const FSPath & src, const FSPath & dst_dir, con
void
NDBAMMerger::record_install_dir(const FSPath & src, const FSPath & dst_dir, const FSMergerStatusFlags & flags)
{
- std::string tidy(stringify((dst_dir / src.basename()).strip_leading(_imp->realroot)));
- display_override(make_arrows(flags) + " [dir] " + tidy);
+ const auto dir(dst_dir / src.basename());
+ const std::string tidy(stringify(dir.strip_leading(_imp->realroot)));
+
+ display_merge(et_dir, dir, flags);
*_imp->contents_file << "type=dir path=" << escape(tidy) << std::endl;
}
@@ -203,8 +205,9 @@ NDBAMMerger::record_install_dir(const FSPath & src, const FSPath & dst_dir, cons
void
NDBAMMerger::record_install_under_dir(const FSPath & dst, const FSMergerStatusFlags & flags)
{
- std::string tidy(stringify(dst.strip_leading(_imp->realroot)));
- display_override(make_arrows(flags) + " [dir] " + tidy);
+ const std::string tidy(stringify(dst.strip_leading(_imp->realroot)));
+
+ display_merge(et_dir, dst, flags);
*_imp->contents_file << "type=dir path=" << escape(tidy) << std::endl;
}
@@ -212,11 +215,12 @@ NDBAMMerger::record_install_under_dir(const FSPath & dst, const FSMergerStatusFl
void
NDBAMMerger::record_install_sym(const FSPath & src, const FSPath & dst_dir, const FSMergerStatusFlags & flags)
{
- std::string tidy(stringify((dst_dir / src.basename()).strip_leading(_imp->realroot)));
- std::string target((dst_dir / src.basename()).readlink());
- Timestamp timestamp((dst_dir / src.basename()).stat().mtim());
+ const auto sym(dst_dir / src.basename());
+ const std::string tidy(stringify(sym.strip_leading(_imp->realroot)));
+ const std::string target(sym.readlink());
+ const Timestamp timestamp(sym.stat().mtim());
- display_override(make_arrows(flags) + " [sym] " + tidy);
+ display_merge(et_sym, sym, flags);
*_imp->contents_file << "type=sym path=" << escape(tidy);
*_imp->contents_file << " target=" << escape(target);