Author: danielsh
Date: Fri Jun 10 23:45:51 2011
New Revision: 1134484

URL: http://svn.apache.org/viewvc?rev=1134484&view=rev
Log:
Verify FS paths for validity during dump.  Follow-up to r1129641, which added
validation to 'verify'.

The validation during dump is conditional upon 'notify_func' being available,
and does not result in a hard error.  The validation during verify always
results in a hard error.

* subversion/include/svn_repos.h
  (svn_repos_notify_warning_t):
    New enumerator 'svn_repos_notify_warning_invalid_fspath'.

* subversion/libsvn_repos/dump.c
  (dump_node): Validate FS paths during dump too if notify_func is provided.
    Use notify_func during verify as well.

* subversion/tests/cmdline/svnadmin_tests.py
  (verify_non_utf8_paths): Adjust expected stderr.

Modified:
    subversion/trunk/subversion/include/svn_repos.h
    subversion/trunk/subversion/libsvn_repos/dump.c
    subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py

Modified: subversion/trunk/subversion/include/svn_repos.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_repos.h?rev=1134484&r1=1134483&r2=1134484&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_repos.h (original)
+++ subversion/trunk/subversion/include/svn_repos.h Fri Jun 10 23:45:51 2011
@@ -259,6 +259,13 @@ typedef enum svn_repos_notify_warning_t
   /** An #SVN_PROP_MERGEINFO property's encoded mergeinfo references a
    * revision earlier than the first revision dumped. */
   svn_repos_notify_warning_found_old_mergeinfo,
+
+  /** Found an invalid path in the filesystem.
+   * @see svn_fs.h:"Directory entry names and directory paths" */
+  /* ### TODO(doxygen): make that a proper doxygen link */
+  /* See svn_fs__path_valid(). */
+  svn_repos_notify_warning_invalid_fspath,
+
 } svn_repos_notify_warning_t;
 
 /**

Modified: subversion/trunk/subversion/libsvn_repos/dump.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/dump.c?rev=1134484&r1=1134483&r2=1134484&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/dump.c (original)
+++ subversion/trunk/subversion/libsvn_repos/dump.c Fri Jun 10 23:45:51 2011
@@ -243,9 +243,33 @@ dump_node(struct edit_baton *eb,
   svn_fs_root_t *compare_root = NULL;
   apr_file_t *delta_file = NULL;
 
-  /* If we're verifying, validate the path. */
-  if (eb->verify)
-    SVN_ERR(svn_fs__path_valid(path, pool));
+  /* Maybe validate the path. */
+  if (eb->verify || eb->notify_func)
+    {
+      svn_error_t *err = svn_fs__path_valid(path, pool);
+
+      if (eb->notify_func)
+        {
+          char errbuf[512]; /* ### svn_strerror() magic number  */
+          svn_repos_notify_t *notify;
+          notify = svn_repos_notify_create(svn_repos_notify_warning, pool);
+
+          notify->warning = svn_repos_notify_warning_invalid_fspath;
+          notify->warning_str = apr_psprintf(
+                 pool,
+                 _("E%06d: While validating fspath '%s': %s"),
+                 err->apr_err, path,
+                 svn_err_best_message(err, errbuf, sizeof(errbuf)));
+
+          eb->notify_func(eb->notify_baton, notify, pool);
+        }
+
+      /* Return the error in addition to notifying about it. */
+      if (eb->verify)
+        return svn_error_return(err);
+      else
+        svn_error_clear(err);
+    }
 
   /* Write out metadata headers for this file node. */
   SVN_ERR(svn_stream_printf(eb->stream, pool,

Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1134484&r1=1134483&r2=1134484&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Fri Jun 10 
23:45:51 2011
@@ -1366,11 +1366,18 @@ def verify_non_utf8_paths(sbox):
 
   # Make sure the repository can still be dumped so that the
   # encoding problem can be fixed in a dump/edit/load cycle.
+  expected_stderr = [
+    "* Dumped revision 0.\n",
+    "WARNING 0x0002: E160005: "
+      "While validating fspath '?\\230': "
+      "Path '?\\230' is not in UTF-8"
+      "\n",
+    "* Dumped revision 1.\n",
+    ]
   exit_code, output, errput = svntest.main.run_svnadmin("dump", sbox.repo_dir)
   if svntest.verify.compare_and_display_lines(
     "Output of 'svnadmin dump' is unexpected.",
-    'STDERR', ["* Dumped revision 0.\n",
-               "* Dumped revision 1.\n"], errput):
+    'STDERR', expected_stderr, errput):
     raise svntest.Failure
 
 ########################################################################


Reply via email to