#!/usr/bin/env bash --login 

if ! which bzr > /dev/null; then
	echo "Could not locate Bazaar. Is it installed on this system?" >&2
	exit 201
fi

if ! bzr alias diff="diff --using=ksdiff" 2>&1; then
	echo "Could not set the diff alias" >&2
	exit 2
fi

if ! bzr config --scope=bazaar bzr.mergetool.Kaleidoscope="ksdiff --merge --output \"{result}\" --base \"{base}\" -- \"{this}\" \"{other}\"" 2>&1; then
	echo "Could not create a Kaleidoscope merge tool" >&2
	exit 3
fi

if ! bzr config --scope=bazaar bzr.default_mergetool=Kaleidoscope 2>&1; then
	echo "Could not set Kaleidoscope as the default merge tool" >&2
	exit 4
fi
