Short Tip: Compare revisions with SVN

If you work with svn you might want to compare differences between two or more revisions – this is especially handy if you come back to work after the weekend and your work partner has already submitted quite some changes. I always forget the right command and especially the correct syntax, so this post is mainly a reminder for myself.

The comparison can be done via:

$ svn diff -r 63:64 .
Index: XSmsCenterActions.cpp                             
--- SomeActions.cpp       (Revision 63)                      
+++ SomeActions.cpp       (Revision 64)                      
@@ -68,7 +68,7 @@                                                  
        connect( my_firstAction, SIGNAL( activated() ) , this, SLOT( dothisSlot() ) );
-       connect( my_secondAction, SIGNAL( activated() ) , this, SLOT( dothatSlot() ) );      

The command is recursive by default, and in this case compares all files in the directory. If you exchange the dot at the end of the comman with a file name, just the changes of the file are compared.


5 thoughts on “Short Tip: Compare revisions with SVN”

  1. But who wants to look at raw diff text output nowadays?

    A graphical diff viewer is the only way to fly. I use kompare, e.g.

    svn di | kompare -o –

  2. In fact, this operation is so common, they added an option for it. 😉

    Instead of having to diff the revisions, you can do:

    svn diff -c 64

    …to show the differences committed in revision 64.

Comments are closed.