Outputting a list of changed or new filenames between two branches or revisions
In developing our projects we wondered how we could easily get an output of just the files that are new or have changed or been deleted between two different subversion branches or versions. This makes it easy to generate upgrade patches with the right file structure and be sure nothing has been missed. It doesn't handle deleted files but manages the new or changed side of things. Deleteion is a minor issue for us which we deal with manually.
Solution
svn diff --old=OLD-URL[@OLDREV] --new=NEW-URL[@NEWREV] | diffstat
or if you want it between 2 revisions
svn diff -rOLDREV:NEWREV | diffstat
Using Sed to strip out unwanted Guff
We tend to pipe the output through sed into a file but the screen output is useful if you only have a few changes. We also use sed to strip out trailing info in diffstat so we are left just with a list of directories without whitespace.
svn diff --old=OLD-URL[@OLDREV] --new=NEW-URL[@NEWREV] | diffstat | sed 's/[ \t]*|.*$//' > output.txt
Using A Shell Script to Read in Changed Files from the previous script and Export From The New Subversion Repository Creating the Appropriate Directory Structure ON the Fly
This is a quick and dirty approach but does what it needs to.
You can specify the output directory and the script will create it. The script will create a couple of erroneous directories at the top directory level but it is easy to just delete these. If anyone wants to make this a bit slicker then do feel free to email us technical@clearintent.co.uk we'll credit and link any updates.
#!/bin/bash
REPO="file:///var/svn/repos/yourrepo/"
OLD="tags/v1.53/"
NEW="trunk/"
OUTPUTDIR="/home/user/svnexport/updates/1.53-1.xx/"
while read LINE
do
DIRTEST=${LINE%/*}
mkdir -p $OUTPUTDIR$DIRTEST"/"
svn export $REPO$NEW$LINE $OUTPUTDIR$LINE
done < output.txt
Alternative Solution
courtesy of http://idn.interspire.com/blogs/6/Exporting-only-the-files-changed-between-2-revisions-in-Subversion.html
We've only tested the command in bash but it should work in zsh too. Not sure about any other shells. Also make sure that you have the trailing / in the sed part of the command otherwise it won't work properly.
for i in $(svn diff --summarize -r 1403:1438 http://server/svn/project/trunk | awk '{ print $2 }'); do p=$(echo $i | sed -e 's{http://server/svn/project/trunk/{{'); mkdir -p $(dirname $p); svn export $i $p; done
If you just wanted to get a list of the changed files you could run the command
svn diff --summarize -r 1403:1438 http://server/svn/project/trunk | awk '{ print $2 }' | sed -e 's{http://server/svn/project/trunk/{{'