#!/bin/bash

PROG_NAME_="`basename $0`"

function printUsage
{
    cat <<EOT
Usage: $PROG_NAME_ <reponame> [src]"

$PROG_NAME_ is a script to clone upstream packages using mq from a mirror.
EOT
    exit 1
}

if (( $# < 1 )); then
    echo "W: give name of repository you want to clone"
    printUsage
fi

set -e

NAME_="$1"
DURL_="${2:-http://hg.grml.org/}"
DURL_="`echo $DURL_| sed -e 's/\/$//'`"
URL_="${DURL_}/${NAME_}"

if [ ! -d "$NAME_" ]; then
    hg clone ${URL_}
fi
hg clone ${URL_}.mq
ln -s ../../${NAME_}.mq ${NAME_}/.hg/patches

# vim: filetype=sh
