view cdseditor @ 43:7fc785a79615

renamed penis to churn
author Josef "Jeff" Sipek <jsipek@cs.sunysb.edu>
date Sat, 05 May 2007 15:53:53 -0400
parents 545f10183111
children
line wrap: on
line source

#!/bin/sh

# If you want to pass your favourite editor some other parameters
# only for Mercurial, modify this:
case "${EDITOR}" in
    "")
	#Perhaps, for both fun and peversity, make this ex?
	#Not EVERYONE has vi :-P
        EDITOR="vi"
        ;;
    emacs)
        EDITOR="$EDITOR -nw"
        ;;
    gvim|vim)
        EDITOR="$EDITOR -f -o"
        ;;
esac

CDSTMP=$1
shift

FILES="no"

echo "" > $CDSTMP/msg

if [ $# -eq 0 ] ; then
	# no args, get list of changed files
	cds-status 2> /dev/null | grep '^[AMD] ' | cut -c 3- > $CDSTMP/list
	for changed in `cat $CDSTMP/list | xargs -0` ; do
	        cds-diff "$changed" >> "$CDSTMP/diff"
		echo "CDS: changed $changed" >> $CDSTMP/msg
		FILES="yes"
	done
else
	# display only files passed by args
	for changed in "$@"; do
	        cds-diff "$changed" >> "$CDSTMP/diff"
		echo "CDS: changed $changed" >> $CDSTMP/msg
		FILES="yes"
	done
fi

if [ $FILES = "no" ] ; then
	# nothing to commit
	exit 14
fi

CHECKSUM=`md5sum "$CDSTMP/msg"`
if [ -s "$CDSTMP/diff" ]; then
    $EDITOR "$CDSTMP/msg" "$CDSTMP/diff" || exit $?
else
    $EDITOR "$CDSTMP/msg" || exit $?
fi
echo "$CHECKSUM" | md5sum -c >/dev/null 2>&1 && exit 13

RET=$?

# remove lines that begin with 'CVS:' just in case cvs commit -F doesn't
cat $CDSTMP/msg | grep -v '^CDS:' > $CDSTMP/msg2
mv $CDSTMP/msg2 $CDSTMP/msg

exit $RET