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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
|
#!/bin/bash
set -e
$PREPARE_CLEAN > /dev/null
$INCLUDE_FUNCS
cd $WC
fn1=file1
fn2=file2
fn3=file3
logfile=$LOGDIR/044.copyfrom
copydb=`$PATH2SPOOL . Copy`
######################################################
# Check copyfrom relation setting logic.
# Overwrite is not allowed - the user would have to revert (TODO).
# We could allow it for non-directories, however.
touch 1 4 5 s
$BINq ci -mx
# If these file had a different timestamp, the revert below would only
# change this; but we want the copy relations to be removed.
touch -r 1 2 3 6
$BINdflt cp 1 2
$BINdflt cp 5 6
$BINdflt cp ./4 $WC/3
if [[ ! -s $copydb ]]
then
$ERROR "Expected a copyfrom database at $copydb"
fi
if [[ $(echo `$BINdflt cp dump | sort`) == ". . 2 3 6 $REPURL/1 $REPURL/4 $REPURL/5" ]]
then
$SUCCESS "Setting and overwriting copyfrom information works."
else
$BINdflt cp dump
$ERROR "Setting or overwriting makes mistakes?"
fi
# Remove copyfrom markers
$BINq sync-repos
(
echo 5
echo 6
echo .
echo 4
echo 3
echo .
echo 1
echo 2
) | $BINdflt cp load
# we still have the values of the last copy operations
if [[ $(echo `$BINdflt cp dump | sort`) == ". . 2 3 6 $REPURL/1 $REPURL/4 $REPURL/5" ]]
then
$SUCCESS "Loading copyfrom information works."
else
$BINdflt cp dump
$ERROR "Loading copyfrom fails."
fi
# A "true | fsvs cp load" doesn't work, as the copyfrom information is
# added, not replaced. So we revert.
$BINdflt revert .
if [[ `$BINdflt cp dump -v` == "No copyfrom information was written." ]]
then
$SUCCESS "Purging copyfrom works"
else
$ERROR "Purging copyfrom fails"
fi
if [[ `true | $BINdflt cp load -v` == "0 copyfrom relations loaded." ]]
then
$SUCCESS "Nothing loaded."
else
$ERROR "Loading nothing on empty copy database fails"
fi
######################################################
# Test copyfrom on commits.
seq 1 100 > $fn1
$BINq ci -m "file1" -o delay=yes
# Now the copyfrom relation file should be cleaned up.
if [[ -s $copydb ]]
then
$ERROR "Expected copyfrom database at $copydb to be deleted"
fi
function Status
{
$BINdflt st > $logfile
while [[ "$1" != "" ]]
do
if ! grep -F "$1" < $logfile | grep -F "$2"
then
$ERROR "Expected status '$1' for '$2'"
fi
shift
shift
done
}
######################################################
# Test simple copying.
# The other file is moved before the commit, so we can check that a commit
# removed *exactly* the used records, and no others.
cat $fn1 > $fn2
mv $fn1 $fn3
$BINq cp $fn1 $fn2
Status ".m.+" $fn2 "N..." $fn3 "D..." $fn1
$BINq mv $fn1 $fn3
Status ".m.+" $fn2 "...+" $fn3 "D..." $fn1
$BINq ci -m "file2" $fn2
# Status ".m.+" $fn2 "...+" $fn3 "D..." $fn1
if [[ $(echo `$BINdflt cp dump | sort`) == "$fn3 $REPURL/$fn1" ]]
then
$SUCCESS "On commit correct entries purged."
else
$BINdflt cp dump
$ERROR "Commit removed wrong copyfrom entries."
fi
function CopyLog
{
src="$1"
dest="$2"
msg="$3"
LC_ALL=C svn log -v -r HEAD $REPURL > $logfile
if grep " A /$REPSUBDIR/$dest .from /$REPSUBDIR/$src:" $logfile
then
# ------------------------------------------------------------------------
# r5 | flip | 2007-11-22 18:39:20 +0100 (Thu, 22 Nov 2007) | 1 line
# Changed paths:
# A /trunk/file2 (from /trunk/file1:4)
#
# file2
# ------------------------------------------------------------------------
$SUCCESS "$msg"
else
cat $logfile
$ERROR "$msg"
fi
}
# Doing a $WC2_UP_ST_COMPARE wouldn't work here, as the moved file is not
# yet committed.
CopyLog $fn1 $fn2 "File was copied"
######################################################
# Test file renaming (moving)
# The operations have been done above.
$BINdflt ci -m "move" # -d > $logfile
$WC2_UP_ST_COMPARE
if [[ -s $copydb ]]
then
$ERROR "Expected copyfrom database at $copydb to be deleted"
fi
CopyLog $fn1 $fn3 "File was moved - 1"
if grep " D /$REPSUBDIR/$fn1" $logfile
then
$SUCCESS "File was moved - 2"
else
cat $logfile
$ERROR "File not moved? - 2"
fi
######################################################
# Test directory copying
mkdir dir1
date > dir1/date-file
seq 1 600 > dir1/large
$BINq ci -m "dir1"
src=dir1
dest=dir2
cp -a $src $dest
$BINq cp $src $dest
$BINq ci -m "$dest"
$WC2_UP_ST_COMPARE
CopyLog $src $dest "Dir was copied"
if [[ -s $copydb ]]
then
$ERROR "Expected copyfrom database at $copydb to be deleted"
fi
# 2nd try: new directory without files; the entries are implicitly copied,
# and have to be removed from therein.
dest=dir3
mkdir $dest
$BINdflt cp $src $dest
$BINq ci -m "$dest"
$WC2_UP_ST_COMPARE
CopyLog $src $dest "Empty dir was copied"
# Now try the same, but not starting in the wc root:
# Copy definition wc/a/b/c => wc/a/e/f
dirname=aergheanrgerkgergwergwergwa
pre=a/b
fulldir=$dirname/$dirname/$dirname/$dirname/$dirname
full=$fulldir/gggg
mkdir -p $pre/d/$fulldir
echo $$ $RANDOM $RANDOM > $pre/c
echo $RANDOM > $pre/d/$full
$BINq ci -m "prep"
mkdir -p a/e a/g
cp $pre/c a/e/f
cp -r $pre/d a/g/d
# copy the file
( cd a ; $BINq cp b/c ../a/e/f )
( cd a ; $BINq cp b/d ../a/g/d )
# Test diff for *long* filenames.
echo $$-$RANDOM > a/g/d/$full
$BINdflt diff a/g/d/$full > $logfile
if [[ `egrep "^[+-]" $logfile | wc -l` -eq 4 ]]
then
$SUCCESS "Diff for long copied entries with long names works."
else
$ERROR "Diff for long copied entries with long names"
fi
$BINq ci -m "copy" -o delay=yes
CopyLog a/b/c a/e/f "Copy definition below wc root"
$WC2_UP_ST_COMPARE
cp -r a with_subs
$BINq cp a with_subs
# Currently copying a copied file that's not committed is not possible.
mkdir will_error
if $BINdflt cp with_subs will_error
then
$ERROR "Unexpected exit status of copying copied, uncommitted entry."
else
$SUCCESS "Expected exit status of copying copied, uncommitted entry."
fi
$BINq ci -m "subs"
$WC2_UP_ST_COMPARE
|