# # # patch "ChangeLog" # from [e02c58404ced0a430ed9ad74d4790635e0d5f170] # to [3f22f73028aca4e49730354b34b1e87f37a8df06] # # patch "cmd_diff_log.cc" # from [304f573d7fe7c8036273902966eee48c3698a73c] # to [455b776f7d77d85e691c54cff31a04a6ccb3493a] # # patch "diff_patch.cc" # from [f6e49ea0bc62a2243092315f0fb9541cbf946cf3] # to [8171f0cf479ad64d9edb401c5086dbb1387c8b78] # # patch "diff_patch.hh" # from [fb4f8c2825228e0131db5166e5b656fc96a958c4] # to [ff45bcd64a26e9133d59afabfac35743613feaec] # ============================================================ --- ChangeLog e02c58404ced0a430ed9ad74d4790635e0d5f170 +++ ChangeLog 3f22f73028aca4e49730354b34b1e87f37a8df06 @@ -1,5 +1,11 @@ 2006-07-07 Nathaniel Smith + * diff_patch.cc (make_diff): Add a version that does a bit more + work. + * cmd_diff_log.cc (dump_diffs): Use it to simplify this code. + +2006-07-07 Nathaniel Smith + * cmd_diff_log.cc: Remove tabs. 2006-07-07 Nathaniel Smith ============================================================ --- cmd_diff_log.cc 304f573d7fe7c8036273902966eee48c3698a73c +++ cmd_diff_log.cc 455b776f7d77d85e691c54cff31a04a6ccb3493a @@ -250,23 +250,12 @@ unpacked, app.lua); } - if (guess_binary(unpacked())) - cout << "# " << file_path(i->first) << " is binary\n"; - else - { - split_into_lines(unpacked(), lines); - if (! lines.empty()) - { - cout << (FL("--- %s\t%s\n") % file_path(i->first) % i->second) - << (FL("+++ %s\t%s\n") % file_path(i->first) % i->second) - << (FL("@@ -0,0 +1,%d @@\n") % lines.size()); - for (vector::const_iterator j = lines.begin(); - j != lines.end(); ++j) - { - cout << "+" << *j << "\n"; - } - } - } + make_diff(file_path(i->first).as_internal(), + file_path(i->first).as_internal(), + i->second, + i->second, + data(), unpacked, + cout, type); } map reverse_rename_map; @@ -306,32 +295,19 @@ data_new, app.lua); } - if (guess_binary(data_new()) || - guess_binary(data_old())) - cout << "# " - << file_path(delta_entry_path(i)) - << " is binary\n"; - else - { - split_into_lines(data_old(), old_lines); - split_into_lines(data_new(), new_lines); - - split_path dst_path = delta_entry_path(i); - split_path src_path = dst_path; - - map::const_iterator re; - re = reverse_rename_map.find(dst_path); - - if (re != reverse_rename_map.end()) - src_path = re->second; - - make_diff(file_path(src_path).as_internal(), - file_path(dst_path).as_internal(), - delta_entry_src(i), - delta_entry_dst(i), - old_lines, new_lines, - cout, type); - } + split_path dst_path = delta_entry_path(i); + split_path src_path = dst_path; + map::const_iterator re; + re = reverse_name_map.find(dst_path); + if (re != reverse_name_map.end()) + src_path = re->second; + + make_diff(file_path(src_path).as_internal(), + file_path(dst_path).as_internal(), + delta_entry_src(i), + delta_entry_dst(i), + old_lines, new_lines, + cout, type); } } ============================================================ --- diff_patch.cc f6e49ea0bc62a2243092315f0fb9541cbf946cf3 +++ diff_patch.cc 8171f0cf479ad64d9edb401c5086dbb1387c8b78 @@ -1112,6 +1112,29 @@ string const & filename2, file_id const & id1, file_id const & id2, + data const & data1, + data const & data2, + ostream & ost, + diff_type type) +{ + if (guess_binary(data1()) || guess_binary(data2())) + ost << "# " << filename2 << " is binary\n"; + else + { + vector lines1, lines2; + split_into_lines(data1(), lines1); + split_into_lines(data2(), lines2); + make_diff(filename1, filename2, + id1, id2, + lines1, lines2, + ost, type); + } +} + +void make_diff(string const & filename1, + string const & filename2, + file_id const & id1, + file_id const & id2, vector const & lines1, vector const & lines2, ostream & ost, ============================================================ --- diff_patch.hh fb4f8c2825228e0131db5166e5b656fc96a958c4 +++ diff_patch.hh ff45bcd64a26e9133d59afabfac35743613feaec @@ -32,6 +32,15 @@ std::string const & filename2, file_id const & id1, file_id const & id2, + data const & data1, + data const & data2, + std::ostream & ost, + diff_type type); + +void make_diff(std::string const & filename1, + std::string const & filename2, + file_id const & id1, + file_id const & id2, std::vector const & lines1, std::vector const & lines2, std::ostream & ost,