changeset 45:4cf415450143

merge
author Josef "Jeff" Sipek <jeffpc@josefsipek.net>
date Sat, 05 May 2007 19:46:08 -0400
parents def93d5394e0 (current diff) 7fc785a79615 (diff)
children 197b9c75f7f1
files cds-penis cds-template
diffstat 11 files changed, 175 insertions(+), 118 deletions(-) [+]
line wrap: on
line diff
--- a/TODO	Mon Jul 24 19:17:05 2006 -0400
+++ b/TODO	Sat May 05 19:46:08 2007 -0400
@@ -1,5 +1,4 @@
 Issues:
-	- cds doesn't check if we are in a CVS dir
 	- common framework
 
 cds-tag
@@ -12,3 +11,17 @@
 	- check to make sure we have to args
 cds-diff
 	- diff of removed file doesn't work
+
+
+
+Multi-VCS support:
+==================
+
+It is fairly trivial to have the 'cds-foo' file evaluate the VCS_FOO
+variable (set in 'cds'). This way, simple commands can just invoke the
+actual vcs command, while the harder to implement ones can just call a
+function within cds itself. This would turn cds-* into something very
+simple, and it may make sense to completely eliminate these very simple
+files and call the executables/functions directly in cds. This would make it
+impossible to support the dual way of calling the scripts (with a space or a
+dash).
--- a/cds	Mon Jul 24 19:17:05 2006 -0400
+++ b/cds	Sat May 05 19:46:08 2007 -0400
@@ -1,14 +1,7 @@
 #!/bin/bash
 
-
-PREFIX=`basename $0`
 DIR=`dirname $0`
 
-
-#put all files that are NOT real commands here
-HIDE[0]="template"
-NUMHIDDEN=1
-
 USAGE_STRING=""
 GREP_USAGE="USAGE_STRING="
 
@@ -17,53 +10,59 @@
 	#Print usage, and valid commands
 	printf "Pick a command:\n"
 	for x in $DIR/cds-*; do
-		check_hidden $x || continue
-
-		printf "\t%s\n" "`basename $x`"
-	done
+		[ -x $x ] && echo -e ${x##$0-}
+	done | sort | column | column -t | sed -e $'s/^/\t/'
 	printf "\n\nExample: cds-commit"
 	printf "\n\nor\n\nExample: cds commit\n"
 
 	exit $1
 }
 
