[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-commits-diffs] net.venge.monotone.colored-diff: f100809f1f2535
From: |
code |
Subject: |
[Monotone-commits-diffs] net.venge.monotone.colored-diff: f100809f1f25357024bf1774ea8c871b80db94f5 |
Date: |
Wed, 17 Aug 2011 11:42:48 +0200 (CEST) |
revision: f100809f1f25357024bf1774ea8c871b80db94f5
suspend: net.venge.monotone.colored-diff
date: 2011-04-15T10:00:19
author: Richard Hopkins <address@hidden>
branch: net.venge.monotone.colored-diff
changelog:
All diff output should now be through colorizer::output ready for Win32
New function to_string<T> should probably be made available to the rest of
the program if it's to be kept.
manifest:
format_version "1"
new_manifest [4aca2c089f5f661b924e0c22b93b9324e0150b1e]
old_revision [8320c869d8acba68acd2bbfda575dfd98bf09500]
patch "src/cmd_diff_log.cc"
from [66d959146c432421ca24988535a9b250aa860a36]
to [b7cf1c6422af0d843216f5cd3792b1d0adb7e840]
patch "src/diff_output.cc"
from [db19431f96f35ca8c6b89c129c2a805ddd418f15]
to [83415d7a0b092725a4315f4124cfe381928e39b0]
============================================================
--- src/diff_output.cc db19431f96f35ca8c6b89c129c2a805ddd418f15
+++ src/diff_output.cc 83415d7a0b092725a4315f4124cfe381928e39b0
@@ -34,6 +34,16 @@ using boost::scoped_ptr;
// someone wants to *read* a diff rather than apply it. The actual diff
// computation is done in lcs.cc.
+template<typename T>
+string to_string(T t) {
+
+ stringstream ss;
+
+ ss << t;
+
+ return ss.str();
+}
+
struct hunk_consumer
{
vector<string> const & a;
@@ -243,9 +253,11 @@ void unidiff_hunk_writer::flush_hunk(siz
find_encloser(a_begin + first_mod, encloser);
ss << " @@";
- ost << color.colorize(ss.str(), colorizer::separator);
- ost << color.colorize(encloser, colorizer::encloser);
- ost << '\n';
+ colorizer::output(ost, color.colorize(ss.str(),
+ colorizer::separator));
+ colorizer::output(ost, color.colorize(encloser,
+ colorizer::encloser));
+ colorizer::output(ost, "\n");
}
copy(hunk.begin(), hunk.end(), ostream_iterator<string>(ost, "\n"));
}
@@ -375,15 +387,20 @@ void cxtdiff_hunk_writer::flush_hunk(siz
find_encloser(a_begin + min(first_insert, first_delete),
encloser);
- ost << color.colorize("***************", colorizer::separator)
- << color.colorize(encloser, colorizer::encloser) << '\n';
+ colorizer::output(ost, color.colorize("***************",
+ colorizer::separator) +
+ color.colorize(encloser, colorizer::encloser) +
+ "\n");
}
- ost << "*** " << (a_begin + 1) << ',' << (a_begin + a_len) << " ****\n";
+ colorizer::output(ost, "*** " + to_string<size_t>(a_begin + 1) + "," +
+ to_string<size_t>(a_begin + a_len)
+ + " ****\n");
if (have_deletions)
copy(from_file.begin(), from_file.end(), ostream_iterator<string>(ost, "\n"));
- ost << "--- " << (b_begin + 1) << ',' << (b_begin + b_len) << " ----\n";
+ colorizer::output(ost, "--- " + to_string<size_t>(b_begin + 1) + ","
+ + to_string<size_t>(b_begin + b_len) + "----\n");
if (have_insertions)
copy(to_file.begin(), to_file.end(), ostream_iterator<string>(ost, "\n"));
}
@@ -505,11 +522,11 @@ make_diff(string const & filename1,
// If a file has been removed, filename2 will be "/dev/null".
// It doesn't make sense to output that.
if (filename2 == "/dev/null")
- ost << color.colorize(string("# ") + filename1 + " is binary",
- colorizer::comment) << "\n";
+ colorizer::output(ost, color.colorize(string("# ") + filename1 + " is binary",
+ colorizer::comment) + "\n");
else
- ost << color.colorize(string("# ") + filename2 + " is binary",
- colorizer::comment) << "\n";
+ colorizer::output(ost, color.colorize(string("# ") + filename2 + " is binary",
+ colorizer::comment) + "\n");
return;
}
@@ -598,12 +615,12 @@ make_diff(string const & filename1,
{
case unified_diff:
{
- ost << color.colorize(string("--- ") + filename1,
- colorizer::remove)
- << '\t' << id1 << '\n';
- ost << color.colorize(string("+++ ") + filename2,
- colorizer::add)
- << '\t' << id2 << '\n';
+ colorizer::output(ost, color.colorize(string("--- ") + filename1,
+ colorizer::remove) + "\t" +
+ to_string<file_id>(id1) + "\n");
+ colorizer::output(ost, color.colorize(string("+++ ") + filename2,
+ colorizer::add) + "\t" +
+ to_string<file_id>(id2) + "\n");
unidiff_hunk_writer hunks(lines1, lines2, 3, ost, pattern, color);
walk_hunk_consumer(lcs, left_interned, right_interned, hunks);
@@ -611,12 +628,12 @@ make_diff(string const & filename1,
}
case context_diff:
{
- ost << color.colorize(string("*** ") + filename1,
- colorizer::remove)
- << '\t' << id1 << '\n';
- ost << color.colorize(string("--- ") + filename2,
- colorizer::add)
- << '\t' << id2 << '\n';
+ colorizer::output(ost, color.colorize(string("*** ") + filename1,
+ colorizer::remove) + "\t" +
+ to_string<file_id>(id1) + "\n");
+ colorizer::output(ost, color.colorize(string("--- ") + filename2,
+ colorizer::add) + "\t" +
+ to_string<file_id>(id2) + "\n");
cxtdiff_hunk_writer hunks(lines1, lines2, 3, ost, pattern, color);
walk_hunk_consumer(lcs, left_interned, right_interned, hunks);
============================================================
--- src/cmd_diff_log.cc 66d959146c432421ca24988535a9b250aa860a36
+++ src/cmd_diff_log.cc b7cf1c6422af0d843216f5cd3792b1d0adb7e840
@@ -99,7 +99,7 @@ dump_diff(lua_hooks & lua,
{
// 60 is somewhat arbitrary, but less than 80
string patch_sep = string(60, '=');
- output << patch_sep << '\n';
+ colorizer::output(output, patch_sep + '\n');
// see the big comment in diff_output.cc about what paths should be
string left = left_path.as_internal();
@@ -399,23 +399,26 @@ void dump_header(std::string const & rev
vector<string> lines;
split_into_lines(summary(), lines);
- out << colorizer.colorize("#", colorizer::comment) << "\n";
+ colorizer::output(out, colorizer.colorize("#", colorizer::comment) +
+ "\n");
if (!summary().empty())
{
- out << colorizer.colorize(revs, colorizer::comment);
- out << colorizer.colorize("#", colorizer::comment) << "\n";
+ colorizer::output(out, colorizer.colorize(revs, colorizer::comment));
+ colorizer::output(out, colorizer.colorize("#", colorizer::comment) +
+ "\n");
for (vector<string>::iterator i = lines.begin();
i != lines.end(); ++i)
- out << colorizer.colorize(string("# ") + *i,
- colorizer::comment) << "\n";
+ colorizer::output(out, colorizer.colorize(string("# ") + *i,
+ colorizer::comment) + "\n");
}
else
{
- out << colorizer.colorize(string("# ") + _("no changes"),
- colorizer::comment) << "\n";
+ colorizer::output(out, colorizer.colorize(string("# ") + _("no changes"),
+ colorizer::comment) + "\n");
}
- out << colorizer.colorize("#", colorizer::comment) << "\n";
+ colorizer::output(out, colorizer.colorize("#", colorizer::comment) +
+ "\n");
}
CMD_PRESET_OPTIONS(diff)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-commits-diffs] net.venge.monotone.colored-diff: f100809f1f25357024bf1774ea8c871b80db94f5,
code <=