subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1684940 - in /subversion/trunk/subversion: svnadmin/svnadmin.c tests/cmdline/svnadmin_tests.py
Date Thu, 11 Jun 2015 16:28:03 GMT
Author: brane
Date: Thu Jun 11 16:28:03 2015
New Revision: 1684940

URL: http://svn.apache.org/r1684940
Log:
Make 'svnadmin verify --keep-going --quiet' print errors to stderr,
as promised by the documentation.

* subversion/svnadmin/svnadmin.c
  (repos_notify_handler_baton): New member 'silent_running'.
  (repos_notify_handler): Implement silent running mode:
   only send notifications for warnings and errors.
  (subcommand_verify): With --quiet, print errors to stderr
   but do not print any other notifications and do not print
   the --keep-going error summary.

* subversion/tests/cmdline/svnadmin_tests.py
  (verify_keep_going_quiet): New test case for 'svnadmin verify --keep-going'.
  (test_list): Added verify_keep_going_quiet.

Modified:
    subversion/trunk/subversion/svnadmin/svnadmin.c
    subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py

Modified: subversion/trunk/subversion/svnadmin/svnadmin.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnadmin/svnadmin.c?rev=1684940&r1=1684939&r2=1684940&view=diff
==============================================================================
--- subversion/trunk/subversion/svnadmin/svnadmin.c (original)
+++ subversion/trunk/subversion/svnadmin/svnadmin.c Thu Jun 11 16:28:03 2015
@@ -868,6 +868,9 @@ struct repos_notify_handler_baton {
   /* Stream to write progress and other non-error output to. */
   svn_stream_t *feedback_stream;
 
+  /* Suppress notifications that are neither errors nor warnings. */
+  svn_boolean_t silent_running;
+
   /* Whether errors contained in notifications should be printed along
      with the notification. If FALSE, any errors will only be
      summarized. */
@@ -891,6 +894,14 @@ repos_notify_handler(void *baton,
   struct repos_notify_handler_baton *b = baton;
   svn_stream_t *feedback_stream = b->feedback_stream;
 
+  /* Don't print anything if the feedback stream isn't provided.
+     Only print errors and warnings in silent mode. */
+  if (!feedback_stream
+      || (b->silent_running
+          && notify->action != svn_repos_notify_warning
+          && notify->action != svn_repos_notify_failure))
+    return;
+
   switch (notify->action)
   {
     case svn_repos_notify_warning:
@@ -1794,6 +1805,8 @@ subcommand_verify(apr_getopt_t *os, void
   svn_fs_t *fs;
   svn_revnum_t youngest, lower, upper;
   struct repos_notify_handler_baton notify_baton = { 0 };
+  struct repos_notify_handler_baton *notify_baton_p = &notify_baton;
+  svn_repos_notify_func_t notify_func = repos_notify_handler;
   svn_error_t *verify_err;
 
   /* Expect no more arguments. */
@@ -1838,28 +1851,42 @@ subcommand_verify(apr_getopt_t *os, void
       upper = lower;
     }
 
-  if (! opt_state->quiet)
-    notify_baton.feedback_stream = recode_stream_create(stdout, pool);
+  /* Set up the notification handler. */
+  if (!opt_state->quiet || opt_state->keep_going)
+    {
+      if (opt_state->quiet)
+        {
+          notify_baton.silent_running = TRUE;
+          notify_baton.feedback_stream = recode_stream_create(stderr, pool);
+        }
+      else
+        notify_baton.feedback_stream = recode_stream_create(stdout, pool);
 
-  if (opt_state->keep_going)
-    notify_baton.error_summary =
-      apr_array_make(pool, 0, sizeof(struct verification_error *));
-  else
-    notify_baton.silent_errors = TRUE;
+      if (opt_state->keep_going)
+        notify_baton.error_summary =
+          apr_array_make(pool, 0, sizeof(struct verification_error *));
+      else
+        notify_baton.silent_errors = TRUE;
 
-  notify_baton.result_pool = pool;
+      notify_baton.result_pool = pool;
+    }
+  else
+    {
+      notify_func = NULL;
+      notify_baton_p = NULL;
+    }
 
   verify_err = svn_repos_verify_fs3(repos, lower, upper,
                                     opt_state->keep_going,
                                     opt_state->check_normalization,
                                     opt_state->metadata_only,
-                                    !opt_state->quiet
-                                    ? repos_notify_handler : NULL,
-                                    &notify_baton, check_cancel,
-                                    NULL, pool);
+                                    notify_func, notify_baton_p,
+                                    check_cancel, NULL, pool);
 
   /* Show the --keep-going error summary. */
-  if (opt_state->keep_going && notify_baton.error_summary->nelts > 0)
+  if (!opt_state->quiet
+      && opt_state->keep_going
+      && notify_baton.error_summary->nelts > 0)
     {
       int rev_maxlength;
       svn_revnum_t end_revnum;

Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1684940&r1=1684939&r2=1684940&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Thu Jun 11 16:28:03 2015
@@ -2117,6 +2117,52 @@ def verify_keep_going(sbox):
   # Don't leave a corrupt repository
   svntest.main.safe_rmtree(sbox.repo_dir, True)
 
+
+@SkipUnless(svntest.main.is_fs_type_fsfs)
+def verify_keep_going_quiet(sbox):
+  "svnadmin verify --keep-going --quiet test"
+
+  sbox.build(create_wc = False)
+  repo_url = sbox.repo_url
+  B_url = sbox.repo_url + '/B'
+  C_url = sbox.repo_url + '/C'
+
+  # Create A/B/E/bravo in r2.
+  svntest.actions.run_and_verify_svn(None, [],
+                                     'mkdir', '-m', 'log_msg',
+                                     B_url)
+
+  svntest.actions.run_and_verify_svn(None, [],
+                                     'mkdir', '-m', 'log_msg',
+                                     C_url)
+
+  r2 = fsfs_file(sbox.repo_dir, 'revs', '2')
+  fp = open(r2, 'r+b')
+  fp.write("""inserting junk to corrupt the rev""")
+  fp.close()
+
+  exit_code, output, errput = svntest.main.run_svnadmin("verify",
+                                                        "--keep-going",
+                                                        "--quiet",
+                                                        sbox.repo_dir)
+
+  exp_err = svntest.verify.RegexListOutput(["svnadmin: E160004:.*",
+                                            ".*Error verifying revision 2.",
+                                            "svnadmin: E160004:.*",
+                                            "svnadmin: E160004:.*",
+                                            ".*Error verifying revision 3.",
+                                            "svnadmin: E160004:.*",
+                                            "svnadmin: E160004:.*",
+                                            "svnadmin: E165011:.*"], False)
+  if svntest.verify.verify_outputs(
+          "Unexpected error while running 'svnadmin verify'.",
+          output, errput, None, exp_err):
+    raise svntest.Failure
+
+  # Don't leave a corrupt repository
+  svntest.main.safe_rmtree(sbox.repo_dir, True)
+
+
 @SkipUnless(svntest.main.is_fs_type_fsfs)
 def verify_invalid_path_changes(sbox):
   "detect invalid changed path list entries"
@@ -2991,6 +3037,7 @@ test_list = [ None,
               mergeinfo_race,
               recover_old_empty,
               verify_keep_going,
+              verify_keep_going_quiet,
               verify_invalid_path_changes,
               verify_denormalized_names,
               fsfs_recover_old_non_empty,



Mime
View raw message