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