Short Tip: Compare revisions with SVN

shell.png
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 @@                                                  
        boolValue=true;                                          
                                                                   
        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.

About these ads

5 Responses to “Short Tip: Compare revisions with SVN”

  1. Stefan Says:

    The trailing dot in “svn diff -r 63:64 .” may also be omitted, as the target defaults to the working directory.

  2. Mark B Says:

    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 -

  3. Benjamin Reed Says:

    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.

  4. liquidat Says:

    Mark, nice one, didn’t knew that :)

    Benjamin, thx for the shortcut!

  5. tjansson Says:

    SVN actually has built-in support for other diff viewers. I my case I use kdiff3:

    svn diff –diff-cmd kdiff3 -r 42:HEAD foo.bar


Comments are closed.

Follow

Get every new post delivered to your Inbox.

Join 96 other followers

%d bloggers like this: