views:

264

answers:

4

A co worker of mine asked me to review some of my code and he sent me a diff file. I'm not new to diffs or version control in general but the diff file was very difficult to read because of the changes he made. Specifically, he used the "extract method" feature and reordered some methods. Conceptually, very easy to understand but looking at the diff, it was very hard to tell what he had done. It was much easier for me to checkout the previous revision and use Eclipse's "compare" feature, but it was still quite clunky.

Is there any version control system that stores metadata related to refactoring. Of course, it would be IDE and Programming Language specific, but we all use Eclipse and Java! Perhaps there might be some standard on which IDEs and version control implementations can play nicely?

+3  A: 

Eclipse can export refactoring history (see 3.2 release notes as well). You could then view the refactoring changes via preview in Eclipse.

flicken
I like this idea, as long as they are versioned for others to see and there is some reference in the comments!
oreoshake
+2  A: 

I don't know of compare tools that do a good job when the file has been rearranged. In general, this is a bad idea because of this type of problem. All too often people do it to simply meet their own style, which is a bad, bad reason to change code. It can effectively destroy the history, just like reformatting the entire file, and should never be done unless necessary (i.e. it is already a mess and unreadable).

The other problem is that working code will likely get broken because of someones style preferences. If it ain't broken, don't fix it!

Robin
A: 

I asked a similar question a while ago and never did get a satisfactory answer. I'll be watching your question to see what people come up with.

For your particular situation, it might be best to review the latest version of the file, using the diff as a guide. That's what I have been doing in my situation too.

Greg Hewgill
A: 

The Refactoring History feature is new to me, but I like the way it sounds. For a less tool-specific method, I like sending patch files. The person reviewing just applies the patch and reviews the results, and then they can revert to the version in version control when they're done.

Hank Gay