#!/bin/sh -ex

basedir=`dirname $0`/../tmp
basedir=`cd $basedir && pwd`

cvsroot=$basedir/cvs
worktree=$basedir/src

rm -f $basedir/*.tar
rm -rf $cvsroot
rm -rf $worktree

mkdir $worktree
cd $worktree

cvs -d $cvsroot init
tar -cf $basedir/cvsroot.tar -C $cvsroot CVSROOT

touch file_a
cvs -d $cvsroot import -m 'Initial import' `basename $worktree` vendor-tag release-tag
tar -cf $basedir/import.tar -C $cvsroot src
cvs -d $cvsroot co -P -d . src

touch file_b
cvs -d $cvsroot add file_b
cvs -d $cvsroot commit -m 'Add file_b'
tar -cf $basedir/add-file_b.tar -C $cvsroot src

# Wait more than QUIET_TIME, so that the partial commits happen long enough
# after the initial import and adding file_b.
sleep 61

# Simulate a commit which affected multiple files but took so long to complete
# that a cvsync run didn't catch all of the affected RCS files.
echo 'this is file_a' > file_a
echo 'this is file_b' > file_b
cvs -d $cvsroot commit -m 'Update file_a and file_b'
tar -cf $basedir/split-commit-part1.tar -C $cvsroot src/file_a,v
tar -cf $basedir/split-commit-part2.tar -C $cvsroot src/file_b,v

# XXX: currently the maintainer's login name is used
#find $cvsroot -type f -exec perl -pi -e "s/author $LOGNAME;/author test;/" {} \;
