You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2011/10/25 17:56:51 UTC

svn commit: r1188747 - in /subversion/trunk/subversion: include/private/ libsvn_fs_base/ libsvn_fs_base/bdb/ libsvn_fs_fs/ libsvn_ra_neon/ libsvn_ra_serf/ libsvn_ra_svn/ libsvn_repos/ libsvn_subr/ tests/libsvn_subr/

Author: julianfoad
Date: Tue Oct 25 15:56:50 2011
New Revision: 1188747

URL: http://svn.apache.org/viewvc?rev=1188747&view=rev
Log:
Eliminate svn_fspath__is_child() and svn_urlpath__is_child(); use
svn_fspath__skip_ancestor() and svn_urlpath__skip_ancestor() instead.

* subversion/include/private/svn_fspath.h
  (svn_fspath__is_child, svn_urlpath__is_child): Remove.

* subversion/libsvn_subr/dirent_uri.c
  (svn_fspath__is_child): Remove.

* subversion/libsvn_fs_base/bdb/changes-table.c
  (svn_fs_bdb__changes_fetch): Use __skip_ancestor; check for "".

* subversion/libsvn_fs_base/bdb/locks-table.c
  (svn_fs_bdb__locks_get): Use __skip_ancestor; no check for "" needed.

* subversion/libsvn_fs_base/tree.c
  (verify_locks, txn_body_history_prev, prev_location): Use __skip_ancestor;
    eliminate special-casing of "".

* subversion/libsvn_fs_fs/lock.c
  (get_locks_filter_func): Use __skip_ancestor; no check for "" needed.

* subversion/libsvn_ra_neon/get_locks.c
  (getlocks_end_element): Use __skip_ancestor; no check for "" needed.
    Don't clear the scratch pool, as that was only done because the
    _is_child call used it.

* subversion/libsvn_ra_neon/merge.c
  (handle_resource): Use __skip_ancestor; eliminate special-casing of "".

* subversion/libsvn_ra_serf/getlocks.c
  (end_getlocks): Use __skip_ancestor; no check for "" needed.

* subversion/libsvn_ra_serf/merge.c
  (end_merge): Use __skip_ancestor; eliminate special-casing of "". Fix
    typos in comment.

* subversion/libsvn_ra_serf/util.c
  (svn_ra_serf__get_relative_path): Use __skip_ancestor; eliminate
    special-casing of "".

* subversion/libsvn_ra_svn/client.c
  (ra_svn_get_locks): Use __skip_ancestor; no check for "" needed.

* subversion/libsvn_repos/rev_hunt.c
  (svn_repos__prev_location): Use __skip_ancestor; eliminate
    special-casing of "".

* subversion/tests/libsvn_subr/dirent_uri-test.c
  (test_fspath_is_child): Rename to 'test_fspath_skip_ancestor' and update
    to test svn_fspath__skip_ancestor() instead, which was untested.
  (test_funcs): Update the name and description of that test.

Modified:
    subversion/trunk/subversion/include/private/svn_fspath.h
    subversion/trunk/subversion/libsvn_fs_base/bdb/changes-table.c
    subversion/trunk/subversion/libsvn_fs_base/bdb/locks-table.c
    subversion/trunk/subversion/libsvn_fs_base/tree.c
    subversion/trunk/subversion/libsvn_fs_fs/lock.c
    subversion/trunk/subversion/libsvn_ra_neon/get_locks.c
    subversion/trunk/subversion/libsvn_ra_neon/merge.c
    subversion/trunk/subversion/libsvn_ra_serf/getlocks.c
    subversion/trunk/subversion/libsvn_ra_serf/merge.c
    subversion/trunk/subversion/libsvn_ra_serf/util.c
    subversion/trunk/subversion/libsvn_ra_svn/client.c
    subversion/trunk/subversion/libsvn_repos/rev_hunt.c
    subversion/trunk/subversion/libsvn_subr/dirent_uri.c
    subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c

