1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
#!/bin/bash
set -e
$PREPARE_CLEAN > /dev/null
$INCLUDE_FUNCS
cd $WC
LOGFILE=$LOGDIR/027.recursive
mkdir -p 1/2/3/4/5/6
mkdir 1/2/3/4/5/d
list="1/2/3/4/5/6 1/2/3/4 1/2"
for f in $list
do
echo $f > $f-changed
echo $f > $f-same
done
# commit some of the files
$BINdflt ci -m 1 -q -o delay=yes
( cd $WC2 && $BINq up )
for n in new changed
do
for f in $list
do
echo $n `date` > $f-$n
done
done
# Change directories' mtime
touch $list
# remove directory
rmdir 1/2/3/4/5/d
function check
{
# Action, Parameter, Nr. of expected lines, Message
msg="$4"
$BINdflt $1 $2 > $LOGFILE
if [[ `wc -l < $LOGFILE` -ne "$3" ]]
then
$ERROR "$msg failed - wrong number of output lines."
fi
shift 4
while [[ "$1" != "" ]]
do
if [[ `grep $1 < $LOGFILE | wc -l` -ne $2 ]]
then
$ERROR_NB "$msg"
cat $LOGFILE
$ERROR "expected $2*$1."
fi
shift 2
done
$SUCCESS "$msg"
}
function status
{
check status "$@"
}
function revert
{
check revert "$@"
}
status "" 13 "Recursive status from root" changed 3 new 3 same 0
status "1/2/3" 9 "Partial recursive status" changed 2 new 2 same 0
status "1/2/3 -N" 4 "Partial non-recursive status" changed 1 new 1 same 0
status "1/2/3 -N -N" 1 "Partial atomic status" changed 0 new 0 same 0
status "1/2/3/4/5/6?* -N -N" 2 "Status with wildcard" changed 1 new 1 same 0
status "1/2/3/4/5/6?* -N -N -v" 3 "Verbose status with wildcard" changed 1 new 1 same 1
# Revert prints the revision it reverts to, so we get an extra line.
revert "1/2/3/4/5/d" 2 "Revert of directory deletion" /d 1 changed 0 same 0 new 0
revert "1/2/3/4/5/6-changed" 2 "Single revert" changed 1 same 0 new 0
status "1/2/3/4/5/6-changed -v" 1 "Status after revert" changed 1 same 0 new 0 "-F ....." 1
echo $RANDOM > 1/2/3/4/5/6-changed
revert "1/2/3/" 4 "Non-recursive revert" changed 1 same 0 new 0 ".m.?" 2 dir 2
revert ". -R" 6 "Recursive revert" changed 2 same 0 new 0
status "." 6 "Status after revert" new 3 changed 0 same 0
status ". -v" 17 "Verbose status after revert" new 3 changed 3 same 3 "-F ......" 11
# Don't try this at home!
rm -r *
revert ". -R -o delay=yes" 15 "Full revert" changed 3 same 3 /d 1 new 0 dir 8 5/6 3
# Now the status is empty - all is like it was.
status "." 0 "Rec st after full revert" changed 0 new 0 same 0 "-F ......" 0
status ". -v" 14 "Rec verb st after full revert" changed 3 new 0 same 3 "-F ......" 14 /d 1
$WC2_UP_ST_COMPARE
for f in $list
do
echo something-else > $f-changed
echo something-else > $f-same
done
# Directories whose entries got changed get a new mtime.
revert ". -R -o delay=yes" 10 "Full revert 2" changed 3 same 3 /d 0 new 0 ./1/2 8
# But that doesn't work for the root directory ... so we touch it, then we
# know exactly what to test for.
touch .
# Now the status is (nearly) empty - all is like it was.
status "." 1 "Rec st after full revert 2" changed 0 new 0 same 0 "-F ...." 0 "-F .m.." 1
status ". -v" 14 "Rec verb st after full revert 2" changed 3 new 0 same 3 "-F ....." 13 /d 1 "-F .t...." 1
$WC2_UP_ST_COMPARE
|