aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/e/vdb_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/repositories/e/vdb_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/repositories/e/vdb_merger.cc')
-rw-r--r--paludis/repositories/e/vdb_merger.cc39
1 files changed, 22 insertions, 17 deletions
diff --git a/paludis/repositories/e/vdb_merger.cc b/paludis/repositories/e/vdb_merger.cc
index 9d033e395..af74b35ec 100644
--- a/paludis/repositories/e/vdb_merger.cc
+++ b/paludis/repositories/e/vdb_merger.cc
@@ -148,20 +148,21 @@ VDBMerger::extend_hook(const Hook & h)
void
VDBMerger::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)));
- Timestamp timestamp((dst_dir / dst_name).stat().mtim());
+ const auto file(dst_dir / src.basename());
+ const auto renamed_file(dst_dir / dst_name);
- SafeIFStream infile(FSPath(dst_dir / dst_name));
+ const std::string tidy(stringify(renamed_file.strip_leading(_imp->realroot))),
+ tidy_real(stringify(file.strip_leading(_imp->realroot)));
+ const Timestamp timestamp(renamed_file.stat().mtim());
+
+ SafeIFStream infile(renamed_file);
if (! infile)
- throw FSMergerError("Cannot read '" + stringify(FSPath(dst_dir / dst_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, renamed_file, flags,
+ src.basename() == dst_name ? "" : dst_name);
*_imp->contents_file << "obj " << tidy_real << " " << md5.hexsum() << " " << timestamp.seconds() << std::endl;
}
@@ -169,8 +170,10 @@ VDBMerger::record_install_file(const FSPath & src, const FSPath & dst_dir, const
void
VDBMerger::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 << "dir " << tidy << std::endl;
}
@@ -178,8 +181,9 @@ VDBMerger::record_install_dir(const FSPath & src, const FSPath & dst_dir, const
void
VDBMerger::record_install_under_dir(const FSPath & dst_dir, const FSMergerStatusFlags & flags)
{
- std::string tidy(stringify(dst_dir.strip_leading(_imp->realroot)));
- display_override(make_arrows(flags) + " [dir] " + tidy);
+ const std::string tidy(stringify(dst_dir.strip_leading(_imp->realroot)));
+
+ display_merge(et_dir, dst_dir, flags);
*_imp->contents_file << "dir " << tidy << std::endl;
}
@@ -187,11 +191,12 @@ VDBMerger::record_install_under_dir(const FSPath & dst_dir, const FSMergerStatus
void
VDBMerger::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 << "sym " << tidy << " -> " << target << " " << timestamp.seconds() << std::endl;
}