You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2013/11/24 22:53:02 UTC

svn commit: r1545081 - in /subversion/trunk/subversion: include/svn_repos.h libsvn_repos/dump.c svnadmin/svnadmin.c tests/cmdline/svnadmin_tests.py tests/cmdline/svnadmin_tests_data/normalization_check.dump

Author: brane
Date: Sun Nov 24 21:53:01 2013
New Revision: 1545081

URL: http://svn.apache.org/r1545081
Log:
Extend UCS normalization checks in 'svnadmin verify' to mergeinfo.

* subversion/include/svn_repos.h (svn_repos_notify_warning_t):
   New constants 'svn_repos_notify_warning_denormalized_mergeinfo'
   and 'svn_repos_notify_warning_mergeinfo_collision'.
  (svn_repos_verify_fs3) Update documentation of parameter 'check_ucs_norm'.
* subversion/libsvn_repos/dump.c (dump_node): Check UCS normalization
   of paths in added or changed svn:mergeinfo property values.
  (check_name_collision): Fix latent bug: copy the normalized name
   from the membuf into the pool, so that the hash key doesn't change
   during the iteration.
* subversion/svnadmin/svnadmin.c (options_table): Update the documentation
   of the --check-ucs-normalization option.

* subversion/tests/cmdline/svnadmin_tests.py (verify_denormalized_names):
   Update expected results.
* subversion/tests/cmdline/svnadmin_tests_data/normalization_check.dump:
   Add svn:mergeinfo properties for UCS normalizaiton checks.

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

Modified: subversion/trunk/subversion/include/svn_repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_repos.h?rev=1545081&r1=1545080&r2=1545081&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_repos.h (original)
+++ subversion/trunk/subversion/include/svn_repos.h Sun Nov 24 21:53:01 2013
@@ -301,7 +301,26 @@ typedef enum svn_repos_notify_warning_t
    *
    * @since New in 1.9.
    */
-  svn_repos_notify_warning_name_collision
+  svn_repos_notify_warning_name_collision,
+
+  /**
+   * Found a denormalized mergeinfo entry. Reported when the path in
+   * an entry in the svn:mergeinfo property is not normalized to
+   * Unicode Normalization Form C.
+   *
+   * @since New in 1.9.
+   */
+  svn_repos_notify_warning_denormalized_mergeinfo,
+
+  /**
+   * Detected a mergeinfo path collision. Reported when the paths in
+   * two or more entries in the same svn:mergeinfo property differ
+   * only in character representation (normalization), but are
+   * otherwise identical.
+   *
+   * @since New in 1.9.
+   */
+  svn_repos_notify_warning_mergeinfo_collision
 } svn_repos_notify_warning_t;
 
 /**
@@ -2676,10 +2695,10 @@ svn_repos_info_format(int *repos_format,
  * verification, or SVN_NO_ERROR if there were no failures.
  *
  * If @a check_ucs_norm is @c TRUE, verify that all path names in the
- * repository are normaized to Unicode Normalization Form C, and
- * report any name collisions within the same directory where the
- * names differ only in character representation, but are otherwise
- * identical.
+ * repository and in svn:mergeinfo entries are normaized to Unicode
+ * Normalization Form C, and report any name collisions within the
+ * same directory or svn:mergeinfo property where the names differ only
+ * in character representation, but are otherwise identical.
  *
  * @since New in 1.9.
  */

Modified: subversion/trunk/subversion/libsvn_repos/dump.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/dump.c?rev=1545081&r1=1545080&r2=1545081&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/dump.c (original)
+++ subversion/trunk/subversion/libsvn_repos/dump.c Sun Nov 24 21:53:01 2013
@@ -970,6 +970,89 @@ dump_node(struct edit_baton *eb,
             }
         }
 
