#!/bin/sh
svnadmin create ~/mergetest-repo
svn co file://$HOME/mergetest-repo mergetest
cd mergetest/
mkdir -p trunk branches/testing
svn add *
svn ci -m "directories created"
# r1 created
cp ~/files.txt trunk/files.txt
svn add trunk/files.txt
svn ci -m "added files.txt"
# r2 created
svn update
patch trunk/files.txt ~/files1.patch
svn ci -m "files.txt changed"
# r3 created
svn update
patch trunk/files.txt ~/files2.patch
svn ci -m "files.txt corrected"
# r4 created
svn update
svn copy trunk/files.txt@2 branches/testing/
svn ci -m "copied files.txt to testing branch"
svn update
# this should _not_ work, as r4 contains a deletion
# which cannot be applied to files.txt@2!
# the "patch" utility correctly reports that the hunk could not be applied
#svn diff -c4 trunk/files.txt | patch -p0 branches/testing/files.txt || exit 1
svn merge -c4 trunk branches/testing # <-- merge succeeds!!! why?
svn ci -m "r4 integrated from trunk"
# r5 created
svn update
svn merge -c3 trunk branches/testing
svn ci -m "r3 integrated from trunk"
# r6 created
svn update
# files are different!
cmp -s trunk/files.txt branches/testing/files.txt && echo "OK" || echo "FAILURE"
cd ..

