# # # add_file "tests/t_log_diffs.at" # content [909f066377054ba79dcc05d906e237eab4b88a4b] # # patch "ChangeLog" # from [8d8eeddf46503818581f3d5f01e53809b7283fbf] # to [e7b2f579754e6321a09e4e693041bcd863d21a9e] # # patch "cmd_diff_log.cc" # from [9621695332cf1c0dbbe3a829f8b5d97f636e27c2] # to [a831b231bb020f181f60425bd0bca65624c140c5] # # patch "testsuite.at" # from [0cfa0b8041e6430815f65965145117420a9b8110] # to [f627e0500cb2d2166fa9c4c2f3ab29520488eb69] # ============================================================ --- tests/t_log_diffs.at 909f066377054ba79dcc05d906e237eab4b88a4b +++ tests/t_log_diffs.at 909f066377054ba79dcc05d906e237eab4b88a4b @@ -0,0 +1,70 @@ +AT_SETUP([log --diffs]) +MTN_SETUP + +ADD_FILE(foo, [foo +]) +ADD_FILE(bar, [bar +]) + +COMMIT(testbranch) +REV1=`BASE_REVISION` + +AT_DATA(foo, [foo changed +]) + +COMMIT(testbranch) +REV2=`BASE_REVISION` + +ADD_FILE(quux, [quux +]) + +COMMIT(testbranch) +REV3=`BASE_REVISION` + +AT_DATA(foo, [foo again +]) +AT_DATA(bar, [bar again +]) + +AT_CHECK(MTN rename -e foo foo2, [], [ignore], [ignore]) + +COMMIT(testbranch) +REV4=`BASE_REVISION` + +# without restrictions +AT_CHECK(MTN log --diffs, [], [stdout], [ignore]) +AT_CHECK(mv stdout logfull) +AT_CHECK(egrep '^(---|\+\+\+) ' logfull, [], [stdout], [ignore]) +AT_CHECK(mv stdout full) +AT_DATA(expect_full, [--- bar e242ed3bffccdf271b7fbaf34ed72d089537b42f ++++ bar 17ecc84b62b35bcf309c0b246cba8641426ad35d +--- foo 5527e63e7193ef5fadbc8fd40cc8092d742602e7 ++++ foo2 6d0789008812dd091f3e0c97d6606bf427cf82e4 +--- quux f3d9ae4aeea6946a8668445395ba10b7399523a0 ++++ quux f3d9ae4aeea6946a8668445395ba10b7399523a0 +--- foo f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 ++++ foo 5527e63e7193ef5fadbc8fd40cc8092d742602e7 +--- bar e242ed3bffccdf271b7fbaf34ed72d089537b42f ++++ bar e242ed3bffccdf271b7fbaf34ed72d089537b42f +--- foo f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 ++++ foo f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 +]) +AT_CHECK(cmp expect_full full, [], [ignore]) + +# restrict to foo2 and quux +AT_CHECK(MTN log quux --diffs foo2, [], [stdout], [ignore]) +AT_CHECK(mv stdout logrestrict) +AT_CHECK(egrep '^(---|\+\+\+) | sed 's/\t//' ' logrestrict, [], [stdout], [ignore]) +AT_CHECK(mv stdout restrict) +AT_DATA(expect_restrict, [--- foo 5527e63e7193ef5fadbc8fd40cc8092d742602e7 ++++ foo2 6d0789008812dd091f3e0c97d6606bf427cf82e4 +--- quux f3d9ae4aeea6946a8668445395ba10b7399523a0 ++++ quux f3d9ae4aeea6946a8668445395ba10b7399523a0 +--- foo f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 ++++ foo 5527e63e7193ef5fadbc8fd40cc8092d742602e7 +--- foo f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 ++++ foo f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 +]) +AT_CHECK(cmp expect_restrict restrict, [], [ignore]) + +AT_CLEANUP ============================================================ --- ChangeLog 8d8eeddf46503818581f3d5f01e53809b7283fbf +++ ChangeLog e7b2f579754e6321a09e4e693041bcd863d21a9e @@ -1,3 +1,9 @@ +2006-05-15 Matt Johnston + + * cmd_diff_log (log, dump_diffs): limit diffs to restricted files, + updated for new restrictions code. + * tests/t_log_diffs.at: A test for log --diffs + 2006-05-14 Lapo Luchini * po/it.po: Translated a few more strings to Italian (115 to go). ============================================================ --- cmd_diff_log.cc 9621695332cf1c0dbbe3a829f8b5d97f636e27c2 +++ cmd_diff_log.cc a831b231bb020f181f60425bd0bca65624c140c5 @@ -196,7 +196,9 @@ dump_diffs(cset const & cs, app_state & app, bool new_is_archived, - diff_type type) + diff_type type, + set const & paths, + bool limit_paths = false) { // 60 is somewhat arbitrary, but less than 80 std::string patch_sep = std::string(60, '='); @@ -205,6 +207,9 @@ i = cs.files_added.begin(); i != cs.files_added.end(); ++i) { + if (limit_paths && paths.find(i->first) == paths.end()) + continue; + cout << patch_sep << "\n"; data unpacked; vector lines; @@ -253,6 +258,9 @@ i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) { + if (limit_paths && paths.find(i->first) == paths.end()) + continue; + file_data f_old; data data_old, data_new; vector old_lines, new_lines; @@ -301,6 +309,16 @@ } } +static void +dump_diffs(cset const & cs, + app_state & app, + bool new_is_archived, + diff_type type) +{ + set dummy; + dump_diffs(cs, app, new_is_archived, type, dummy); +} + CMD(diff, N_("informative"), N_("[PATH]..."), N_("show current diffs on stdout.\n" "If one revision is given, the diff between the workspace and\n" @@ -575,6 +593,7 @@ bool print_this = mask.empty(); set< revision > parents; vector< revision > tmp; + set diff_paths; if (null_id(rid) || seen.find(rid) != seen.end()) continue; @@ -590,7 +609,6 @@ app.db.get_roster(rid, roster); set nodes_modified; - bool any_node_hit = false; select_nodes_modified_by_rev(rid, rev, roster, nodes_modified, app); @@ -598,16 +616,22 @@ for (set::const_iterator n = nodes_modified.begin(); n != nodes_modified.end(); ++n) { - // the current roster won't have deleted nodes - if (!roster.has_node(*n) || mask.includes(roster, *n)) + if (!roster.has_node(*n)) { - any_node_hit = true; - break; + // include all deleted nodes + print_this = true; } + else if (mask.includes(roster, *n)) + { + print_this = true; + if (app.diffs) + { + split_path sp; + roster.get_name(*n, sp); + diff_paths.insert(sp); + } + } } - - if (any_node_hit) - print_this = true; } if (next > 0) @@ -680,7 +704,8 @@ for (edge_map::const_iterator e = rev.edges.begin(); e != rev.edges.end(); ++e) { - dump_diffs(edge_changes(e), app, true, unified_diff); + dump_diffs(edge_changes(e), app, true, unified_diff, + diff_paths, !mask.empty()); } } ============================================================ --- testsuite.at 0cfa0b8041e6430815f65965145117420a9b8110 +++ testsuite.at f627e0500cb2d2166fa9c4c2f3ab29520488eb69 @@ -887,3 +887,4 @@ m4_include(tests/t_escaped_selectors.at) m4_include(tests/t_automate_get_base_revision_id.at) m4_include(tests/t_automate_get_current_revision_id.at) +m4_include(tests/t_log_diffs.at)