#!/bin/sh

. ./init_test

echo "*** Initialisation with 2 hosts, with mismatched file/full dir"

touch $H/A/On_A
touch $H/B/On_B
touch $H/A/A_newer_than_B ; stamp 05 $H/A/A_newer_than_B
mkdir $H/B/A_newer_than_B
	touch $H/B/A_newer_than_B/new ; stamp 06 $H/B/A_newer_than_B/new
	stamp 04 $H/B/A_newer_than_B
touch $H/A/B_newer_than_A ; stamp 04 $H/A/B_newer_than_A
mkdir $H/B/B_newer_than_A
	touch $H/B/B_newer_than_A/new2 ; stamp 06 $H/B/B_newer_than_A/new2
	stamp 05 $H/B/B_newer_than_A

touch $H/A/file ; stamp 14 $H/A/file
mkdir $H/B/file
	touch $H/B/file/old ; stamp 13 $H/B/file/old
	stamp 12 $H/B/file

# I choose to take the most recent in the hierarchy

runA -f $H/A
runB -a $H/B
[ ! -f $H/B/On_B ] && Exit 100
[ -d $H/B/.nnfs/history ] && Exit 200

runA
[ ! -f $H/A/On_A ] && Exit 101
[ ! -d $H/A/.nnfs/history ] && Exit 201
[ ! -f $H/A/.nnfs/history/*/*/B_newer_than_A ] && Exit 202
[ ! -f $H/A/.nnfs/history/*/*/A_newer_than_B ] && Exit 203
[ ! -f $H/A/.nnfs/history/*/*/file ] && Exit 204
[ ! -d $H/A/file ] && Exit 301
[ ! -d $H/A/A_newer_than_B ] && Exit 302
[ ! -d $H/A/B_newer_than_A ] && Exit 303
same $H/A On_B $H/B On_B || Exit 102
same $H/A B_newer_than_A $H/B B_newer_than_A || Exit 304
same $H/A A_newer_than_B $H/B A_newer_than_B || Exit 305
same $H/A/B_newer_than_A new2 $H/B/B_newer_than_A new2 || Exit 103
same $H/A/A_newer_than_B new  $H/B/A_newer_than_B new  || Exit 104

runB
[   -d $H/B/.nnfs/history ] && Exit 204
same $H/A On_A $H/B On_A || Exit 105

Exit 0
