Quick SVN merging
With SVN, I seem to spend a lot of time merging trunk changes into feature branches. I wrote a handy dandy script to merge the latest changes from a specified branch into a working copy.
#!/bin/bash
SERVER=`svn info | grep '^Repository Root:' | awk '{print $3}'`
BRANCH=`echo "$1" | sed -r 's/^\\///'`
WC=$2
REV=`svn pg svn:mergeinfo $WC | grep "^/$BRANCH:" |
sed -r 's/[:,\\-]/ /g' | awk '{print $NF}'`
echo "Merging from $SERVER/$BRANCH $REV:HEAD..."
svn merge -r $REV:HEAD $SERVER/$BRANCH $WC
Usage is as follows:
$ ./merge.sh /trunk /path/to/working/copy
Merging from svn://svnserver/trunk 19:HEAD...
--- Merging r19 through r22 into '/path/to/working/copy':
U /path/to/working/copy/one.php
U /path/to/working/copy/two.php
D /path/to/working/copy/three.php
The server is picked up from svn info
, and the starting revision is taken from the svn:mergeinfo
property of the working copy. It makes it a lot easier to
Note: If you're not using svn:mergeinfo
then this won't work for you. Sorry about that!