Modified: subversion/trunk/subversion/include/private/svn_fspath.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_fspath.h?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_fspath.h (original)
+++ subversion/trunk/subversion/include/private/svn_fspath.h Tue Oct 25 15:56:50 2011
@@ -123,23 +123,6 @@ svn_boolean_t
 svn_fspath__is_root(const char *fspath,
                     apr_size_t len);
 
-/** Test if @a child_fspath is a child of @a parent_fspath.  If not, return
- * NULL.  If so, return the relpath which, if joined to @a parent_fspath,
- * would yield @a child_fspath.
- *
- * If @a child_fspath is the same as @a parent_fspath, it is not considered
- * a child, so the result is NULL; an empty string is never returned.
- *
- * If @a pool is NULL, a pointer into @a child_fspath will be returned to
- * identify the remainder fspath.
- *
- * @since New in 1.7.
- */
-const char *
-svn_fspath__is_child(const char *parent_fspath,
-                     const char *child_fspath,
-                     apr_pool_t *pool);
-
 /** Return the relative path part of @a child_fspath that is below
  * @a parent_fspath, or just "" if @a parent_fspath is equal to
  * @a child_fspath. If @a child_fspath is not below @a parent_fspath
@@ -171,7 +154,6 @@ svn_fspath__get_longest_ancestor(const c
 #define svn_urlpath__dirname              svn_fspath__dirname
 #define svn_urlpath__get_longest_ancestor svn_fspath__get_longest_ancestor
 #define svn_urlpath__is_canonical         svn_fspath__is_canonical
-#define svn_urlpath__is_child             svn_fspath__is_child
 #define svn_urlpath__is_root              svn_fspath__is_root
 #define svn_urlpath__join                 svn_fspath__join
 #define svn_urlpath__skip_ancestor        svn_fspath__skip_ancestor

Modified: subversion/trunk/subversion/libsvn_fs_base/bdb/changes-table.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_base/bdb/changes-table.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_base/bdb/changes-table.c (original)
+++ subversion/trunk/subversion/libsvn_fs_base/bdb/changes-table.c Tue Oct 25 15:56:50 2011
@@ -325,14 +325,14 @@ svn_fs_bdb__changes_fetch(apr_hash_t **c
               /* KEY is the path. */
               const void *hashkey;
               apr_ssize_t klen;
-              apr_hash_this(hi, &hashkey, &klen, NULL);
+              const char *child_relpath;
 
-              /* If we come across our own path, ignore it. */
-              if (strcmp(change->path, hashkey) == 0)
-                continue;
+              apr_hash_this(hi, &hashkey, &klen, NULL);
 
-              /* If we come across a child of our path, remove it. */
-              if (svn_fspath__is_child(change->path, hashkey, subpool))
+              /* If we come across our own path, ignore it.
+                 If we come across a child of our path, remove it. */
+              child_relpath = svn_fspath__skip_ancestor(change->path, hashkey);
+              if (child_relpath && *child_relpath)
                 apr_hash_set(changes, hashkey, klen, NULL);
             }
         }

Modified: subversion/trunk/subversion/libsvn_fs_base/bdb/locks-table.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_base/bdb/locks-table.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_base/bdb/locks-table.c (original)
+++ subversion/trunk/subversion/libsvn_fs_base/bdb/locks-table.c Tue Oct 25 15:56:50 2011
@@ -274,7 +274,7 @@ svn_fs_bdb__locks_get(svn_fs_t *fs,
              same set of results.  So just see if CHILD_PATH is an
              immediate child of PATH.  If not, we don't care about
              this item.   */
-          const char *rel_path = svn_fspath__is_child(path, child_path, subpool);
+          const char *rel_path = svn_fspath__skip_ancestor(path, child_path);
           if (!rel_path || (svn_path_component_count(rel_path) != 1))
             goto loop_it;
         }

Modified: subversion/trunk/subversion/libsvn_fs_base/tree.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_base/tree.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_base/tree.c (original)
+++ subversion/trunk/subversion/libsvn_fs_base/tree.c Tue Oct 25 15:56:50 2011
@@ -2523,7 +2523,7 @@ verify_locks(const char *txn_name,
       /* If this path has already been verified as part of a recursive
          check of one of its parents, no need to do it again.  */
       if (last_recursed
-          && svn_fspath__is_child(last_recursed->data, path, subpool))
+          && svn_fspath__skip_ancestor(last_recursed->data, path))
         continue;
 
       /* Fetch the change associated with our path.  */
