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 🙂

Project Euler: Just two tiny notes

Just two things I felt like mentioning:

Thing number one

I got tired of the page 2 stuff. So, I swapped all the <!–nextpage–> things with <!–more–> and a header. Which means that the solution will now be on the same page as the problem. (Although not on the index page).

Thing number two

My brother puts his whole solution on a public subversion repository, which is a very good idea. Following his good example, I did a repository dump of my local VisualSVN Server and… undumped(??) it into one I set up here on my web host which I will be using from now on instead.

Update: SubVersion turned out to be a bit blah sometimes, so I am trying out Mercurial now instead. The repository has been converted and published on BitBucket. Mercurial seems a lot nicer than SubVersion so far. You can find a very good introduction at hginit.com.

Thing number three

Works On My MachineOk, ok, the topic says two, but I just figured I should maybe mention one more thing. You see, the code you will find in my aforementioned subversion repository cannot be run. Like, there is no main method or anything there. That is because I am trying to teach myself how to use test cases, etc. So, instead of creating an executable program for each problem or one program with fancy “Solve problem #n”-buttons, I decided to just do it all in test cases. So, my solutions are actually found as part of the test project (well, the running of them anyways). I am using TestDriven.net to run them, and it works great. This way I can also do a lot of changes, and then just run my tests and make sure that all my solutions still calculate correctly. Awesome stuff.