#! /bin/bash -eux

# This is meant to "resume" recovering after "repo sync".

usage()
{
    cat <<EOF
usage: ${0##*/} [+-h] [-t horizon.new] [--] {horizont.pre}
EOF
}

tmpname=horizon.restored
while getopts :ht: OPT; do
    case $OPT in
	h|+h)
	    usage
	    exit 0
	    ;;
	t)
	    tmpname=$OPTARG
	    ;;
	*)
	    usage
	    exit 2
    esac
done
shift $(( OPTIND - 1 ))
OPTIND=1


if [ $# -lt 1 ]; then
    usage
    exit 1
fi

# tmpname=$(mktemp)
repo_save_horizon > $tmpname

repo_restore_horizon $1 $tmpname
