1.1 --- a/TODO Mon Jul 24 19:17:05 2006 -0400
1.2 +++ b/TODO Sat May 05 19:46:08 2007 -0400
1.3 @@ -1,5 +1,4 @@
1.4 Issues:
1.5 - - cds doesn't check if we are in a CVS dir
1.6 - common framework
1.7
1.8 cds-tag
1.9 @@ -12,3 +11,17 @@
1.10 - check to make sure we have to args
1.11 cds-diff
1.12 - diff of removed file doesn't work
1.13 +
1.14 +
1.15 +
1.16 +Multi-VCS support:
1.17 +==================
1.18 +
1.19 +It is fairly trivial to have the 'cds-foo' file evaluate the VCS_FOO
1.20 +variable (set in 'cds'). This way, simple commands can just invoke the
1.21 +actual vcs command, while the harder to implement ones can just call a
1.22 +function within cds itself. This would turn cds-* into something very
1.23 +simple, and it may make sense to completely eliminate these very simple
1.24 +files and call the executables/functions directly in cds. This would make it
1.25 +impossible to support the dual way of calling the scripts (with a space or a
1.26 +dash).
2.1 --- a/cds Mon Jul 24 19:17:05 2006 -0400
2.2 +++ b/cds Sat May 05 19:46:08 2007 -0400
2.3 @@ -1,14 +1,7 @@
2.4 #!/bin/bash
2.5
2.6 -
2.7 -PREFIX=`basename $0`
2.8 DIR=`dirname $0`
2.9
2.10 -
2.11 -#put all files that are NOT real commands here
2.12 -HIDE[0]="template"
2.13 -NUMHIDDEN=1
2.14 -
2.15 USAGE_STRING=""
2.16 GREP_USAGE="USAGE_STRING="
2.17
2.18 @@ -17,53 +10,59 @@
2.19 #Print usage, and valid commands
2.20 printf "Pick a command:\n"
2.21 for x in $DIR/cds-*; do
2.22 - check_hidden $x || continue
2.23 -
2.24 - printf "\t%s\n" "`basename $x`"
2.25 - done
2.26 + [ -x $x ] && echo -e ${x##$0-}
2.27 + done | sort | column | column -t | sed -e $'s/^/\t/'
2.28 printf "\n\nExample: cds-commit"
2.29 printf "\n\nor\n\nExample: cds commit\n"
2.30
2.31 exit $1
2.32 }
2.33
2.34 +if [ `basename $0` = "cds" ]; then
2.35 + if [ $# -ne 0 ]; then
2.36 + #otherwise launch the intended client script
2.37 + PROGNAME=cds-$1
2.38 + PROG=$DIR/$PROGNAME
2.39
2.40 + if [ -x "$PROG" ]; then
2.41 + shift
2.42 + exec $PROG "$@"
2.43 + printf "cds: Exec failed! Something is wrong!\n"
2.44 + exit 1
2.45 + else
2.46 + printf "cds: Unknown command $1\n\n"
2.47 + fi
2.48 + fi
2.49
2.50 -function check_hidden
2.51 -{
2.52 - i=0
2.53 + usage
2.54 + exit 1
2.55 +fi
2.56
2.57 - ## Loop thru that list, and find all files we want to suppress
2.58 +VCS=""
2.59 +if [ -d CVS ]; then
2.60 + # commands for CVS
2.61
2.62 - while [ $i -lt $NUMHIDDEN ]; do
2.63 - if [ "$1" == $HIDE[$i] ]; then
2.64 - return 1
2.65 - fi
2.66 - i=$(( $i+1 ))
2.67 - done
2.68 - return 0
2.69 -}
2.70 + VCS="cvs"
2.71
2.72 -# If no arguments then print help
2.73 -if [ $# == 0 ]; then
2.74 + VCS_ADD="cvs add"
2.75 + VCS_RM="cvs rm"
2.76 + VCS_STATUS="cvs -n update"
2.77 + VCS_UPDATE="cvs update -d"
2.78 + VCS_REVERT="cvs update -d"
2.79
2.80 - usage 0
2.81 +elif [ -d .svn ]; then
2.82 + # commands for Subversion
2.83 +
2.84 + VCS="svn"
2.85 +
2.86 + VCS_ADD="svn add"
2.87 + VCS_RM="svn rm"
2.88 + VCS_STATUS="svn status"
2.89 + VCS_UPDATE="svn update"
2.90 + VCS_REVERT="svn revert"
2.91
2.92 else
2.93 -#otherwise launch the intended client script
2.94 - PROGNAME=$PREFIX-$1
2.95 - PROG=$DIR/$PROGNAME
2.96 -
2.97 - if [ -x "$PROG" ]; then
2.98 - if check_hidden $PROG ; then
2.99 - shift 1
2.100 - exec $PROG "$@"
2.101 - fi
2.102 - fi
2.103 - printf "$PREFIX: Unknown command $1\n\n"
2.104 - usage 1
2.105 + printf "cds: Unknown or no version control system in use"
2.106 + exit 1
2.107 fi
2.108
2.109 -
2.110 -
2.111 -printf "We should NEVER get here!\n"
3.1 --- a/cds-add Mon Jul 24 19:17:05 2006 -0400
3.2 +++ b/cds-add Sat May 05 19:46:08 2007 -0400
3.3 @@ -1,11 +1,19 @@
3.4 #!/bin/bash
3.5
3.6 -cvs add "$@" >& /dev/null
3.7 +source cds
3.8
3.9 -if [ $? -ne 0 ] ; then
3.10 - for x in "$@"
3.11 - do
3.12 - echo -e "Error adding \"$x\", file already tracked?"
3.13 - done
3.14 +if [ $VCS = cvs ]; then
3.15 + # CVS
3.16 + $VCS_ADD "$@" >& /dev/null
3.17 +
3.18 + if [ $? -ne 0 ] ; then
3.19 + for x in "$@"
3.20 + do
3.21 + echo -e "Error adding \"$x\", file already tracked?"
3.22 + done
3.23 + fi
3.24 +
3.25 +elif [ $VCS = svn ]; then
3.26 + # Subversion
3.27 + $VCS_ADD "$@" > /dev/null
3.28 fi
3.29 -
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/cds-churn Sat May 05 19:46:08 2007 -0400
4.3 @@ -0,0 +1,45 @@
4.4 +#!/bin/bash
4.5 +
4.6 +function annotate
4.7 +{
4.8 + for file in `find . -type f | grep -v CVS | xargs -0`; do
4.9 + cvs annotate $file 2> /dev/null | awk '{print $2}' | cut -c 2-
4.10 + done
4.11 +}
4.12 +
4.13 +function centergraph
4.14 +{
4.15 + WIDTH=$1
4.16 + LINES=$2
4.17 + MAX=$3
4.18 +
4.19 + my=`echo "scale=3; $WIDTH * ($LINES / $MAX)" | bc -lq | sed -e 's/\./\n/' | head -1`
4.20 + if [ -z "$my" ] ; then
4.21 + # bc likes to use .xyz for numbers < 1
4.22 + my=0
4.23 + fi
4.24 +
4.25 + for ((i=0; $i < $my ; i=$(($i+1)) )); do
4.26 + printf "#"
4.27 + done
4.28 +}
4.29 +
4.30 +DIR=`dirname $0`
4.31 +
4.32 +WIDTH=`stty -a | head -1 | awk '{print $7}' | sed -e 's/[^0-9]//'`
4.33 +MAX=-1
4.34 +
4.35 +for entry in `annotate | sort | uniq -c | sort -nr | awk '{print $1 "@" $2}'`; do
4.36 + entry=`echo $entry | sed -e 's/@/ /'`
4.37 + LINES=`echo $entry | awk '{print $1}'`
4.38 + SIZE=`echo $entry | awk '{print $2}'`
4.39 +
4.40 + if [ $MAX -eq -1 ] ; then
4.41 + MAX=$LINES
4.42 + fi
4.43 +
4.44 + CENTER=`centergraph $(($WIDTH-6-1-15-1-1)) $LINES $MAX`
4.45 + SIZE=`echo $SIZE | $DIR/truncate 15`
4.46 + printf "%6d %s %s\n" $LINES "$SIZE" "$CENTER"
4.47 +done
4.48 +
5.1 --- a/cds-commit Mon Jul 24 19:17:05 2006 -0400
5.2 +++ b/cds-commit Sat May 05 19:46:08 2007 -0400
5.3 @@ -1,5 +1,26 @@
5.4 #!/bin/bash
5.5
5.6 +msg=""
5.7 +
5.8 +while [ $# -gt 0 ]; do
5.9 + case "$1" in
5.10 + -m)
5.11 + msg="$2"
5.12 + shift
5.13 + shift
5.14 + ;;
5.15 + *)
5.16 + break
5.17 + ;;
5.18 + esac
5.19 +done
5.20 +
5.21 +if [ ! -z "$msg" ]; then
5.22 + # -m supplied, just use that instead of doing anything fancy
5.23 + cvs commit -m "$msg" "$@"
5.24 + exit $?
5.25 +fi
5.26 +
5.27 if [ -z "$CDSEDITOR" ] ; then
5.28 # no CDSEDITOR set, fall back to old behavior
5.29 cvs commit "$@"
5.30 @@ -35,4 +56,4 @@
5.31
5.32 cvs commit -F $CDSTMP/msg "$@"
5.33
5.34 -exit
5.35 +exit $?
6.1 --- a/cds-penis Mon Jul 24 19:17:05 2006 -0400
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,45 +0,0 @@
6.4 -#!/bin/bash
6.5 -
6.6 -function annotate
6.7 -{
6.8 - for file in `find . -type f | grep -v CVS | xargs -0`; do
6.9 - cvs annotate $file 2> /dev/null | awk '{print $2}' | cut -c 2-
6.10 - done
6.11 -}
6.12 -
6.13 -function centerdick
6.14 -{
6.15 - WIDTH=$1
6.16 - LINES=$2
6.17 - MAX=$3
6.18 -
6.19 - my=`echo "scale=3; $WIDTH * ($LINES / $MAX)" | bc -lq | sed -e 's/\./\n/' | head -1`
6.20 - if [ -z "$my" ] ; then
6.21 - # bc likes to use .xyz for numbers < 1
6.22 - my=0
6.23 - fi
6.24 -
6.25 - for ((i=0; $i < $my ; i=$(($i+1)) )); do
6.26 - printf "="
6.27 - done
6.28 -}
6.29 -
6.30 -DIR=`dirname $0`
6.31 -
6.32 -WIDTH=`stty -a | head -1 | awk '{print $7}' | sed -e 's/[^0-9]//'`
6.33 -MAX=-1
6.34 -
6.35 -for entry in `annotate | sort | uniq -c | sort -nr | awk '{print $1 "@" $2}'`; do
6.36 - entry=`echo $entry | sed -e 's/@/ /'`
6.37 - LINES=`echo $entry | awk '{print $1}'`
6.38 - DICK=`echo $entry | awk '{print $2}'`
6.39 -
6.40 - if [ $MAX -eq -1 ] ; then
6.41 - MAX=$LINES
6.42 - fi
6.43 -
6.44 - CENTER=`centerdick $(($WIDTH-6-1-15-1-2-1-1)) $LINES $MAX`
6.45 - DICK=`echo $DICK | $DIR/truncate 15`
6.46 - printf "%6d %s 8=%sD\n" $LINES "$DICK" "$CENTER"
6.47 -done
6.48 -
7.1 --- a/cds-revert Mon Jul 24 19:17:05 2006 -0400
7.2 +++ b/cds-revert Sat May 05 19:46:08 2007 -0400
7.3 @@ -1,15 +1,21 @@
7.4 #!/bin/bash
7.5
7.6 -rm -f "$@"
7.7 +source cds
7.8
7.9 -for x in "$@";
7.10 -do
7.11 - echo -n "reverting $x..."
7.12 - rm -rf "$x"
7.13 - cvs update -d "$x" 2>&1 > /dev/null
7.14 - if [ $? -ne 0 ] ; then
7.15 - echo -n "failed"
7.16 - fi
7.17 - echo
7.18 -done
7.19 +if [ $VCS = cvs ]; then
7.20 + rm -f "$@"
7.21
7.22 + for x in "$@"; do
7.23 + echo -n "reverting $x..."
7.24 + rm -rf "$x"
7.25 + cvs update -d "$x" 2>&1 > /dev/null
7.26 + if [ $? -ne 0 ] ; then
7.27 + echo -n "failed"
7.28 + fi
7.29 + echo
7.30 + done
7.31 +
7.32 +elif [ $VCS = svn ]; then
7.33 + svn revert "$@"
7.34 +fi
7.35 +
8.1 --- a/cds-rm Mon Jul 24 19:17:05 2006 -0400
8.2 +++ b/cds-rm Sat May 05 19:46:08 2007 -0400
8.3 @@ -1,5 +1,10 @@
8.4 #!/bin/bash
8.5
8.6 -rm -f "$@"
8.7 -cvs rm "$@"
8.8 +source cds
8.9
8.10 +if [ $VCS = cvs ]; then
8.11 + rm -f "$@"
8.12 +fi
8.13 +
8.14 +$VCS_RM "$@"
8.15 +
9.1 --- a/cds-status Mon Jul 24 19:17:05 2006 -0400
9.2 +++ b/cds-status Sat May 05 19:46:08 2007 -0400
9.3 @@ -1,4 +1,10 @@
9.4 #!/bin/bash
9.5
9.6 -cvs -n update 2> /dev/null
9.7 +source cds
9.8
9.9 +if [ $VCS = cvs ]; then
9.10 + cvs -n update 2> /dev/null | sed -e 's/^\(.\)/\1 /'
9.11 +elif [ $VCS = svn ]; then
9.12 + svn status
9.13 +fi
9.14 +
10.1 --- a/cds-template Mon Jul 24 19:17:05 2006 -0400
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,7 +0,0 @@
10.4 -#!/bin/bash
10.5 -CMD=`basename $0 | sed -e s/cds-//`
10.6 -
10.7 -printf "$CMD is not implemented yet\n"
10.8 -
10.9 -exit 1
10.10 -
11.1 --- a/cds-update Mon Jul 24 19:17:05 2006 -0400
11.2 +++ b/cds-update Sat May 05 19:46:08 2007 -0400
11.3 @@ -1,4 +1,10 @@
11.4 #!/bin/bash
11.5
11.6 -cvs update -d "$@"
11.7 +source cds
11.8
11.9 +if [ $VCS = cvs ]; then
11.10 + cvs update -d "$@"
11.11 +elif [ $VCS = svn ]; then
11.12 + svn update "$@"
11.13 +fi
11.14 +