views:

1219

answers:

3

Hi,

I've got a unified diff file (say my_diff.diff), containing comparison of several files from a project.

What would be the best way to review all the code changes in a nice visual format, for example, using meld or vimdiff?

I have figured out the way how to do it for a single diff file (ie. containing comparison of just two files). It'd be something along the lines:

patch -o /tmp/temp_file -i my_diff.diff ./target_file.ext 
gvimdiff /tmp/temp_file ./target_file.ext

Which essentially applies the patch, but stores the result in a temp file, and then compares that file to the original one.

I have also found filterdiff utility, which can extract portions of unified diff segments relevant to a file. Potentially it can be used with code example above in some sort of hack shell scripting, in which I am not so advanced.

I would envisage the process happening like that though:

  1. Scan unified diff for changed file names
  2. For each file name, extract the diff portion
  3. For each portion, run script quoted in the beginning of the question.

Is there anyone with shell scripting skills? :)

A

+1  A: 

I'm sure I'll get down voted for stoking the holy war, but I'm responding to the general portion of the question, "People doing code reviews must have came across that before".

Ediff for Emacs works great with multiple files. The interface takes some getting used to.

Looks like Meld can't do this, and there are no plans to do so.

ashawley
Unfortunately I have no plans for learning Emacs right now, is there a way to do it in say vim?
Art
As you can tell, I don't know much about Vim. Good luck.
ashawley
+1  A: 

This answer would seem to apply.

Also, check out diff navigator

rampion
Looks like diff navigator just provides commands to skip around inside a patch, not to show the consequences of a patch of multiple files. diff_navigator sounds like Diff mode for Emacs.
ashawley
The answer quoted unfortunatelly does not work with diff file containing comparison of more than one file
Art
A: 

If your looking for a directory wide vim solution, after applying the patch to a temp directory you could review directory wide with the DirDiff plugin.

http://www.vim.org/scripts/script.php?script_id=102

I use this plugin a lot, its great.

To automate the task of patching then opening the diff view just write a macro

michael