#!/bin/sh

. patchfns 2>/dev/null ||
. /usr/lib/patch-scripts/patchfns 2>/dev/null ||
. $PATCHSCRIPTS_LIBDIR/patchfns 2>/dev/null ||
{
	echo "Impossible to find my library 'patchfns'."
	echo "Check your install, or go to the right directory"
	exit 1
}

build()
{
	if [ -e $1 ]
	then
		files="$files $1"
	fi
}

if [ $# -eq 1 ]
then
	OLD=$(stripit $1)
	NEW=$OLD
elif [ $# -eq 2 ]
then
	OLD=$(stripit $1)
	NEW=$(stripit $2)
else
	echo "Usage: rename-patch old [new]"
	exit 1
fi

files=""

build $P/pc/$OLD.pc
build $P/patches/$OLD.patch
build $P/txt/$OLD.txt

mv $P/pc/$OLD.pc $P/pc/old/$NEW.pc
mv $P/patches/$OLD.patch $P/patches/old/$NEW.patch
mv $P/txt/$OLD.txt $P/txt/old/$NEW.txt

cvs remove $files

files=""

build $P/pc/old/$NEW.pc
build $P/patches/old/$NEW.patch
build $P/txt/old/$NEW.txt
cvs add $files
