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