subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phi...@apache.org
Subject svn commit: r1182771 - in /subversion/trunk/subversion: libsvn_subr/mergeinfo.c tests/libsvn_subr/mergeinfo-test.c
Date Thu, 13 Oct 2011 10:37:13 GMT
Author: philip
Date: Thu Oct 13 10:37:12 2011
New Revision: 1182771

URL: http://svn.apache.org/viewvc?rev=1182771&view=rev
Log:
For issue 4032, make the server be graceful on non-canonical paths
in svn:mergeinfo.

* subversion/libsvn_subr/mergeinfo.c
  (parse_pathname): Change parameter type, canonicalize the returned path.
  (parse_revision_line): Change variable type.

* subversion/tests/libsvn_subr/mergeinfo-test.c
  (NBR_MERGEINFO_VALS, mergeinfo_vals, mergeinfo_paths,
   mergeinfo_ranges): New test cases.

Modified:
    subversion/trunk/subversion/libsvn_subr/mergeinfo.c
    subversion/trunk/subversion/tests/libsvn_subr/mergeinfo-test.c

Modified: subversion/trunk/subversion/libsvn_subr/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/mergeinfo.c?rev=1182771&r1=1182770&r2=1182771&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_subr/mergeinfo.c Thu Oct 13 10:37:12 2011
@@ -78,7 +78,7 @@ combine_ranges(svn_merge_range_t *output
 static svn_error_t *
 parse_pathname(const char **input,
                const char *end,
-               svn_stringbuf_t **pathname,
+               const char **pathname,
                apr_pool_t *pool)
 {
   const char *curr = *input;
@@ -101,17 +101,11 @@ parse_pathname(const char **input,
     return svn_error_create(SVN_ERR_MERGEINFO_PARSE_ERROR, NULL,
                             _("No pathname preceding ':'"));
 
-  /* Tolerate relative repository paths, but convert them to absolute. */
-  if (**input == '/')
-    {
-      *pathname = svn_stringbuf_ncreate(*input, last_colon - *input, pool);
-    }
-  else
-    {
-      const char *repos_rel_path = apr_pstrndup(pool, *input,
-                                                last_colon - *input);
-      *pathname = svn_stringbuf_createf(pool, "/%s",  repos_rel_path);
-    }
+  /* Tolerate relative repository paths, but convert them to absolute.
+     ### Efficiency?  1 string duplication here, 2 in canonicalize. */
+  *pathname = svn_fspath__canonicalize(apr_pstrndup(pool, *input,
+                                                    last_colon - *input),
+                                       pool);
 
   *input = last_colon;
 
@@ -614,7 +608,7 @@ static svn_error_t *
 parse_revision_line(const char **input, const char *end, svn_mergeinfo_t hash,
                     apr_pool_t *scratch_pool)
 {
-  svn_stringbuf_t *pathname;
+  const char *pathname;
   apr_array_header_t *existing_rangelist;
   apr_array_header_t *rangelist = apr_array_make(scratch_pool, 1,
                                                  sizeof(svn_merge_range_t *));
@@ -627,7 +621,7 @@ parse_revision_line(const char **input, 
 
   *input = *input + 1;
 
-  SVN_ERR(parse_rangelist(input, end, rangelist, pathname->data, scratch_pool));
+  SVN_ERR(parse_rangelist(input, end, rangelist, pathname, scratch_pool));
 
   if (*input != end && *(*input) != '\n')
     return svn_error_createf(SVN_ERR_MERGEINFO_PARSE_ERROR, NULL,
@@ -695,12 +689,12 @@ parse_revision_line(const char **input, 
      leading slash, e.g. "trunk:4033\n/trunk:4039-4995".  In the event
      we encounter this we merge the rangelists together under a single
      absolute path key. */
-  existing_rangelist = apr_hash_get(hash, pathname->data, APR_HASH_KEY_STRING);
+  existing_rangelist = apr_hash_get(hash, pathname, APR_HASH_KEY_STRING);
   if (existing_rangelist)
     SVN_ERR(svn_rangelist_merge2(rangelist, existing_rangelist,
                                  scratch_pool, scratch_pool));
 
-  apr_hash_set(hash, apr_pstrdup(apr_hash_pool_get(hash), pathname->data),
+  apr_hash_set(hash, apr_pstrdup(apr_hash_pool_get(hash), pathname),
                APR_HASH_KEY_STRING,
                svn_rangelist_dup(rangelist, apr_hash_pool_get(hash)));
 

Modified: subversion/trunk/subversion/tests/libsvn_subr/mergeinfo-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/mergeinfo-test.c?rev=1182771&r1=1182770&r2=1182771&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/mergeinfo-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/mergeinfo-test.c Thu Oct 13 10:37:12 2011
@@ -117,7 +117,7 @@ verify_mergeinfo_parse(const char *input
    -> merge ranges. */
 static apr_hash_t *info1, *info2;
 
-#define NBR_MERGEINFO_VALS 20
+#define NBR_MERGEINFO_VALS 24
 
 /* Valid mergeinfo values. */
 static const char * const mergeinfo_vals[NBR_MERGEINFO_VALS] =
@@ -146,7 +146,12 @@ static const char * const mergeinfo_vals
     "/gunther_branch:7-12*,1,5-10*",
     /* Adjacent rangelists of differing inheritability. */
     "/b5:5-53,1-4,54-90*",
-    "/c0:1-77,12-44"
+    "/c0:1-77,12-44",
+    /* Non-canonical paths. */
+    "/A/:7-8",
+    "/A///:7-8",
+    "/A/.:7-8",
+    "/A/./B:7-8"
   };
 /* Paths corresponding to mergeinfo_vals. */
 static const char * const mergeinfo_paths[NBR_MERGEINFO_VALS] =
@@ -173,7 +178,13 @@ static const char * const mergeinfo_path
     "/gunther_branch",
     "/gunther_branch",
     "/b5",
-    "/c0"
+    "/c0",
+
+    /* non-canonical paths converted to canonical */
+    "/A",
+    "/A",
+    "/A",
+    "/A/B"
   };
 /* First ranges from the paths identified by mergeinfo_paths. */
 static svn_merge_range_t mergeinfo_ranges[NBR_MERGEINFO_VALS][MAX_NBR_RANGES] =
@@ -200,6 +211,10 @@ static svn_merge_range_t mergeinfo_range
     { {0, 1, TRUE}, {4, 12, FALSE} },
     { {0, 53, TRUE}, {53, 90, FALSE} },
     { {0, 77, TRUE} },
+    { {6, 8, TRUE} },
+    { {6, 8, TRUE} },
+    { {6, 8, TRUE} },
+    { {6, 8, TRUE} },
   };
 
 static svn_error_t *



Mime
View raw message