+      /* If we're checking UCS normalization, also parse any changed
+         mergeinfo and warn about denormalized paths and name
+         collisions there. */
+      if (eb->verify && eb->check_ucs_norm && eb->notify_func)
+        {
+          /* N.B.: This hash lookup happens only once; the conditions
+             for verifying historic mergeinfo references and checking
+             UCS normalization are mutually exclusive. */
+          svn_string_t *mergeinfo_str = svn_hash_gets(prophash,
+                                                      SVN_PROP_MERGEINFO);
+          if (mergeinfo_str)
+            {
+              static const char unique[] = "unique";
+              static const char collision[] = "collision";
+
+              svn_mergeinfo_t mergeinfo;
+              svn_membuf_t buf;
+              apr_hash_t *normalized;
+              apr_hash_index_t *hi;
+
+              SVN_ERR(svn_mergeinfo_parse(&mergeinfo, mergeinfo_str->data,
+                                          pool));
+              normalized = apr_hash_make(pool);
+              svn_membuf__create(&buf, 0, pool);
+
+              for (hi = apr_hash_first(pool, mergeinfo);
+                   hi; hi = apr_hash_next(hi))
+                {
+                  const void *key;
+                  apr_ssize_t klen;
+                  const char *mipath;
+                  const char *normpath;
+                  const char *found;
+
+                  apr_hash_this(hi, &key, &klen, NULL);
+                  mipath = (const char*)key;
+                  SVN_ERR(svn_utf__normalize(&normpath, mipath, klen, &buf));
+
+                  found = svn_hash_gets(normalized, normpath);
+                  if (!found)
+                    {
+                      if (0 != strcmp(mipath, normpath))
+                        {
+                          /* Report denormlized mergeinfo path */
+                          svn_repos_notify_t *const notify =
+                            svn_repos_notify_create(svn_repos_notify_warning,
+                                                    pool);
+                          notify->warning =
+                            svn_repos_notify_warning_denormalized_mergeinfo;
+                          notify->warning_str = apr_psprintf(
+                              pool,
+                              _("Denormalized path '%s'"
+                                " in %s property of '%s'"),
+                              mipath, SVN_PROP_MERGEINFO, path);
+                          eb->notify_func(eb->notify_baton, notify, pool);
+                        }
+                      svn_hash_sets(normalized,
+                                    apr_pstrdup(pool, normpath), unique);
+                    }
+                  else if (found == collision)
+                    /* Skip already reported collision */;
+                  else
+                    {
+                      /* Report path collision in mergeinfo */
+                      svn_repos_notify_t *const notify =
+                        svn_repos_notify_create(svn_repos_notify_warning,
+                                                pool);
+                      notify->warning =
+                        svn_repos_notify_warning_mergeinfo_collision;
+                      notify->warning_str = apr_psprintf(
+                          pool,
+                          _("Duplicate representation of path '%s'"
+                            " in %s property of '%s'"),
+                          normpath, SVN_PROP_MERGEINFO, path);
+                      eb->notify_func(eb->notify_baton, notify, pool);
+                      svn_hash_sets(normalized,
+                                    apr_pstrdup(pool, normpath), collision);
+                    }
+                }
+            }
+        }
+
+
       if (eb->use_deltas && compare_root)
         {
           /* Fetch the old property hash to diff against and output a header
@@ -1881,7 +1964,8 @@ check_name_collision(void *baton, const 
 
   found = svn_hash_gets(check_baton->normalized, name);
   if (!found)
-    svn_hash_sets(check_baton->normalized, name, unique);
+    svn_hash_sets(check_baton->normalized,
+                  apr_pstrdup(pool, name), unique);
   else if (found == collision)
     /* Skip already reported collision */;
   else
@@ -1891,7 +1975,8 @@ check_name_collision(void *baton, const 
       svn_repos_notify_t *notify;
       const char* normpath;
 
-      svn_hash_sets(check_baton->normalized, name, collision);
+      svn_hash_sets(check_baton->normalized,
+                    apr_pstrdup(pool, name), collision);
       SVN_ERR(svn_utf__normalize(
                   &normpath, svn_relpath_join(db->path, name, pool),
                   SVN_UTF__UNKNOWN_LENGTH, &check_baton->buffer));

Modified: subversion/trunk/subversion/svnadmin/svnadmin.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnadmin/svnadmin.c?rev=1545081&r1=1545080&r2=1545081&view=diff
==============================================================================
--- subversion/trunk/subversion/svnadmin/svnadmin.c (original)
+++ subversion/trunk/subversion/svnadmin/svnadmin.c Sun Nov 24 21:53:01 2013
@@ -304,10 +304,11 @@ static const apr_getopt_option_t options
     {"file", 'F', 1, N_("read repository paths from file ARG")},
 
     {"check-ucs-normalization", svnadmin__check_ucs_normalization, 0,
-     N_("report path names that are not normalized to\n"
-        "                             Unicode Normalization Form C, and any names\n"
-        "                             within the same directory that differ only in\n"
-        "                             character representation, but are otherwise\n"
+     N_("report paths in the filesystem and mergeinfo\n"
+        "                             that are not normalized to Unicode Normalization\n"
+        "                             Form C, and any names within the same directory\n"
+        "                             or svn:mergeinfo property value that differ only\n"
+        "                             in character representation, but are otherwise\n"
         "                             identical")},
 
     {NULL}

Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1545081&r1=1545080&r2=1545081&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Sun Nov 24 21:53:01 2013
@@ -2056,18 +2056,27 @@ def verify_denormalized_names(sbox):
   exp_out = svntest.verify.RegexListOutput([
     ".*Verifying repository metadata",
     ".*Verified revision 0.",
-                                            # A/{Eacute}
-    "WARNING .*: Denormalized directory name 'A/.*'",
-                                       # A/{icircumflex}{odiaeresis}ta
-    "WARNING .*: Denormalized file name 'A/.*ta'",
+                                                # A/{Eacute}
+    "WARNING 0x0003: Denormalized directory name 'A/.*'",
+                                           # A/{icircumflex}{odiaeresis}ta
+    "WARNING 0x0003: Denormalized file name 'A/.*ta'",
     ".*Verified revision 1.",
     ".*Verified revision 2.",
     ".*Verified revision 3.",
-                                       # A/{Eacute}/{aring}lpha
-    "WARNING .*: Denormalized file name 'A/.*/.*lpha'",
-    "WARNING .*: Duplicate representation of path 'A/.*/.*lpha'",
+                                           # A/{Eacute}/{aring}lpha
+    "WARNING 0x0003: Denormalized file name 'A/.*/.*lpha'",
+    "WARNING 0x0004: Duplicate representation of path 'A/.*/.*lpha'",
     ".*Verified revision 4.",
-    ".*Verified revision 5."])
+    ".*Verified revision 5.",
+                                       # Q/{aring}lpha
+    "WARNING 0x0005: Denormalized path '/Q/.*lpha'"
+                                  # A/{Eacute}
+    " in svn:mergeinfo property of 'A/.*'",
+                                                      # Q/{aring}lpha
+    "WARNING 0x0006: Duplicate representation of path '/Q/.*lpha'"
+                                  # A/{Eacute}
+    " in svn:mergeinfo property of 'A/.*'",
+    ".*Verified revision 6."])
 
   if svntest.verify.verify_outputs(
       "Unexpected error while running 'svnadmin verify'.",

Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests_data/normalization_check.dump
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests_data/normalization_check.dump?rev=1545081&r1=1545080&r2=1545081&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests_data/normalization_check.dump [UTF-8] (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests_data/normalization_check.dump [UTF-8] Sun Nov 24 21:53:01 2013
@@ -13,13 +13,13 @@ V 27
 PROPS-END
 
 Revision-number: 1
-Prop-content-length: 124
-Content-length: 124
+Prop-content-length: 126
+Content-length: 126
 
 K 10
 svn:author
-V 5
-brane
+V 7
+jrandom
 K 8
 svn:date
 V 27
@@ -42,9 +42,13 @@ PROPS-END
 Node-path: A/É
 Node-kind: dir
 Node-action: add
-Prop-content-length: 10
-Content-length: 10
+Prop-content-length: 47
+Content-length: 47
 
+K 13
+svn:mergeinfo
+V 12
+/Q/ålpha:69
 PROPS-END
 
 
@@ -73,13 +77,13 @@ PROPS-END
 
 
 Revision-number: 2
-Prop-content-length: 126
-Content-length: 126
+Prop-content-length: 128
+Content-length: 128
 
 K 10
 svn:author
-V 5
-brane
+V 7
+jrandom
 K 8
 svn:date
 V 27
@@ -102,13 +106,13 @@ modified
 
 
 Revision-number: 3
-Prop-content-length: 124
-Content-length: 124
+Prop-content-length: 126
+Content-length: 126
 
 K 10
 svn:author
-V 5
-brane
+V 7
+jrandom
 K 8
 svn:date
 V 27
@@ -131,13 +135,13 @@ modified
 
 
 Revision-number: 4
-Prop-content-length: 122
-Content-length: 122
+Prop-content-length: 124
+Content-length: 124
 
 K 10
 svn:author
-V 5
-brane
+V 7
+jrandom
 K 8
 svn:date
 V 27
@@ -161,13 +165,13 @@ PROPS-END
 
 
 Revision-number: 5
-Prop-content-length: 123
-Content-length: 123
+Prop-content-length: 125
+Content-length: 125
 
 K 10
 svn:author
-V 5
-brane
+V 7
+jrandom
 K 8
 svn:date
 V 27
@@ -189,3 +193,35 @@ Content-length: 9
 modified
 
 
+Revision-number: 6
+Prop-content-length: 127
+Content-length: 127
+
+K 10
+svn:author
+V 7
+jrandom
+K 8
+svn:date
+V 27
+2013-11-24T18:04:43.128158Z
+K 7
+svn:log
+V 25
+Update mergeinfo on A/É
+PROPS-END
+
+Node-path: A/É
+Node-kind: dir
+Node-action: change
+Prop-content-length: 61
+Content-length: 61
+
+K 13
+svn:mergeinfo
+V 26
+/Q/ålpha:71
+/Q/ålpha:69
+PROPS-END
+
+