@@ -4349,10 +4349,7 @@ txn_body_history_prev(void *baton, trail
          the copy source.  Finally, if our current path doesn't meet
          one of these other criteria ... ### for now just fallback to
          the old copy hunt algorithm. */
-      if (strcmp(path, copy_dst) == 0)
-        remainder = "";
-      else
-        remainder = svn_fspath__is_child(copy_dst, path, trail->pool);
+      remainder = svn_fspath__skip_ancestor(copy_dst, path);
 
       if (remainder)
         {
@@ -4745,7 +4742,7 @@ prev_location(const char **prev_path,
               const char *path,
               apr_pool_t *pool)
 {
-  const char *copy_path, *copy_src_path, *remainder = "";
+  const char *copy_path, *copy_src_path, *remainder;
   svn_fs_root_t *copy_root;
   svn_revnum_t copy_src_rev;
 
@@ -4774,8 +4771,7 @@ prev_location(const char **prev_path,
   */
   SVN_ERR(base_copied_from(&copy_src_rev, &copy_src_path,
                            copy_root, copy_path, pool));
-  if (! strcmp(copy_path, path) == 0)
-    remainder = svn_fspath__is_child(copy_path, path, pool);
+  remainder = svn_fspath__skip_ancestor(copy_path, path);
   *prev_path = svn_fspath__join(copy_src_path, remainder, pool);
   *prev_rev = copy_src_rev;
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_fs_fs/lock.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/lock.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/lock.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/lock.c Tue Oct 25 15:56:50 2011
@@ -1036,7 +1036,7 @@ get_locks_filter_func(void *baton,
   else if ((b->requested_depth == svn_depth_files) ||
            (b->requested_depth == svn_depth_immediates))
     {
-      const char *rel_uri = svn_fspath__is_child(b->path, lock->path, pool);
+      const char *rel_uri = svn_fspath__skip_ancestor(b->path, lock->path);
       if (rel_uri && (svn_path_component_count(rel_uri) == 1))
         SVN_ERR(b->get_locks_func(b->get_locks_baton, lock, pool));
     }

Modified: subversion/trunk/subversion/libsvn_ra_neon/get_locks.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_neon/get_locks.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_neon/get_locks.c (original)
+++ subversion/trunk/subversion/libsvn_ra_neon/get_locks.c Tue Oct 25 15:56:50 2011
@@ -257,13 +257,11 @@ getlocks_end_element(void *userdata, int
       else if ((baton->requested_depth == svn_depth_files) ||
                (baton->requested_depth == svn_depth_immediates))
         {
-          const char *rel_uri = svn_fspath__is_child(baton->path,
-                                                     baton->current_lock->path,
-                                                     baton->scratchpool);
+          const char *rel_uri = svn_fspath__skip_ancestor(
+                                  baton->path, baton->current_lock->path);
           if (rel_uri && (svn_path_component_count(rel_uri) == 1))
             apr_hash_set(baton->lock_hash, baton->current_lock->path,
                          APR_HASH_KEY_STRING, baton->current_lock);
-          svn_pool_clear(baton->scratchpool);
         }
       break;
 

Modified: subversion/trunk/subversion/libsvn_ra_neon/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_neon/merge.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_neon/merge.c (original)
+++ subversion/trunk/subversion/libsvn_ra_neon/merge.c Tue Oct 25 15:56:50 2011
@@ -269,9 +269,7 @@ static svn_error_t * handle_resource(mer
     }
 
   /* given HREF of the form: BASE "/" RELATIVE, extract the relative portion */
-  relative = svn_urlpath__is_child(mc->base_href, mc->href->data, NULL);
-  if (! relative) /* the paths are equal */
-    relative = "";
+  relative = svn_urlpath__skip_ancestor(mc->base_href, mc->href->data);
 
   /* bump the resource */
   relative = svn_path_uri_decode(relative, pool);

Modified: subversion/trunk/subversion/libsvn_ra_serf/getlocks.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/getlocks.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/getlocks.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/getlocks.c Tue Oct 25 15:56:50 2011
@@ -200,9 +200,8 @@ end_getlocks(svn_ra_serf__xml_parser_t *
       else if ((lock_ctx->requested_depth == svn_depth_files) ||
                (lock_ctx->requested_depth == svn_depth_immediates))
         {
-          const char *rel_path = svn_fspath__is_child(lock_ctx->path,
-                                                      info->lock->path,
-                                                      info->pool);
+          const char *rel_path = svn_fspath__skip_ancestor(lock_ctx->path,
+                                                           info->lock->path);
           if (rel_path && (svn_path_component_count(rel_path) == 1))
             apr_hash_set(lock_ctx->hash, info->lock->path,
                          APR_HASH_KEY_STRING, info->lock);

Modified: subversion/trunk/subversion/libsvn_ra_serf/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/merge.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/merge.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/merge.c Tue Oct 25 15:56:50 2011
@@ -311,11 +311,9 @@ end_merge(svn_ra_serf__xml_parser_t *par
 
               /* From the above check, we know that CTX->MERGE_URL is
                  an ancestor of HREF.  All that remains is to
-                 determine of HREF is the same as CTX->MERGE_URL, or --
-                 if not -- is relative value as a child thereof. */
-              href = svn_urlpath__is_child(ctx->merge_url, href, NULL);
-              if (! href)
-                href = "";
+                 determine if HREF is the same as CTX->MERGE_URL, or --
+                 if not -- its relative value as a child thereof. */
+              href = svn_urlpath__skip_ancestor(ctx->merge_url, href);
 
               checked_in = apr_hash_get(info->props, "checked-in",
                                         APR_HASH_KEY_STRING);

Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Tue Oct 25 15:56:50 2011
@@ -2408,15 +2408,8 @@ svn_ra_serf__get_relative_path(const cha
 
   decoded_root = svn_path_uri_decode(session->repos_root.path, pool);
   decoded_orig = svn_path_uri_decode(orig_path, pool);
-  if (strcmp(decoded_root, decoded_orig) == 0)
-    {
-      *rel_path = "";
-    }
-  else
-    {
-      *rel_path = svn_urlpath__is_child(decoded_root, decoded_orig, pool);
-      SVN_ERR_ASSERT(*rel_path != NULL);
-    }
+  *rel_path = svn_urlpath__skip_ancestor(decoded_root, decoded_orig);
+  SVN_ERR_ASSERT(*rel_path != NULL);
   return SVN_NO_ERROR;
 }
 

Modified: subversion/trunk/subversion/libsvn_ra_svn/client.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/client.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/client.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/client.c Tue Oct 25 15:56:50 2011
@@ -2340,7 +2340,7 @@ static svn_error_t *ra_svn_get_locks(svn
         }
       else if ((depth == svn_depth_files) || (depth == svn_depth_immediates))
         {
-          const char *relpath = svn_fspath__is_child(abs_path, lock->path, pool);
+          const char *relpath = svn_fspath__skip_ancestor(abs_path, lock->path);
           if (relpath && (svn_path_component_count(relpath) == 1))
             apr_hash_set(*locks, lock->path, APR_HASH_KEY_STRING, lock);
         }

Modified: subversion/trunk/subversion/libsvn_repos/rev_hunt.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/rev_hunt.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/rev_hunt.c (original)
+++ subversion/trunk/subversion/libsvn_repos/rev_hunt.c Tue Oct 25 15:56:50 2011
@@ -590,7 +590,7 @@ svn_repos__prev_location(svn_revnum_t *a
                          apr_pool_t *pool)
 {
   svn_fs_root_t *root, *copy_root;
-  const char *copy_path, *copy_src_path, *remainder = "";
+  const char *copy_path, *copy_src_path, *remainder;
   svn_revnum_t copy_src_rev;
 
   /* Initialize return variables. */
@@ -623,8 +623,7 @@ svn_repos__prev_location(svn_revnum_t *a
   */
   SVN_ERR(svn_fs_copied_from(&copy_src_rev, &copy_src_path,
                              copy_root, copy_path, pool));
-  if (! strcmp(copy_path, path) == 0)
-    remainder = svn_fspath__is_child(copy_path, path, pool);
+  remainder = svn_fspath__skip_ancestor(copy_path, path);
   if (prev_path)
     *prev_path = svn_fspath__join(copy_src_path, remainder, pool);
   if (appeared_rev)

Modified: subversion/trunk/subversion/libsvn_subr/dirent_uri.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/dirent_uri.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/dirent_uri.c (original)
+++ subversion/trunk/subversion/libsvn_subr/dirent_uri.c Tue Oct 25 15:56:50 2011
@@ -2442,21 +2442,6 @@ svn_fspath__is_root(const char *fspath, 
 
 
 const char *
-svn_fspath__is_child(const char *parent_fspath,
-                     const char *child_fspath,
-                     apr_pool_t *pool)
-{
-  const char *result;
-  assert(svn_fspath__is_canonical(parent_fspath));
-  assert(svn_fspath__is_canonical(child_fspath));
-
-  result = is_child(type_relpath, parent_fspath + 1, child_fspath + 1, pool);
-
-  assert(result == NULL || svn_relpath_is_canonical(result));
-  return result;
-}
-
-const char *
 svn_fspath__skip_ancestor(const char *parent_fspath,
                           const char *child_fspath)
 {

Modified: subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c?rev=1188747&r1=1188746&r2=1188747&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c Tue Oct 25 15:56:50 2011
@@ -2587,7 +2587,7 @@ test_fspath_join(apr_pool_t *pool)
 }
 
 static svn_error_t *
-test_fspath_is_child(apr_pool_t *pool)
+test_fspath_skip_ancestor(apr_pool_t *pool)
 {
   int i, j;
 
@@ -2602,12 +2602,12 @@ test_fspath_is_child(apr_pool_t *pool)
 
   static const char * const
     remainders[COUNT_OF(paths)][COUNT_OF(paths)] = {
-    { 0,  "f",  "foo",  "foo/bar",  "foo/bars", "foo/bar/baz" },
-    { 0,  0,    0,      0,          0,          0             },
-    { 0,  0,    0,      "bar",      "bars",     "bar/baz"     },
-    { 0,  0,    0,      0,          0,          "baz"         },
-    { 0,  0,    0,      0,          0,          0             },
-    { 0,  0,    0,      0,          0,          0             },
+    { "", "f",  "foo",  "foo/bar",  "foo/bars", "foo/bar/baz" },
+    { 0,  "",   0,      0,          0,          0             },
+    { 0,  0,    "",     "bar",      "bars",     "bar/baz"     },
+    { 0,  0,    0,      "",         0,          "baz"         },
+    { 0,  0,    0,      0,          "",         0             },
+    { 0,  0,    0,      0,          0,          ""            },
   };
 
   for (i = 0; i < COUNT_OF(paths); i++)
@@ -2615,7 +2615,7 @@ test_fspath_is_child(apr_pool_t *pool)
       for (j = 0; j < COUNT_OF(paths); j++)
         {
           const char *remainder
-            = svn_fspath__is_child(paths[i], paths[j], pool);
+            = svn_fspath__skip_ancestor(paths[i], paths[j]);
 
           SVN_TEST_STRING_ASSERT(remainder, remainders[i][j]);
         }
@@ -2802,8 +2802,8 @@ struct svn_test_descriptor_t test_funcs[
                    "test svn_fspath__is_canonical"),
     SVN_TEST_PASS2(test_fspath_join,
                    "test svn_fspath__join"),
-    SVN_TEST_PASS2(test_fspath_is_child,
-                   "test svn_fspath__is_child"),
+    SVN_TEST_PASS2(test_fspath_skip_ancestor,
+                   "test svn_fspath__skip_ancestor"),
     SVN_TEST_PASS2(test_fspath_dirname_basename_split,
                    "test svn_fspath__dirname/basename/split"),
     SVN_TEST_PASS2(test_fspath_get_longest_ancestor,