#!/bin/sh

# $Id: svn-example.sh 3406 2007-03-19 20:38:52Z erich $

# This shows a surprising difference between svn 1.4.3 on Linux, and
# on Windows.  Run this once on Linux, and you'll see _two_ lines of
# output from "svn st".  Run it again on Windows, and you'll only see
# one.

# Alas, you need Cygwin installed in order for the shell script to
# run.  But don't install the Cygwin svn, since I don't know if that
# behaves the same as the Win32 version.

PATH=$PATH:/usr/local/src/svn-live/subversion/svn

case "$OSTYPE" in
    cygwin*)
        case "$(type -p svn)" in
            */program\ files/subversion/bin/svn)
            TMP="$(cygpath -m /tmp)"
            ;;
        esac
        ;;
    *)
        TMP=/tmp
        ;;
esac

r="$TMP/repos"
w1="$TMP/wc1"
w2="$TMP/wc2"

u=file://localhost$TMP/repos

rm -rf $r "$w1" "$w2"
svnadmin create $r

svn co $u $w1
svn co $u $w2

h=hum-de-dum
f1=$w1/$h
f2=$w2/$h
echo One line     >> $f1
echo Another line >> $f1

svn add $f1

svn ci -m "" $w1

svn up $w1
svn up $w2

(echo A new line added at the beginning ; cat $f1 ) > /tmp/xyzzy
cp /tmp/xyzzy $f1
echo A line appended to, you know, the end >> $f2

svn ci -m "" $w1
echo exit 2 > /tmp/exit-two
chmod +x /tmp/exit-two
svn up --diff3-cmd /tmp/exit-two $w2
echo Note that the wc is broken, or at least, there is a scary-looking exclamation point
svn st $w2
echo 'trying "svn cleanup"'
svn cleanup $w2
echo still looks scary
svn st $w2

# svn ci -m "" $w2
# svn up $w1
# echo These two files should be the same
# echo $f1
# cat -n $f1
# echo $f2
# cat -n $f2

