#!/bin/bash

## Create minimal developement environment for NEMO
###################################################

## Optional arguments
## - $1: developer ID
## - $2: 'repo' to replicate the layout of whole repository

dir='NEMO_dev'
if [ "$2" == 'repo' ]; then root=''; else root='NEMO'; fi

## Copy of the repository with empty root directories
svn co --depth immediates http://forge.ipsl.jussieu.fr/nemo/svn/$root $dir

## Switch to developer role if ID is provided
if [ -n "$1" ]; then
    ssh-copy-id -i ~/.ssh/id_rsa.pub $1@forge.ipsl.jussieu.fr 2> /dev/null
    svn sw --relocate http://forge.ipsl.jussieu.fr            \
	svn+ssh://$1@forge.ipsl.jussieu.fr/ipsl/forge/projets \
	NEMO_dev
fi

if [ "$2" == 'repo' ]; then
    svn up --set-depth immediates $dir/utils $dir/vendors
    dir=$dir/'NEMO'
fi

## Get the 1st level tree under 'branches' and 'releases'
svn up --set-depth immediates $dir/branches $dir/releases

## Download trunk and last release
svn up --set-depth infinity $dir/trunk
svn up --set-depth infinity $dir/releases/release-3.6

exit 0
