]> Tony Duckles's Git Repositories (git.nynim.org) - svn2svn.git/blob - tests/check-replay-repo.sh
Better "Usage" help-text
[svn2svn.git] / tests / check-replay-repo.sh
1 #!/bin/sh
2 # Compare the reference (make-ref-repo.sh) and replay (make-replay-repo.sh)
3 # repositories to check for any differences/problems with the svn2svn replay.
4
5 PWD=$(pwd)
6 WCREF="$PWD/_wc_ref"
7 WCDUP="$PWD/_wc_target"
8 found_diff=0
9
10 # Create a working-copy for the reference repo
11 # Note: We assume that the replay working-copy ("_wc_target") still exists from make-replay-repo.sh
12 #svn co -q file://$PWD/_repo_ref $WCREF
13 svn co -q file://$PWD/_repo_ref/trunk $WCREF
14
15 # Check if the final list of files is the same
16 echo ">> Checking file-list..."
17 cd $WCREF && FILESREF=$(find . -type f | grep -v "\.svn") && cd $PWD
18 cd $WCDUP && FILESDUP=$(find . -type f | grep -v "\.svn") && cd $PWD
19 if [ "$FILESREF" != "$FILESDUP" ]; then
20 echo "$FILESREF" > _files_ref.txt
21 echo "$FILESDUP" > _files_replay.txt
22 echo "<<< _files_reference.txt"
23 echo ">>> _files_replay.txt"
24 diff _files_ref.txt _files_replay.txt
25 rm _files_ref.txt _files_replay.txt
26 found_diff=1
27 fi
28 echo ""
29
30 # Check if the final file-contents is the same
31 echo ">> Checking file-contents..."
32 cd $WCREF
33 FILES=$(find . -type f | grep -v "\.svn")
34 cd $PWD
35 for file in $FILES; do
36 fname=$(echo "$file" | sed 's/^\.\///')
37 FILEREF="$WCREF/$fname"
38 FILEDUP="$WCDUP/$fname"
39 if [ -f "$FILEDUP" ]; then
40 chksum1=$(md5sum $FILEREF | cut -c1-32)
41 chksum2=$(md5sum $FILEDUP | cut -c1-32)
42 if [ "$chksum1" != "$chksum2" ]; then
43 echo "Checksum mismatch: $fname"
44 echo " $chksum1 $FILEREF"
45 echo " $chksum2 $FILEDUP"
46 found_diff=1
47 fi
48 else
49 echo "No such file: $FILEDUP"
50 found_diff=1
51 fi
52 done
53 echo ""
54
55 # Clean-up
56 rm -rf $WCREF
57
58 # If we found any differences, exit with an error-code
59 [ "$found_diff" -eq 1 ] && exit 1