Hi all,
Currently svnadmin verify would stop verification process once an
error/corruption is found in the repo. It does not go till the HEAD of
the repo to see if there are further corruptions/errors.
It would be helpful if "--force" switch would do this.
Attaching a patch and the log message for the same. Please share your
thoughts...
Thanks and regards
Prabhu
Implement svnadmin verify --force, which would continue the verification
even if there is some corruption, after printing the errors to stderr.
* subversion/svnadmin/main.c
(svnadmin__cmdline_options_t):
(svnadmin_opt_state): add force option.
(subcommand_verify) : uses the new svn_repos_verify_fs3 function.
* subversion/include/svn_repos.h
(svn_repos_verify_fs3): newly added to handle "force" option.
* subversion/libsvn_repos/dump.c
(svn_repos_verify_fs3): now handles "force".
If "force" is TRUE, then the error message is
written to the stderr and verify process continues.
* subversion/libsvn_repos/deprecated.c
(svn_repos_verify_fs2) : deprecated.
Now calls svn_repos_verify_fs3 with force as FALSE.
Patch by: Prabhu Gnana Sundar <prabhugs{_AT_}collab.net>
Index: subversion/libsvn_repos/deprecated.c
===================================================================
--- subversion/libsvn_repos/deprecated.c (revision 1398254)
+++ subversion/libsvn_repos/deprecated.c (working copy)
@@ -728,6 +728,27 @@
}
svn_error_t *
+svn_repos_verify_fs2(svn_repos_t *repos,
+ svn_revnum_t start_rev,
+ svn_revnum_t end_rev,
+ svn_repos_notify_func_t notify_func,
+ void *notify_baton,
+ svn_cancel_func_t cancel_func,
+ void *cancel_baton,
+ apr_pool_t *pool)
+{
+ return svn_error_trace(svn_repos_verify_fs3(repos,
+ start_rev,
+ end_rev,
+ notify_func,
+ notify_baton,
+ cancel_func,
+ cancel_baton,
+ FALSE,
+ pool));
+}
+
+svn_error_t *
svn_repos_verify_fs(svn_repos_t *repos,
svn_stream_t *feedback_stream,
svn_revnum_t start_rev,
@@ -736,16 +757,16 @@
void *cancel_baton,
apr_pool_t *pool)
{
- return svn_error_trace(svn_repos_verify_fs2(repos,
- start_rev,
- end_rev,
- feedback_stream
- ? repos_notify_handler
- : NULL,
- feedback_stream,
- cancel_func,
- cancel_baton,
- pool));
+ return svn_repos_verify_fs2(repos,
+ start_rev,
+ end_rev,
+ feedback_stream
+ ? repos_notify_handler
+ : NULL,
+ feedback_stream,
+ cancel_func,
+ cancel_baton,
+ pool);
}
/*** From load.c ***/
Index: subversion/libsvn_repos/dump.c
===================================================================
--- subversion/libsvn_repos/dump.c (revision 1398254)
+++ subversion/libsvn_repos/dump.c (working copy)
@@ -35,6 +35,7 @@
#include "svn_checksum.h"
#include "svn_props.h"
#include "svn_sorts.h"
+#include "svn_cmdline.h"
#include "private/svn_mergeinfo_private.h"
#include "private/svn_fs_private.h"
@@ -1360,13 +1361,14 @@
}
svn_error_t *
-svn_repos_verify_fs2(svn_repos_t *repos,
+svn_repos_verify_fs3(svn_repos_t *repos,
svn_revnum_t start_rev,
svn_revnum_t end_rev,
svn_repos_notify_func_t notify_func,
void *notify_baton,
svn_cancel_func_t cancel_func,
void *cancel_baton,
+ svn_boolean_t force,
apr_pool_t *pool)
{
svn_fs_t *fs = svn_repos_fs(repos);
@@ -1397,6 +1399,7 @@
end_rev, youngest);
/* Verify global/auxiliary data and backend-specific data first. */
+ if (!force)
SVN_ERR(svn_fs_verify(svn_fs_path(fs, pool), cancel_func, cancel_baton,
start_rev, end_rev, pool));
@@ -1413,11 +1416,12 @@
void *cancel_edit_baton;
svn_fs_root_t *to_root;
apr_hash_t *props;
+ svn_error_t *err;
svn_pool_clear(iterpool);
/* Get cancellable dump editor, but with our close_directory handler. */
- SVN_ERR(get_dump_editor(&dump_editor, &dump_edit_baton,
+ err = get_dump_editor(&dump_editor, &dump_edit_baton,
fs, rev, "",
svn_stream_empty(iterpool),
NULL, NULL,
@@ -1425,7 +1429,15 @@
notify_func, notify_baton,
start_rev,
FALSE, TRUE, /* use_deltas, verify */
- iterpool));
+ iterpool);
+ if (err && force)
+ {
+ svn_handle_error2(err, stderr, FALSE /* non-fatal */, "svnadmin: ");
+ continue;
+ }
+ else
+ SVN_ERR(err);
+
SVN_ERR(svn_delta_get_cancellation_editor(cancel_func, cancel_baton,
dump_editor, dump_edit_baton,
&cancel_editor,
Index: subversion/include/svn_repos.h
===================================================================
--- subversion/include/svn_repos.h (revision 1398254)
+++ subversion/include/svn_repos.h (working copy)
@@ -2517,8 +2517,29 @@
* cancel_baton as argument to see if the caller wishes to cancel the
* verification.
*
+ * If @a force is @c TRUE, the verify process prints the error message
+ * to the stderr and continues.
+ *
+ * @since New in 1.8.
+ */
+svn_error_t *
+svn_repos_verify_fs3(svn_repos_t *repos,
+ svn_revnum_t start_rev,
+ svn_revnum_t end_rev,
+ svn_repos_notify_func_t notify_func,
+ void *notify_baton,
+ svn_cancel_func_t cancel,
+ void *cancel_baton,
+ svn_boolean_t force,
+ apr_pool_t *scratch_pool);
+
+/**
+ * Similar to svn_repos_verify_fs3(), but without force.
+ *
* @since New in 1.7.
+ * @deprecated Provided for backward compatibility with the 1.7 API.
*/
+
svn_error_t *
svn_repos_verify_fs2(svn_repos_t *repos,
svn_revnum_t start_rev,
Index: subversion/svnadmin/main.c
===================================================================
--- subversion/svnadmin/main.c (revision 1398254)
+++ subversion/svnadmin/main.c (working copy)
@@ -193,7 +193,8 @@
svnadmin__pre_1_4_compatible,
svnadmin__pre_1_5_compatible,
svnadmin__pre_1_6_compatible,
- svnadmin__pre_1_8_compatible
+ svnadmin__pre_1_8_compatible,
+ svnadmin__force
};
/* Option codes and descriptions.
@@ -286,6 +287,9 @@
N_("use format compatible with Subversion versions\n"
" earlier than 1.8")},
+ {"force", svnadmin__force, 0,
+ N_("continue verifying even if there is a corruption")},
+
{"memory-cache-size", 'M', 1,
N_("size of the extra in-memory cache in MB used to\n"
" minimize redundant operations. Default: 16.\n"
@@ -473,7 +477,7 @@
{"verify", subcommand_verify, {0}, N_
("usage: svnadmin verify REPOS_PATH\n\n"
"Verifies the data stored in the repository.\n"),
- {'r', 'q', 'M'} },
+ {'r', 'q', svnadmin__force, 'M'} },
{ NULL, NULL, {0}, NULL, {0} }
};
@@ -503,6 +507,7 @@
svn_boolean_t clean_logs; /* --clean-logs */
svn_boolean_t bypass_hooks; /* --bypass-hooks */
svn_boolean_t wait; /* --wait */
+ svn_boolean_t force; /* --force */
svn_boolean_t bypass_prop_validation; /* --bypass-prop-validation */
enum svn_repos_load_uuid uuid_action; /* --ignore-uuid,
--force-uuid */
@@ -1525,10 +1530,11 @@
if (! opt_state->quiet)
progress_stream = recode_stream_create(stderr, pool);
- return svn_repos_verify_fs2(repos, lower, upper,
+ return svn_repos_verify_fs3(repos, lower, upper,
!opt_state->quiet
? repos_notify_handler : NULL,
- progress_stream, check_cancel, NULL, pool);
+ progress_stream, check_cancel, NULL,
+ opt_state->force, pool);
}
/* This implements `svn_opt_subcommand_t'. */
@@ -1990,6 +1996,9 @@
case svnadmin__pre_1_8_compatible:
opt_state.pre_1_8_compatible = TRUE;
break;
+ case svnadmin__force:
+ opt_state.force = TRUE;
+ break;
case svnadmin__fs_type:
SVN_INT_ERR(svn_utf_cstring_to_utf8(&opt_state.fs_type, opt_arg, pool));
break;