Tag Archives: Subversion

Use WinMerge for comparing archives with TortoiseSVN

I really like the Diff Viewer that comes with TortoiseSVN, but from what I can gather it doesn’t seem to support anything but text files, which is fair enough, but I need to compare archives as well. Zip and Jar files in particular.

WinMerge supports that, and can be integrated with TortoiseSVN very easily right through its installer. But I prefer the diff viewer that comes with TortoiseSVN and the archive diff isn’t recursive by default, so I decided to set it up manually.

  1. Install WinMerge
    • Deselect Automagic TortoiseSVN integration

  2. Install the WinMerge 7-zip plugin
    • Select Application specific installation
    • Browse to WinMerge executable
    • Enable Enable standalone operation

  3. Open WinMerge and go to Edit, Options, Archive Support
    • Enable Detect archive type from file signature
    • Switch to Use local 7-Zip from WinMerge folder

  4. Open TortoiseSVN Settings and go to Diff Viewer, Advanced
    • Add rows with extension set to .zip, .jar and whatever archives you want WinMerge to handle and set external program to the following:
      C:\Program Files (x86)\WinMerge\WinMergeU.exe /r /x /e /u /dl %bname /dr %yname %base %mine

If I now for example ask TortoiseSVN for a Diff with previous version of a jar file, I get WinMerge with a recursive comparison of the archive contents.

Note: When you’re diffing archives in WinMerge, deselecting Show Identical Items under View makes actual differences much easier to see.

PowerShell: Run command for each directory

I wanted to run the svn update command for each directory in my Eclipse workspace. Could be done like this:

PS C:\workspace> Get-ChildItem |
where {$_.PsIsContainer} |
foreach {svn update $_.name}

This gets all child items (files and directories) in the workspace folder, filters out only directories and finally runs the wanted command for each one.

But what if not all directories were subversion working copies?

Filter based on directory contents

A subversion working copy is a directory with a hidden .svn folder inside.

PS C:\workspace> Get-ChildItem -force */* |
where {$_.name -eq ".svn"} |
foreach {svn update $_.parent}

This lists all children one level down (-force is to include hidden stuff), filters out only those named .svn and then runs the update on its parent folder.

If we needed to look for a file instead (which doesn’t have a parent property) we could do something like this:

PS C:\workspace> Get-ChildItem */* |
where {$_.name -eq "pom.xml"} |
foreach { cd $_.DirectoryName; mvn clean compile; cd ..}

Here we do basically the same thing except that we use the DirectoryName property instead of parent. We also actually go into each directory to run the command there rather than just passing the path to a command like in the svn example.

Gotta say, PowerShell is kind of neat 🙂