4 Usage: validate.sh [--svnadmin-dump=<file>] [--svnrdump-dump=<file>]
5 [--repos=<url-or-path>] [-r<revision>]
6 [--ignore-existing-dump] [--make]
20 do_ignore_existing_svnadmin_dump
=
21 while test "$#" -gt 0; do
24 svnadmin_dump
="${1#*=}"
27 svnrdump_dump
="${1#*=}"
29 --ignore-existing|
--ignore-existing-dump)
30 do_ignore_existing_svnadmin_dump
=1
34 repos_protocol
="${repos_url%://*}"
35 repos_path
="${repos_url#file://}"
36 if test "$repos_protocol" = "$repos_path"; then
39 elif test ! "$repos_protocol" = 'file'; then
51 test -n "$do_both" && do_validate
=
56 test -n "$do_both" && do_generate
=
64 echo "unknown option $1" >&2
71 if test -z "$svnrdump_dump"; then
72 if test -z "$repos_url"; then
73 if test -n "$repos_path"; then
74 repos_url
="file://$(readlink -f "$repos_path")"
75 if test $?
-ne 0; then
76 echo "error: unable to derive repos url from path" >&2
77 echo "--svnrdump_dump=<file> or a local (file://) --repos=<url> is required" >&2
81 echo "--svnrdump_dump=<file> or a local (file://) --repos=<url> is required" >&2
87 svnadmin_dump_cut
="t/svnadmin-$end_rev.dump"
88 svnrdump_dump_cut
="t/svnrdump-$end_rev.dump"
91 if test -z "$svnadmin_dump"; then
92 if test -z "$repos_path"; then
93 echo "--svnadmin_dump=<file> or a local (file://) --repos=<url> is required" >&2
98 svnadmin_dump
="$svnadmin_dump_cut"
99 if test -z "$do_ignore_existing_svnadmin_dump" && test -r "$svnadmin_dump"; then
100 echo "Using existing $svnadmin_dump"
102 echo "Generating $svnadmin_dump ..."
105 if test -n "$end_rev"; then
111 svnadmin dump
--deltas $r "$repos_path" > "$svnadmin_dump"
112 if test $?
-ne 0; then
113 echo "error: failed to create canonical dump for comparison" >&2
118 echo "Using specified $svnadmin_dump"
121 if test -z "$svnrdump_dump"; then
122 svnrdump_dump
="$svnrdump_dump_cut"
124 if test -n "$do_make"; then
125 make svnrdump
> /dev
/null
;
126 if test $?
-ne 0; then
127 echo "error: Make failed. Check the program." >&2
132 echo "Generating $svnrdump_dump ..."
135 test -n "$end_rev" && r
="-r0:$end_rev"
137 .
/svnrdump
-v $r "$repos_url" > "$svnrdump_dump"
138 if test $?
-ne 0; then
139 echo "error: failed to create dump for validation" >&2
143 echo "Using specified $svnrdump_dump"
155 /^Revision-number: [0-9][0-9]*$/ {
159 } else if ( hit_max ) {
165 if (max == -1 || hit_max) {
172 if test ! "$svnadmin_dump" = "$svnadmin_dump_cut"; then
173 cut_dump
"$end_rev" <"$svnadmin_dump" >"$svnadmin_dump_cut"
174 if test $?
-ne 0; then
175 echo "error: failed to cut canonical dump $svnadmin_dump for comparison" >&2
178 echo "Successfully generated cut canonical dump $svnadmin_dump_cut for comparison" >&2
181 echo "Comparing canonical and svnrdump-based dumps..."
182 diff -au "$svnadmin_dump_cut" "$svnrdump_dump" > t
/dump-diff.error
184 '$0 !~ "Prop-delta: true|Text-delta-base-|sha1|Text-copy-source-|^-$" && $0 ~ "^+|^-" { print; }' \
185 t
/dump-diff.error
>t
/dump-diff-filtered.error
;
187 if test -n "$do_generate"; then
188 echo "Generating canonical import logs..."
192 svnadmin create t
/repo
;
194 svnadmin load t
/repo
< "$svnadmin_dump_cut" \
195 1>"$svnadmin_dump_cut.import.log" 2>"$svnadmin_dump_cut.import.error";
196 if test $?
-ne 0; then
197 echo "error: Load $end_rev failed. See $svnadmin_dump_cut.import.* for details" >&2
200 echo "Successfully generated canonical repository for comparison."
203 if test -n "$do_validate"; then
204 echo "Generating svnrdump-based import logs..."
206 log_prefix
=t
/svnrdump-
$end_rev
210 svnadmin create t
/repo
;
212 svnadmin load t
/repo
< "$svnrdump_dump" 1>"$log_prefix.import.log" 2>"$log_prefix.import.error";
213 if test $?
-ne 0; then
214 echo "error: Load $end_rev failed. See $log_prefix.import.* for details" >&2
217 echo "Successfully loaded svnrdump-based repository for validation"
219 echo "Comparing canonical and svnrdump-based import logs..."
220 diff -au "$svnadmin_dump_cut.import.log" "$log_prefix.import.log" > t
/import-diff.error
;
221 if test $?
-ne 0; then
222 echo "Validation failed. See t/import-diff.error for details." >&2
225 echo "Validation successful"