#!/usr/bin/env bash
set -ev

test $DARCS || DARCS=$PWD/../darcs
ACTUAL_DARCS=`which $DARCS`
DARCSPATH=`dirname $ACTUAL_DARCS`
PATH="$DARCSPATH:$PATH"
export EMAIL=test
export PATH

mkdir temp1
cd temp1
# this test fails in the darcs 1 format
$DARCS init --darcs-2
echo A > f
$DARCS add f
$DARCS record --ignore-times -a -m A
cd ..

$DARCS get temp1 temp2

cd temp1
echo C > f
$DARCS record --ignore-times -a -m A-C
cd ..

cd temp2
echo B > f
$DARCS record --ignore-times -a -m A-B
echo A > f
$DARCS record --ignore-times -a -m B-A
($DARCS push -a || :) 2> push-result
grep "Refusing to apply" push-result
cd ..

rm -rf temp1 temp2