-
+if [ `basename $0` = "cds" ]; then
+	if [ $# -ne 0 ]; then
+		#otherwise launch the intended client script
+		PROGNAME=cds-$1
+		PROG=$DIR/$PROGNAME
 
-function check_hidden
-{
-	i=0
+		if [ -x "$PROG" ]; then
+			shift
+			exec $PROG "$@"
+			printf "cds: Exec failed! Something is wrong!\n"
+			exit 1
+		else
+			printf "cds: Unknown command $1\n\n"
+		fi
+	fi
 
-	## Loop thru that list, and find all files we want to suppress
+	usage
+	exit 1
+fi
 
-	while [ $i -lt $NUMHIDDEN ]; do
-		if [ "$1" == $HIDE[$i] ]; then
-			return 1
-		fi
-		i=$(( $i+1 ))
-	done
-	return 0
-}
+VCS=""
+if [ -d CVS ]; then
+	# commands for CVS
+
+	VCS="cvs"
 
-# If no arguments then print help
-if [ $# == 0 ]; then
+	VCS_ADD="cvs add"
+	VCS_RM="cvs rm"
+	VCS_STATUS="cvs -n update"
+	VCS_UPDATE="cvs update -d"
+	VCS_REVERT="cvs update -d"
 
-	usage 0
+elif [ -d .svn ]; then
+	# commands for Subversion
+
+	VCS="svn"
+
+	VCS_ADD="svn add"
+	VCS_RM="svn rm"
+	VCS_STATUS="svn status"
+	VCS_UPDATE="svn update"
+	VCS_REVERT="svn revert"
 
 else
-#otherwise launch the intended client script
-	PROGNAME=$PREFIX-$1
-	PROG=$DIR/$PROGNAME
-
-	if [ -x "$PROG" ]; then
-		if check_hidden $PROG ; then
-			shift 1
-			exec $PROG "$@"
-		fi
-	fi
-	printf "$PREFIX: Unknown command $1\n\n"
-	usage 1
+	printf "cds: Unknown or no version control system in use"
+	exit 1
 fi
 
-
-
-printf "We should NEVER get here!\n"
--- a/cds-add	Mon Jul 24 19:17:05 2006 -0400
+++ b/cds-add	Sat May 05 19:46:08 2007 -0400
@@ -1,11 +1,19 @@
 #!/bin/bash
 
-cvs add "$@" >& /dev/null
+source cds
+
+if [ $VCS = cvs ]; then
+	# CVS
+	$VCS_ADD "$@" >& /dev/null
 
-if [ $? -ne 0 ] ; then
-	for x in "$@"
-	do
-		echo -e "Error adding \"$x\", file already tracked?"
-	done
+	if [ $? -ne 0 ] ; then
+		for x in "$@"
+		do
+			echo -e "Error adding \"$x\", file already tracked?"
+		done
+	fi
+
+elif [ $VCS = svn ]; then
+	# Subversion
+	$VCS_ADD "$@" > /dev/null
 fi
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cds-churn	Sat May 05 19:46:08 2007 -0400
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+function annotate
+{
+	for file in `find . -type f | grep -v CVS | xargs -0`; do
+		cvs annotate $file 2> /dev/null | awk '{print $2}' | cut -c 2-
+	done
+}
+
+function centergraph
+{
+	WIDTH=$1
+	LINES=$2
+	MAX=$3
+
+	my=`echo "scale=3; $WIDTH * ($LINES / $MAX)" | bc -lq | sed -e 's/\./\n/' | head -1`
+	if [ -z "$my" ] ; then
+		# bc likes to use .xyz for numbers < 1
+		my=0
+	fi
+
+	for ((i=0; $i < $my ; i=$(($i+1)) )); do
+		printf "#"
+	done
+}
+
+DIR=`dirname $0`
+
+WIDTH=`stty -a | head -1 | awk '{print $7}' | sed -e 's/[^0-9]//'`
+MAX=-1
+
+for entry in `annotate | sort | uniq -c | sort -nr | awk '{print $1 "@" $2}'`; do
+	entry=`echo $entry | sed -e 's/@/ /'`
+	LINES=`echo $entry | awk '{print $1}'`
+	SIZE=`echo $entry | awk '{print $2}'`
+
+	if [ $MAX -eq -1 ] ; then
+		MAX=$LINES
+	fi
+
+	CENTER=`centergraph $(($WIDTH-6-1-15-1-1)) $LINES $MAX`
+	SIZE=`echo $SIZE | $DIR/truncate 15`
+	printf "%6d %s %s\n" $LINES "$SIZE" "$CENTER"
+done
+
--- a/cds-commit	Mon Jul 24 19:17:05 2006 -0400
+++ b/cds-commit	Sat May 05 19:46:08 2007 -0400
@@ -1,5 +1,26 @@
 #!/bin/bash
 
+msg=""
+
+while [ $# -gt 0 ]; do
+	case "$1" in
+		-m)
+			msg="$2"
+			shift
+			shift
+			;;
+		*)
+			break
+			;;
+	esac
+done
+
+if [ ! -z "$msg" ]; then
+	# -m supplied, just use that instead of doing anything fancy
+	cvs commit -m "$msg" "$@"
+	exit $?
+fi
+
 if [ -z "$CDSEDITOR" ] ; then
 	# no CDSEDITOR set, fall back to old behavior
 	cvs commit "$@"
@@ -35,4 +56,4 @@
 
 cvs commit -F $CDSTMP/msg "$@"
 
-exit
+exit $?
--- a/cds-penis	Mon Jul 24 19:17:05 2006 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#!/bin/bash
-
-function annotate
-{
-	for file in `find . -type f | grep -v CVS | xargs -0`; do
-		cvs annotate $file 2> /dev/null | awk '{print $2}' | cut -c 2-
-	done
-}
-
-function centerdick
-{
-	WIDTH=$1
-	LINES=$2
-	MAX=$3
-
-	my=`echo "scale=3; $WIDTH * ($LINES / $MAX)" | bc -lq | sed -e 's/\./\n/' | head -1`
-	if [ -z "$my" ] ; then
-		# bc likes to use .xyz for numbers < 1
-		my=0
-	fi
-
-	for ((i=0; $i < $my ; i=$(($i+1)) )); do
-		printf "="
-	done
-}
-
-DIR=`dirname $0`
-
-WIDTH=`stty -a | head -1 | awk '{print $7}' | sed -e 's/[^0-9]//'`
-MAX=-1
-
-for entry in `annotate | sort | uniq -c | sort -nr | awk '{print $1 "@" $2}'`; do
-	entry=`echo $entry | sed -e 's/@/ /'`
-	LINES=`echo $entry | awk '{print $1}'`
-	DICK=`echo $entry | awk '{print $2}'`
-
-	if [ $MAX -eq -1 ] ; then
-		MAX=$LINES
-	fi
-
-	CENTER=`centerdick $(($WIDTH-6-1-15-1-2-1-1)) $LINES $MAX`
-	DICK=`echo $DICK | $DIR/truncate 15`
-	printf "%6d %s 8=%sD\n" $LINES "$DICK" "$CENTER"
-done
-
--- a/cds-revert	Mon Jul 24 19:17:05 2006 -0400
+++ b/cds-revert	Sat May 05 19:46:08 2007 -0400
@@ -1,15 +1,21 @@
 #!/bin/bash
 
-rm -f "$@"
+source cds
+
+if [ $VCS = cvs ]; then
+	rm -f "$@"
 
-for x in "$@";
-do
-	echo -n "reverting $x..."
-	rm -rf "$x"
-	cvs update -d "$x" 2>&1 > /dev/null
-	if [ $? -ne 0 ] ; then
-		echo -n "failed"
-	fi
-	echo
-done
+	for x in "$@"; do
+		echo -n "reverting $x..."
+		rm -rf "$x"
+		cvs update -d "$x" 2>&1 > /dev/null
+		if [ $? -ne 0 ] ; then
+			echo -n "failed"
+		fi
+		echo
+	done
 
+elif [ $VCS = svn ]; then
+	svn revert "$@"
+fi
+
--- a/cds-rm	Mon Jul 24 19:17:05 2006 -0400
+++ b/cds-rm	Sat May 05 19:46:08 2007 -0400
@@ -1,5 +1,10 @@
 #!/bin/bash
 
-rm -f "$@"
-cvs rm "$@"
+source cds
 
+if [ $VCS = cvs ]; then
+	rm -f "$@"
+fi
+
+$VCS_RM "$@"
+
--- a/cds-status	Mon Jul 24 19:17:05 2006 -0400
+++ b/cds-status	Sat May 05 19:46:08 2007 -0400
@@ -1,4 +1,10 @@
 #!/bin/bash
 
-cvs -n update 2> /dev/null
+source cds
 
+if [ $VCS = cvs ]; then
+	cvs -n update 2> /dev/null | sed -e 's/^\(.\)/\1     /'
+elif [ $VCS = svn ]; then
+	svn status
+fi
+
--- a/cds-template	Mon Jul 24 19:17:05 2006 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#!/bin/bash
-CMD=`basename $0 | sed -e s/cds-//`
-
-printf "$CMD is not implemented yet\n"
-
-exit 1
-
--- a/cds-update	Mon Jul 24 19:17:05 2006 -0400
+++ b/cds-update	Sat May 05 19:46:08 2007 -0400
@@ -1,4 +1,10 @@
 #!/bin/bash
 
-cvs update -d "$@"
+source cds
 
+if [ $VCS = cvs ]; then
+	cvs update -d "$@"
+elif [ $VCS = svn ]; then
+	svn update "$@"
+fi
+