#!/bin/sh
# Never really run this script...
exit 0

# Set the CVS root location
CVSROOT=:ext:carlos@cvs.parisc-linux.org:/var/lib/cvs
export CVSROOT
# Set the build tools location for 'cvs-snapshot'
build_tools=/mnt/flaire/src/build-tools

# Have the project local cvs repo in $cvs_dir
cvs_dir=$1
# Download the project and set it up in $project_dir.
project_dir=$2
# Set the two tags for CVS which we will use
current_ver=$3
previous_ver=$4
# Examples might be:
# current_ver=BINUTILS_2005-12-10
# previous_ver=BINUTILS_2005-07-14
# Versions are branch tags of the name "PROJECT_YYYY-MM-DD" 
# when doing date based CVS imports

# Set the moving tag, which is usuall "project"
moving_tag=$5
# Examples might be:
# moving_tag=binutils
# moving_tag=linux

# Set the cvs module name
cvs_module=$6
# Examples might be:
# cvs_module=binutils
# cvs_module=linux-2.6

# Branch and set default branch revision, we will be importing the  new
# code into $current_ver on the module $cvs_module
cd $cvs_dir
cvs rtag -b $current_ver $cvs_module 
# Delete the moving tag used to specify the latest import
cvs rtag -d $moving_tag $cvs_module
# Move into new source tree
cd $project_dir
# Safe import the new source into the branch
# Use -C because its another CVS directory.
$build_tools/cvs-snapshot -C $cvs_module $current_ver $moving_tag
# Go to the local cvs source
cd $cvs_dir
# Update repo incase anyone did edits
cvs up -RAPd -ko
# Merge the branch back into head
cvs up -RAPd -ko -j${previous_ver} -j${current_ver}
# Examine conflicts and fix, iterate here until everything is fixed.
cvs -n up | awk '($1 == "C"){print $2}' > /tmp/$cvs_module.conflicts
# Next we do some tagging to make everything easy to diff.
# Tag before the merge.
cvs -Q tag ${current_ver}_PRE
cvs commit -m "Merged to $current_ver"
cvs -Q tag ${current_ver}_MERGED
# Done!

