cfdiff

I have some custom tag sets that have recently started to fork into different versions - not good for easy of use or maintenance. I wanted to coalesce them into one master version (in hopes of releasing a beta soon). Unfortunately, unifying three versions of several files (some of them quite large) represented a bit of a task.

I started this task in my usual way, but opening up two versions of each file and going through them screen by screen. It didn't take me very long to think that my time was too valuable for such a boring task. It seemed like the sort of thing that could be automated. Then I remembered a blog entry by Rick Osborne about cfdiff - a tool to do just what I was doing.

I'll start with the bad news.

Not yet being an SVN person (soon! honest!), I found the Google Code page for cfdiff difficult to use. I really just wanted to download a zip like I can on RIA Forge (where I would love to see this project move).

I wasn't able to find any documentation for the project. I saw a screen shot of a really nice report on Rick's page, but I couldn't figure out how to produce it with his code. Without documentation, I was hoping to find an example implementation of the code (I find that often all I need). Of course, this means that I really need to look at some of my projects, like DataMgr, and add a file in the download with a bit of explanation. In my defense, I have the CFC docs and some presentations available.

Now on to the good news.

Although I am not yet an SVN person, I was able to put in the SVN url in my browser and download the files individually. It wasn't my preferred approach, but nor was it a major inconvenience.

A short look through the code, turned up the DiffFiles method. This method was easy enough to understand. You just pass in the full path for each of two files that you want to compare as well as the carraige return character (though it does have a default for this). It returns a query that you can dump on your page.

This wasn't as attractive a result as I was hoping for, but no less useful for that. It provides the line number for each file where a difference can be found. It has to provide two line numbers because it does a good job of identifying two lines as being the same even if they are in different line numbers in different files (due to differences earlier in the file). This made going through the files fast and easy.

It seems to always report the line after the last line as a difference. This isn't really a problem because it is easy to get used to. In fact, it is somewhat nice because if you get an empty query, you can bet it wasn't able to find one of the files.

All in all, cfdiff saved me a lot of time and found differences that I may have missed had I tried to compare the files by hand. 

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
FYI - You could install Tortoise to grab SVN files (assuming you are running Windows).

There is also WinMerge - a nice, free diff tool. (http://winmerge.org/)

I use BeyondCompare - it's a great diff tool, and reasonably priced, with a lot of powerful features (http://www.scootersoftware.com/)
# Posted By Jim | 12/14/06 5:46 PM
Ouch. Yeah, cfdiff could definitely use some documentation. I have no lame excuses, I just haven't gotten around to it yet.

That said, the easiest way to get started is to look at svn.cfm - the stock SVN browser. You may not need the SVN-browsing capabilities, but it'll show you how to use the cfdiff CFC. In your specific case, after your call to DiffFiles, pass the resulting query back into the CFC's Parallelize() or UnifiedDiffArrays() function. Either one will give you back something much more useful than the raw difference query.

cfset f=Differ.Parallelize(Differ.DiffArrays(LeftFile, RightFile), LeftFile, RightFile)

-R
# Posted By Rick O | 12/14/06 9:54 PM
Rick,

Thanks for the tip. I will check that out.

I certainly didn't mean to imply that I didn't like the results. Even with my limited knowledge of the product, I was still able to pretty quickly get it to give me useful information.

It really did save me a lot of time. I really appreciate the effort that you put into it.
# Posted By | 12/15/06 1:54 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.