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