]> Tony Duckles's Git Repositories (git.nynim.org) - svn2svn.git/blob - tests/diff-repo.sh
Fix typo in comment
[svn2svn.git] / tests / diff-repo.sh
1 #!/bin/bash
2 # Compare the contents of two different SVN repositories.
3
4 [ $# -eq 0 ] && {
5 echo "usage: $0 [repo1] [repo2]"
6 exit 1
7 }
8
9 PWD=$(pwd)
10 WC1="$PWD/_wc_tmp1_$$"
11 WC2="$PWD/_wc_tmp2_$$"
12 found_diff=0
13
14 # Create a working-copy for the reference repo
15 # Note: We assume that the replay working-copy ("_wc_target") still exists from t*.sh
16 rm -rf "$WC1" "$WC2"
17 svn co -q $1 "$WC1"
18 svn co -q $2 "$WC2"
19
20 # Check if the final list of files is the same
21 cd "$WC1" && FILES1=$(find . -type f | grep -v "\.svn" | sed 's/^\.\///') && cd "$PWD"
22 cd "$WC2" && FILES2=$(find . -type f | grep -v "\.svn" | sed 's/^\.\///') && cd "$PWD"
23 if [ "$FILES1" != "$FILES2" ]; then
24 echo "Found file-list differences:"
25 echo "$FILES1" > _files1.txt
26 echo "$FILES2" > _files2.txt
27 echo "<<< @A"
28 echo ">>> @B"
29 diff _files1.txt _files2.txt
30 rm _files1.txt _files2.txt
31 found_diff=1
32 fi
33
34 # Check if the final file-contents is the same
35 cd "$WC1"
36 FILES=$(find . -type f | grep -v "\.svn")
37 cd "$PWD"
38 while read file; do
39 fname=$(echo "$file" | sed 's/^\.\///')
40 FILE1="$WC1/$fname"
41 FILE2="$WC2/$fname"
42 if [ -f "$FILE2" ]; then
43 chksum1=$(md5sum "$FILE1" | cut -c1-32)
44 chksum2=$(md5sum "$FILE2" | cut -c1-32)
45 if [ "$chksum1" != "$chksum2" ]; then
46 echo "Checksum mismatch: $fname"
47 echo "<<< @A $fname $chksum1"
48 echo ">>> @B $fname $chksum2"
49 found_diff=1
50 fi
51 else
52 found_diff=1
53 fi
54 done < <(echo "$FILES")
55
56 # Clean-up
57 rm -rf "$WC1" "$WC2"
58
59 # If we found any differences, exit with an error-code
60 [ "$found_diff" -eq 1 ] && exit 1
61 exit 0