summaryrefslogtreecommitdiff
path: root/localvcsactions
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2006-07-27 22:32:54 +0000
committerJonas Smedegaard <dr@jones.dk>2006-07-27 22:32:54 +0000
commitd621aa3802b4c34dbf7a224cedac84dab0b929e1 (patch)
treefc30718e550f8a1b4614aaaf5a75d4158362239e /localvcsactions
parentb1e8a8c90d91f357958bfc9f9427971e734e9418 (diff)
Add Version control system scripts.
Diffstat (limited to 'localvcsactions')
-rwxr-xr-xlocalvcsactions112
1 files changed, 112 insertions, 0 deletions
diff --git a/localvcsactions b/localvcsactions
new file mode 100755
index 0000000..7352c3d
--- /dev/null
+++ b/localvcsactions
@@ -0,0 +1,112 @@
+#!/bin/sh
+
+set -e
+
+action=$(basename $0 .sh)
+
+tar_excludes="--exclude CVSROOT --exclude .cvsignore --exclude .svn --exclude .arch-ids --exclude {arch} --exclude .hg --exclude .hgignore --exclude .hgtags"
+
+projects=${1:-$(find -mindepth 1 -maxdepth 1 -type d -printf '%f\n')}
+for project in $projects; do
+ if [ -x $project/$action.sh ]; then
+ echo " ** Custom updating project $project... **"
+ (cd $project && ./$action.sh)
+ else
+ targets=${2:-$(find $project -mindepth 1 -maxdepth 1 -type d -printf '%f\n')}
+ for target in $targets; do
+ repository=""
+ branch=""
+ if [ -d "$project/$target/.hg" ]; then
+ versys="Mercurial"
+ versysfile="hg"
+ repository="$(cat $project/$target/.hg/hgrc | perl -n -e '/^default\s+=\s+(\S+)/ && print "$1\n"')"
+ elif [ -d "$project/$target/{arch}" ]; then
+ versys="ARCH"
+ versysfile="arch"
+ repository="$(cat $project/$target/{arch}/++default-version)"
+ elif [ -d "$project/$target/.svn" ]; then
+ versys="SVN"
+ versysfile="svn"
+ elif [ -d "$project/$target/CVS" ]; then
+ versys="CVS"
+ versysfile="cvs"
+ repository="$(cat $project/$target/CVS/Repository)"
+ # Get Tag if available
+ if [ -f $project/$target/CVS/Tag ]; then
+ branch="$(egrep '^N' $project/$target/CVS/Tag | sed 's/^N//')"
+ fi
+ else
+ echo "ERROR: Unknown version control system used for \"$project/$target\"."
+ exit 1
+ fi
+ case $action in
+ update)
+ echo " ** Updating $versys project \"$project\" target \"$target\"${repository:+ (repository \"$repository\"${branch:+ branch \"$branch\"})}"
+ case $versys in
+ CVS)
+ ( cd $project/$target && cvs -z3 update -dP 2>&1 || exit 1 ) \
+ | egrep -v '^cvs(pserver)? (server|update): Updating' || [ $? -lt 2 ] # catch grep failures
+ ;;
+ SVN)
+ ( cd $project/$target && svn update )
+ ;;
+ ARCH)
+ ( cd $project/$target && tla update )
+ ;;
+ Mercurial)
+ ( cd $project/$target && hg pull -u )
+ ;;
+ *)
+ echo "ERROR: Action \"$action\" not supported for \"$project/$target\"."
+ exit 1
+ ;;
+ esac
+ ;;
+ archive)
+ echo " ** Creating snapshot of $versys project \"$project\" target \"$target\"${repository:+ (repository \"$repository\"${branch:+ branch \"$branch\"})}"
+ case $versys in
+ CVS|SVN|ARCH|Mercurial)
+ ( cd $project && tar chf - --exclude CVS $tar_excludes $target ) \
+ | gzip -f9 > $project/$target-$versysfile$(date '+%Y%m%d').tar.gz
+ ;;
+ *)
+ echo "ERROR: Action \"$action\" not supported for \"$project/$target\"."
+ exit 1
+ ;;
+ esac
+ ;;
+ mkchanges)
+ echo " ** Building changelog of $versys project \"$project\" target \"$target\"${repository:+ (repository \"$repository\"${branch:+ branch \"$branch\"})}"
+ case $versys in
+ CVS)
+# ( cd $project/$target && cvs2cl --gmt -S --no-wrap -f ../$target.ChangeLog 2>&1 || exit 1 ) \
+# ( cd $project/$target && cvs2cl --gmt -S --no-wrap ${branch:+-F $branch} -f ../$target.ChangeLog 2>&1 || exit 1 ) \
+ ( cd $project/$target && cvs2cl --gmt -S --no-wrap -F ${branch:-TRUNK} -f ../$target.ChangeLog 2>&1 || exit 1 ) \
+ | egrep -v '^cvs(pserver)? (server|log): Logging' || [ $? -lt 2 ] # catch grep failures
+ ;;
+ SVN)
+ ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak )
+ ( cd $project/$target && svn log -v | localsvnlog2cl > ../$target.ChangeLog )
+ ;;
+ ARCH)
+ ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak )
+ ( cd $project/$target && tla changelog > ../$target.ChangeLog )
+ ;;
+ Mercurial)
+ ( cd $project/$target && test -f ../$target.ChangeLog && mv -f ../$target.ChangeLog ../$target.ChangeLog.bak )
+ ( cd $project/$target && hg log -v > ../$target.ChangeLog )
+ ;;
+ *)
+ echo "ERROR: Action \"$action\" not supported for \"$project/$target\"."
+ exit 1
+ ;;
+ esac
+ ;;
+ *)
+ echo "ERROR: Unknown action \"$action\" for \"$project/$target\"."
+ exit 1
+ ;;
+ esac
+ done
+ fi
+done