#!/bin/bash

SVN=~/develop/trunk/subversion/svn/svn
SVNADMIN=~/develop/trunk/subversion/svnadmin/svnadmin
BASE_PATH=`pwd`

#clean up any old mess
rm -rf $BASE_PATH/wc
rm -rf $BASE_PATH/repo
cd $BASE_PATH

#new repo
$SVNADMIN create repo
$SVN co file://$BASE_PATH/repo wc
cd wc

#basic project structure
mkdir trunk
echo "inital content" > trunk/foo
$SVN add trunk
$SVN ci -m "main line"

#branch it
$SVN cp trunk branch
$SVN ci -m "branch point"

#three trivial modifications
echo "version 1
1
2
3" > trunk/foo
$SVN ci -m "mod 1"
echo "version 2
1
2
3" > trunk/foo
$SVN ci -m "mod 2"
echo "add line 4" >> trunk/foo
$SVN ci -m "mod 3"
echo "add line 5" >> trunk/foo
$SVN ci -m "mod 4"

#merges at project root
$SVN up .
$SVN merge -c 3 ^/trunk branch
$SVN ci -m "merge mod 1"
$SVN up .
$SVN merge -c 5 ^/trunk branch
$SVN ci -m "merge mod 3"

#problematic subtree merge (usually different user/wc)
$SVN up -r7 .
$SVN merge -c 4 ^/trunk/foo branch/foo
$SVN up .
$SVN ci -m "merge mod 2"

#show inconsistency; m/i for /branch/foo is wrong
echo "eligible for merging from /trunk to /branch"
$SVN mergeinfo --show-revs eligible ^/trunk branch
echo "eligible for merging from /trunk/foo to /branch/foo"
$SVN mergeinfo --show-revs eligible ^/trunk/foo branch/foo

#demonstrate that it actually hurts
#This erroneously tries to merge r5 a second time and creates a conflict.
$SVN up .
# would work: $SVN merge ^/trunk branch
$SVN merge ^/trunk/foo branch/foo

