« XSLT style files updated for Microformats.cfc | Main | Great ColdFusion 8 article; how about a comparison to PHP/RoR? »

Using TortoiseSVN's "diff"(aka TortoiseMerge) to pass updates to new files

Today when I checked a third-party site for updates to the XSLT files I use in Microformats.cfc, I found myself wondering how I'd update the new files so that they contained the minor modifications needed for use in my component. I could have saved the new files in a separate directory, then opened each new file and compared it to my older version, making changes by hand. But I was a little worried that I'd forget to notice a change or two-- these XSLT files aren't exactly easy to read, and I only work with them once every few months. Then I remembered the ever-so-handy "diff" utility from my Subversion client, TortoiseSVN.

Those of you who already use Subversion and TortoiseSVN may already be familiar with diff. If you use it like I do, you use it all the time to help you remember exactly what changes you've made to a file since you were too lazy to commit it as often as you should. But diff has other uses, too: you can use it to resolve conflicts between your code and the current base copy by right-clicking on highlighted blocks of conflicting code and choosing "Use this text block" (from among other choices) to help merge the file. And, you can also use the same functionality to pass your own customizations to new versions of other people's files.

Here's how I used it for the XSLT files: first, I just downloaded the new files in place of my old files. Yep, I overwrote my own customized files. You don't have to worry about losing your changes because Subversion has already recorded them for you. If the new file contains any differences from your old file, you'll see the familiar icon overlay of a red exclamation mark indicating that your file has changed from the working base. Just right-click on the file, and choose "Diff" from the "TortoiseSVN" menu:

svn-diff-menu.gif

When Diff opens (which for me is actually a program called TortoiseMerge), you'll see your two files side by side with each differing line lighlighted. Roll over the highlights, and you'll see the highlighted line of code appear in a frame at the bottom of the window along with its corresponding line from the other file. Differences in the code are also highlighted in this window-- it's a fantastic way to compare the changes between each file.

You can use the green arrows at the top of the program to jump up and down between conflicting lines, which is a real help when reading over a long page of code. But here's the best part-- when you see a line of code from one file that you want to copy to the other, just right-click on it and choose "Use this text block". Do that for each change that you want to copy over to the new file. Click on the small image below for a screenshot of what this looks like:

diff-update.gif

If you don't do it yourself, TortoiseMerge will ask you if you want to save your changes before you close the program. So that's it: a convenient way to read through both an older file and a newer file at the same time, with the difference between them identified for you. Copying needed changes from the old file to the new (or vice versa) couldn't be easier with TortoiseMerge's conflict-resolution features.

Comments (1)

Since TSVN 1.5 came out there are some minor changes. Here is a nice link to quick videos showing how to use basic TSVN features. Hope it helps you as well.

http://pollvu.blip.tv/

hamy

Post a comment