#!/bin/sh
#
# Copyright 2008 Bernie Innocenti <bernie@codewiz.org>
#
# Update to the latest upstream version, regardless what scm they
# happen to be using
#
# There are a dozen popular source control systems these days, and
# this forces you to memorize which one each project is using when
# all you want to do 99% of the times is just to pull the latest
# version of the damn source, and you don't give a shit what scms
# your upstreams are in love with.
#

if [ -d .git ]; then
	echo "Using git..."
	git pull "$@" | tee up.log || exit $?
elif [ -d .svn ]; then
	echo "Using Subversion..."
	svn up "$@" 2>&1 | tee up.log || exit $?
elif [ -d CVS ]; then
	echo "Using CVS..."
	cvs -z4 up -dP "$@" 2>&1 | egrep -v 'cvs (update|server): Updating' | tee up.log || exit $?
elif [ -d .hg ]; then
	echo "Using Mercurial..."
	hg pull "$@" && hg update -v | tee up.log || exit $?
elif [ -d .bzr ]; then
	echo "Using Bazaar (sorry)..."
	bzr pull "$@" | tee -a up.log || exit $?
else
	echo >&2 "Unsupported SCM, or current directory is not a repository, moron!"
	exit 666
fi
