You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2011/01/24 21:00:27 UTC
svn commit: r1062948 - in
/subversion/branches/uris-as-urls/subversion/libsvn_ra_serf: commit.c
getlocks.c merge.c options.c property.c ra_serf.h serf.c update.c util.c
Author: cmpilato
Date: Mon Jan 24 20:00:26 2011
New Revision: 1062948
URL: http://svn.apache.org/viewvc?rev=1062948&view=rev
Log:
On the 'uris-as-urls' branch: Continue reviewing/reworking use of the
svn_uri_* APIs.
* subversion/libsvn_ra_serf/ra_serf.h
(svn_ra_serf__uri_basename, svn_ra_serf__uri_dirname,
svn_ra_serf__uri_get_longest_ancestor, svn_ra_serf__uri_is_ancestor,
svn_ra_serf__uri_is_canonical, svn_ra_serf__uri_is_child,
svn_ra_serf__uri_is_root, svn_ra_serf__uri_join,
svn_ra_serf__uri_skip_ancestor, svn_ra_serf__uri_split): New #defines.
(svn_ra_serf__uri_canonicalize): Replace this function with a new one.
* subversion/libsvn_ra_serf/util.c
(svn_ra_serf__uri_canonicalize): Replace the previous version of
this with a simpler version that doesn't accept relpaths. Callers
updated.
(svn_ra_serf__get_relative_path): Update use of svn_uri_* functions
to something else.
(svn_ra_serf__discover_vcc): Same as above. Also, fix what appears
to be a possibly endless looping condition (an is-empty check on a
path that will never be).
* subversion/libsvn_ra_serf/merge.c
(end_merge, svn_ra_serf__merge_lock_token_list): Update
use of svn_uri_* functions to something else, and update calls to
svn_ra_serf__uri_canonicalize().
* subversion/libsvn_ra_serf/commit.c
(setup_copy_dir_headers, delete_entry, add_directory, add_file):
Same as above.
* subversion/libsvn_ra_serf/serf.c
(path_dirent_walker, svn_ra_serf__get_dir): Same as above.
* subversion/libsvn_ra_serf/update.c
(end_report): Same as above.
* subversion/libsvn_ra_serf/getlocks.c
(end_getlocks): Same as above.
* subversion/libsvn_ra_serf/options.c
(capabilities_headers_iterator_callback): Update call to
svn_ra_serf__uri_canonicalize().
* subversion/libsvn_ra_serf/property.c
(end_propfind, svn_ra_serf__get_baseline_info): Update calls to
svn_ra_serf__uri_canonicalize().
Modified:
subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/commit.c
subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/getlocks.c
subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/merge.c
subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/options.c
subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/property.c
subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/ra_serf.h
subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/serf.c
subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/update.c
subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/util.c
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/commit.c?rev=1062948&r1=1062947&r2=1062948&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/commit.c Mon Jan 24 20:00:26 2011
@@ -311,8 +311,7 @@ handle_checkout(serf_request_t *request,
if (status)
err = svn_error_compose_create(svn_error_wrap_apr(status, NULL), err);
- ctx->resource_url = svn_ra_serf__uri_canonicalize(uri.path, pool,
- ctx->pool);
+ ctx->resource_url = svn_ra_serf__uri_canonicalize(uri.path, ctx->pool);
}
return err;
@@ -489,7 +488,7 @@ get_version_url(const char **checked_in_
if (current_version)
{
*checked_in_url =
- svn_ra_serf__uri_canonicalize(current_version->data, pool, pool);
+ svn_ra_serf__uri_canonicalize(current_version->data, pool);
return SVN_NO_ERROR;
}
}
@@ -544,7 +543,7 @@ get_version_url(const char **checked_in_
_("Path '%s' not present"),
session->repos_url.path);
- root_checkout = svn_ra_serf__uri_canonicalize(root_checkout, pool, pool);
+ root_checkout = svn_ra_serf__uri_canonicalize(root_checkout, pool);
}
*checked_in_url = svn_path_url_add_component2(root_checkout, relpath, pool);
@@ -1116,7 +1115,7 @@ setup_copy_dir_headers(serf_bucket_t *he
{
uri.path = (char *)svn_path_url_add_component2(
dir->parent_dir->checkout->resource_url,
- svn_uri_basename(dir->name, pool),
+ svn_relpath_basename(dir->name, pool),
pool);
}
absolute_uri = apr_uri_unparse(pool, &uri, 0);
@@ -1506,7 +1505,8 @@ delete_entry(const char *path,
/* Ensure our directory has been checked out */
SVN_ERR(checkout_dir(dir));
delete_target = svn_path_url_add_component2(dir->checkout->resource_url,
- svn_uri_basename(path, pool),
+ svn_relpath_basename(path,
+ pool),
pool);
}
@@ -1621,7 +1621,7 @@ add_directory(const char *path,
path, dir->pool);
mkcol_target = svn_path_url_add_component2(
parent->checkout->resource_url,
- svn_uri_basename(path, dir->pool),
+ svn_relpath_basename(path, dir->pool),
dir->pool);
}
@@ -1872,7 +1872,7 @@ add_file(const char *path,
new_file->url =
svn_path_url_add_component2(dir->checkout->resource_url,
- svn_uri_basename(path, new_file->pool),
+ svn_relpath_basename(path, new_file->pool),
new_file->pool);
}
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/getlocks.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/getlocks.c?rev=1062948&r1=1062947&r2=1062948&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/getlocks.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/getlocks.c Mon Jan 24 20:00:26 2011
@@ -203,10 +203,10 @@ 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_uri = svn_uri_is_child(lock_ctx->path,
- info->lock->path,
- info->pool);
- if (rel_uri && (svn_path_component_count(rel_uri) == 1))
+ const char *rel_path = svn_fspath__is_child(lock_ctx->path,
+ info->lock->path,
+ info->pool);
+ 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/branches/uris-as-urls/subversion/libsvn_ra_serf/merge.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/merge.c?rev=1062948&r1=1062947&r2=1062948&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/merge.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/merge.c Mon Jan 24 20:00:26 2011
@@ -297,7 +297,7 @@ end_merge(svn_ra_serf__xml_parser_t *par
const char *href;
href = apr_hash_get(info->props, "href", APR_HASH_KEY_STRING);
- if (! svn_uri_is_ancestor(ctx->merge_url, href))
+ if (! svn_ra_serf__uri_is_ancestor(ctx->merge_url, href))
{
/* ### need something better than APR_EGENERAL */
return svn_error_createf(APR_EGENERAL, NULL,
@@ -319,7 +319,7 @@ end_merge(svn_ra_serf__xml_parser_t *par
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_uri_is_child(ctx->merge_url, href, NULL);
+ href = svn_ra_serf__uri_is_child(ctx->merge_url, href, NULL);
if (! href)
href = "";
@@ -364,8 +364,8 @@ end_merge(svn_ra_serf__xml_parser_t *par
info->prop_val = apr_pstrmemdup(info->pool, info->prop_val,
info->prop_val_len);
if (strcmp(info->prop_name, "href") == 0)
- info->prop_val = svn_ra_serf__uri_canonicalize(info->prop_val,
- info->pool, info->pool);
+ info->prop_val = svn_ra_serf__uri_canonicalize(info->prop_val,
+ info->pool);
/* Set our property. */
apr_hash_set(info->props, info->prop_name, APR_HASH_KEY_STRING,
@@ -453,7 +453,7 @@ svn_ra_serf__merge_lock_token_list(apr_h
path.data = key;
path.len = klen;
- if (parent && !svn_uri_is_ancestor(parent, key))
+ if (parent && !svn_ra_serf__uri_is_ancestor(parent, key))
continue;
svn_ra_serf__add_open_tag_buckets(body, alloc, "S:lock", NULL);
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/options.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/options.c?rev=1062948&r1=1062947&r2=1062948&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/options.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/options.c Mon Jan 24 20:00:26 2011
@@ -187,9 +187,7 @@ end_options(svn_ra_serf__xml_parser_t *p
{
options_ctx->collect_cdata = FALSE;
options_ctx->activity_collection =
- svn_ra_serf__uri_canonicalize(options_ctx->attr_val,
- options_ctx->pool,
- options_ctx->pool);
+ svn_ra_serf__uri_canonicalize(options_ctx->attr_val, options_ctx->pool);
pop_state(options_ctx);
}
@@ -342,7 +340,6 @@ capabilities_headers_iterator_callback(v
apr_uri_unparse(orc->session->pool,
&orc->session->repos_root,
0),
- orc->session->pool,
orc->session->pool);
}
else if (svn_cstring_casecmp(key, SVN_DAV_ME_RESOURCE_HEADER) == 0)
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/property.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/property.c?rev=1062948&r1=1062947&r2=1062948&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/property.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/property.c Mon Jan 24 20:00:26 2011
@@ -344,7 +344,7 @@ end_propfind(svn_ra_serf__xml_parser_t *
if (strcmp(ctx->depth, "1") == 0)
{
ctx->current_path =
- svn_ra_serf__uri_canonicalize(info->val, ctx->pool, ctx->pool);
+ svn_ra_serf__uri_canonicalize(info->val, ctx->pool);
}
else
{
@@ -1034,8 +1034,7 @@ svn_ra_serf__get_baseline_info(const cha
"the requested checked-in value"));
}
- baseline_url = svn_ra_serf__uri_canonicalize(baseline_url,
- pool, pool);
+ baseline_url = svn_ra_serf__uri_canonicalize(baseline_url, pool);
SVN_ERR(svn_ra_serf__retrieve_props(props, session, conn,
baseline_url, revision, "0",
@@ -1052,8 +1051,7 @@ svn_ra_serf__get_baseline_info(const cha
"requested baseline-collection value"));
}
- basecoll_url = svn_ra_serf__uri_canonicalize(basecoll_url,
- pool, pool);
+ basecoll_url = svn_ra_serf__uri_canonicalize(basecoll_url, pool);
if (latest_revnum)
{
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/ra_serf.h
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/ra_serf.h?rev=1062948&r1=1062947&r2=1062948&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/ra_serf.h Mon Jan 24 20:00:26 2011
@@ -36,6 +36,7 @@
#include "svn_delta.h"
#include "svn_version.h"
#include "svn_dav.h"
+#include "svn_dirent_uri.h"
#include "private/svn_dav_protocol.h"
@@ -63,6 +64,27 @@ extern "C" {
#endif
+/* A faux fspath API used inside this library to help us distinguish
+ * between real URI-decoded fspaths and URI-encoded URL path-portions.
+ */
+#define svn_ra_serf__uri_basename svn_fspath__basename
+#define svn_ra_serf__uri_dirname svn_fspath__dirname
+#define svn_ra_serf__uri_get_longest_ancestor svn_fspath__get_longest_ancestor
+#define svn_ra_serf__uri_is_ancestor svn_fspath__is_ancestor
+#define svn_ra_serf__uri_is_canonical svn_fspath__is_canonical
+#define svn_ra_serf__uri_is_child svn_fspath__is_child
+#define svn_ra_serf__uri_is_root svn_fspath__is_root
+#define svn_ra_serf__uri_join svn_fspath__join
+#define svn_ra_serf__uri_skip_ancestor svn_fspath__skip_ancestor
+#define svn_ra_serf__uri_split svn_fspath__split
+
+/* Like svn_fspath__canonicalize(), but this one accepts both full
+ URLs and URL path-portions. */
+const char *
+svn_ra_serf__uri_canonicalize(const char *uri,
+ apr_pool_t *pool);
+
+
/* Forward declarations. */
typedef struct svn_ra_serf__session_t svn_ra_serf__session_t;
typedef struct svn_ra_serf__auth_protocol_t svn_ra_serf__auth_protocol_t;
@@ -800,10 +822,6 @@ svn_ra_serf__response_get_location(serf_
* URI-encoded identifier of *some sort*, as will be the returned form
* thereof.
*/
-const char *
-svn_ra_serf__uri_canonicalize(const char *uri,
- apr_pool_t *scratch_pool,
- apr_pool_t *result_pool);
/** XML helper functions. **/
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/serf.c?rev=1062948&r1=1062947&r2=1062948&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/serf.c Mon Jan 24 20:00:26 2011
@@ -773,7 +773,8 @@ path_dirent_walker(void *baton,
apr_hash_set(dirents->full_paths, path, path_len, entry);
- base_name = svn_path_uri_decode(svn_uri_basename(path, pool), pool);
+ base_name = svn_path_uri_decode(svn_ra_serf__uri_basename(path, pool),
+ pool);
apr_hash_set(dirents->base_paths, base_name, APR_HASH_KEY_STRING, entry);
}
@@ -906,7 +907,7 @@ svn_ra_serf__get_dir(svn_ra_session_t *r
*/
dirent_walk.full_paths = apr_hash_make(pool);
dirent_walk.base_paths = apr_hash_make(pool);
- dirent_walk.orig_path = svn_ra_serf__uri_canonicalize(path, pool, pool);
+ dirent_walk.orig_path = svn_ra_serf__uri_canonicalize(path, pool);
SVN_ERR(svn_ra_serf__walk_all_paths(props, revision, path_dirent_walker,
&dirent_walk, pool));
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/update.c?rev=1062948&r1=1062947&r2=1062948&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/update.c Mon Jan 24 20:00:26 2011
@@ -1794,8 +1794,11 @@ end_report(svn_ra_serf__xml_parser_t *pa
if (SVN_RA_SERF__HAVE_HTTPV2_SUPPORT(ctx->sess))
{
const char *fs_path;
- const char *full_path = svn_uri_join(ctx->sess->repos_url.path,
- info->name, info->pool);
+ const char *full_path =
+ svn_fspath__join(ctx->sess->repos_url.path,
+ svn_path_uri_encode(info->name, info->pool),
+ info->pool);
+
SVN_ERR(svn_ra_serf__get_relative_path(&fs_path, full_path,
ctx->sess, NULL, info->pool));
info->delta_base = svn_string_createf(info->pool, "%s/%ld/%s",
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/util.c?rev=1062948&r1=1062947&r2=1062948&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_serf/util.c Mon Jan 24 20:00:26 2011
@@ -914,7 +914,7 @@ svn_ra_serf__response_get_location(serf_
headers = serf_bucket_response_get_headers(response);
val = serf_bucket_headers_get(headers, "Location");
- return val ? svn_ra_serf__uri_canonicalize(val, pool, pool) : NULL;
+ return val ? svn_ra_serf__uri_canonicalize(val, pool) : NULL;
}
/* Implements svn_ra_serf__response_handler_t */
@@ -1745,7 +1745,7 @@ svn_ra_serf__discover_vcc(const char **v
apr_pool_t *pool)
{
apr_hash_t *props;
- const char *path, *relative_path, *present_path = "", *uuid;
+ const char *path, *relative_path, *uuid;
/* If we've already got the information our caller seeks, just return it. */
if (session->vcc_url && session->repos_root_str)
@@ -1800,14 +1800,13 @@ svn_ra_serf__discover_vcc(const char **v
/* This happens when the file is missing in HEAD. */
svn_error_clear(err);
- /* Okay, strip off. */
- present_path = svn_uri_join(svn_uri_basename(path, pool),
- present_path, pool);
- path = svn_uri_dirname(path, pool);
+ /* Okay, strip off a component from PATH. */
+ path = svn_ra_serf__uri_dirname(path, pool);
}
}
}
- while (!svn_path_is_empty(path));
+ while ((path[0] != '\0')
+ && (! (path[0] == '/') && (path[1] == '\0')));
if (!*vcc_url)
{
@@ -1839,7 +1838,7 @@ svn_ra_serf__discover_vcc(const char **v
session->repos_root_str =
svn_ra_serf__uri_canonicalize(apr_uri_unparse(session->pool,
&session->repos_root, 0),
- pool, session->pool);
+ session->pool);
}
/* Store the repository UUID in the cache. */
@@ -1884,7 +1883,7 @@ svn_ra_serf__get_relative_path(const cha
}
else
{
- *rel_path = svn_uri_is_child(decoded_root, decoded_orig, pool);
+ *rel_path = svn_ra_serf__uri_is_child(decoded_root, decoded_orig, pool);
SVN_ERR_ASSERT(*rel_path != NULL);
}
return SVN_NO_ERROR;
@@ -1936,33 +1935,19 @@ svn_ra_serf__error_on_status(int status_
}
-static const char *
-relative_uri_normalize(const char *relpath,
- apr_pool_t *scratch_pool,
- apr_pool_t *result_pool)
-{
- return svn_path_uri_encode(
- svn_relpath_canonicalize(
- svn_path_uri_decode(relpath, scratch_pool),
- scratch_pool),
- result_pool);
-}
-
-
const char *
svn_ra_serf__uri_canonicalize(const char *uri,
- apr_pool_t *scratch_pool,
- apr_pool_t *result_pool)
+ apr_pool_t *pool)
{
if (svn_path_is_url(uri))
- return svn_uri_canonicalize(uri, result_pool);
-
- if (uri[0] == '/')
- return apr_pstrcat(result_pool, "/",
- relative_uri_normalize(uri + 1,
- scratch_pool,
- scratch_pool),
- NULL);
-
- return relative_uri_normalize(uri, scratch_pool, result_pool);
+ {
+ uri = svn_url_canonicalize(uri, pool);
+ }
+ else
+ {
+ uri = svn_fspath__canonicalize(uri, pool);
+ uri = svn_path_uri_decode(uri, pool);
+ uri = svn_path_uri_encode(uri, pool);
+ }
+ return uri;
}