# # patch "commands.cc" # from [7c48b11d14dd9d09d9b1ce7438db03b1cf558ea7] # to [816e71e2f403fa13b05ce176b8a8bc0be6698fef] # # patch "tests/t_rename_diff_names.at" # from [a21a0b7910b5acb036380dd2fab966f0aed1dc0b] # to [6bf74dfd0239f9cd781fae7a7871f490f9bc82f3] # ======================================================================== --- commands.cc 7c48b11d14dd9d09d9b1ce7438db03b1cf558ea7 +++ commands.cc 816e71e2f403fa13b05ce176b8a8bc0be6698fef @@ -2567,6 +2567,15 @@ } } + std::map reverse_rename_map; + + for (std::map::const_iterator + i = cs.nodes_renamed.begin(); + i != cs.nodes_renamed.end(); ++i) + { + reverse_rename_map.insert(std::make_pair(i->second, i->first)); + } + for (std::map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) @@ -2597,8 +2606,18 @@ { split_into_lines(data_old(), old_lines); split_into_lines(data_new(), new_lines); - make_diff(file_path(delta_entry_path(i)).as_internal(), - file_path(delta_entry_path(i)).as_internal(), + + split_path dst_path = delta_entry_path(i); + split_path src_path = dst_path; + + std::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, ======================================================================== --- tests/t_rename_diff_names.at a21a0b7910b5acb036380dd2fab966f0aed1dc0b +++ tests/t_rename_diff_names.at 6bf74dfd0239f9cd781fae7a7871f490f9bc82f3 @@ -1,21 +1,11 @@ AT_SETUP([filenames in diff after rename]) MONOTONE_SETUP -# This test is a bug report. - # If a file is renamed from "testfile" to "otherfile" and has changes, # then 'monotone diff' should display: # --- testfile # +++ otherfile -# But what it does display is -# --- otherfile -# +++ otherfile -# This is because the diffs are built based on changeset deltas, and -# changeset deltas are applied after renames have already taken -# effect. -AT_XFAIL_IF(true) - ADD_FILE(testfile, [blah blah ]) COMMIT(testbranch) @@ -29,6 +19,6 @@ AT_CHECK(MONOTONE diff, [], [stdout], [ignore]) AT_CHECK(QGREP(-- "--- testfile" stdout)) -AT_CHECK(QGREP(-- "+++ otherfile" stdout), [1]) +AT_CHECK(QGREP(-- "+++ otherfile" stdout)) AT_CLEANUP