#!/bin/sh -e
if [ $# -ne 2 -a $# -ne 1 ]; then
   cat <<- EOF
	usage: $0 merge_from_tag [based_on_tag]
	merge_from_tag is the tag to track in this tree
	based_on_tag is the startingpoint of next call to cvsmerge. If not
	specified, then it will be the current state of merge_from_tag.

	Two different uses of based_on_tag exists:
	a) To specify the base of the branch to be merged
	b) To specify our current base branch, when moving out base to
	   another branch.
	EOF
    exit 1
fi
if [ -f CVS/Tag ]; then
    localtag=`cat CVS/Tag|cut -c2-`
else
    localtag=HEAD
fi
rootdir=`cat CVS/Root|sed -e 's/.*://'`
module=`cat CVS/Repository|sed -e "s!^$rootdir!!"`
mergetag=$1
roottag=$2
if [ -z "$roottag" ]; then
   roottag=$mergetag
fi
basetag="Z-${localtag}_merge_${mergetag}"
cvs -z9 rtag -r $roottag $basetag $module


