Emmanuel Bassi just showed me how to get a diff between subversion (svn) branches. It’s not obvious. It should be easier. But here it is:
- Discover the revision numbers: You need to know the revision numbers of the latest versions in each of the branches. It looks like svn log is the only way to do that. If your svn has the –limit option then you can see the revision number by cding into the branch’s directory, and typing svn log –limit 1. Otherwise, just look at the start of the svn log output manually. That will give you two numbers, such as 123 and 145.
- cd into one of the branch directories, such as trunk.
- Supply the revision numbers to the svn diff command: svn diff -r123:145
I’m much rather do something like “svn diff ../branches/thing-1-0”. Surely that should be possible?
Also, here’s how to get a diff with the -p option, so that patches have function names to make them more readable.
10 thoughts on “subversion: diff between branches”
svn diff [path] [path] works fine for me, for example svn diff http://foo.com/branches/stable http://foo.com/trunk.
I was about to say the same as Ross, but too late.
and for the version of a branch, use ‘svn info’ and look for ‘Last changed rev’
http://www.xenomai.org/index.php/Teaching_-p_to_svn_diff is more elegant than the solution proposed on glade-list, since it doesn’t require you to alias commands.
Not only does the path method from Ross work, your solution unfortunately doesn’t (How should it? It simply displays all changes in the branch you call it from between two revision numbers. Revision numbers in SVN are global over the whole repository)
Jens, as I understood it, the revision numbers are unique to a branch, so the same revision number can’t be used for two branches. It seems to work.
I’m afraid Jens is correct. The revisions are unique to a branch, but it depends on what path you are doing the diff on.
Example, if you commit changes to the branch, they will have commit revisions. Then if you do a diff on trunk using a range that includes the aforementioned revisions, notice you will not see the changes. That’s because those revisions only apply to the branch, not trunk.
The best way to see differences between branches is using the method from Ross Burton’s example.
check out this simple tool: http://code.google.com/p/coderev/
It generates some html.
The svn diff [path] [path] worked for me, but unfortunately I couldn’t get it to work with relative paths. Any ideas?
I’ve made a script which does something similar:
It allows you to see all changes on your branch since it was forked from trunk. This could be useful if trunk has changes you don’t yet want to merge into your branch, so diffing against trunk is not a good option if you want to review your changes.
meld is helpful with that, if you just want to find out which files are different