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/21 22:45:41 UTC
svn commit: r1062039 - in
/subversion/branches/uris-as-urls/subversion/libsvn_ra_neon: fetch.c
get_locks.c options.c props.c ra_neon.h util.c
Author: cmpilato
Date: Fri Jan 21 21:45:41 2011
New Revision: 1062039
URL: http://svn.apache.org/viewvc?rev=1062039&view=rev
Log:
On the 'uris-as-urls' branch, review and correct some use of the
svn_uri_* APIs. (One step of many similar ones.)
* subversion/libsvn_ra_neon/fetch.c
(svn_ra_neon__get_dir): Review/correct/rename uses of the svn_uri_* APIs.
* subversion/libsvn_ra_neon/get_locks.c
(get_locks_baton_t): Comment tweak.
(getlocks_end_element, svn_ra_neon__get_locks):
Review/correct/rename uses of the svn_uri_* APIs.
* subversion/libsvn_ra_neon/options.c
(end_element): Now use svn_ra_neon__uri_canonicalize().
* subversion/libsvn_ra_neon/ra_neon.h,
* subversion/libsvn_ra_neon/util.c
(svn_ra_neon__request_get_location): Now use
svn_ra_neon__uri_canonicalize().
(svn_ra_neon__uri_canonicalize): New function.
* subversion/libsvn_ra_neon/props.c
(end_element): Now use svn_ra_neon__uri_canonicalize().
(svn_ra_neon__search_for_starting_props): Avoid using svn_uri_* for
non-URLs.
Modified:
subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/fetch.c
subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/get_locks.c
subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/options.c
subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/props.c
subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/ra_neon.h
subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/util.c
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/fetch.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/fetch.c?rev=1062039&r1=1062038&r2=1062039&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/fetch.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/fetch.c Fri Jan 21 21:45:41 2011
@@ -944,7 +944,7 @@ svn_error_t *svn_ra_neon__get_dir(svn_ra
svn_dirent_t *entry;
apr_hash_this(hi, &key, NULL, &val);
- childname = key;
+ childname = svn_relpath_canonicalize(key, pool);
resource = val;
/* Skip the effective '.' entry that comes back from
@@ -1051,7 +1051,8 @@ svn_error_t *svn_ra_neon__get_dir(svn_ra
}
apr_hash_set(*dirents,
- svn_path_uri_decode(svn_uri_basename(childname, pool),
+ svn_path_uri_decode(svn_relpath_basename(childname,
+ pool),
pool),
APR_HASH_KEY_STRING, entry);
}
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/get_locks.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/get_locks.c?rev=1062039&r1=1062038&r2=1062039&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/get_locks.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/get_locks.c Fri Jan 21 21:45:41 2011
@@ -121,7 +121,7 @@ static const svn_ra_neon__xml_elm_t getl
/* Context for parsing server's response. */
typedef struct get_locks_baton_t {
- const char *path; /* target of the report */
+ const char *path; /* fspath target of the report */
svn_depth_t requested_depth; /* requested depth of the report */
svn_lock_t *current_lock; /* the lock being constructed */
svn_stringbuf_t *cdata_accum; /* a place to accumulate cdata */
@@ -256,9 +256,9 @@ 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_uri_is_child(baton->path,
- baton->current_lock->path,
- baton->scratchpool);
+ const char *rel_uri = svn_fspath__is_child(baton->path,
+ baton->current_lock->path,
+ baton->scratchpool);
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);
@@ -268,9 +268,12 @@ getlocks_end_element(void *userdata, int
case ELEM_lock_path:
/* neon has already xml-unescaped the cdata for us. */
- baton->current_lock->path = apr_pstrmemdup(baton->pool,
- baton->cdata_accum->data,
- baton->cdata_accum->len);
+ baton->current_lock->path =
+ svn_fspath__canonicalize(apr_pstrmemdup(baton->scratchpool,
+ baton->cdata_accum->data,
+ baton->cdata_accum->len),
+ baton->pool);
+
/* clean up the accumulator. */
svn_stringbuf_setempty(baton->cdata_accum);
svn_pool_clear(baton->scratchpool);
@@ -379,7 +382,7 @@ svn_ra_neon__get_locks(svn_ra_session_t
url, pool));
baton.lock_hash = apr_hash_make(pool);
- baton.path = apr_pstrcat(pool, "/", rel_path, (char *)NULL);
+ baton.path = svn_fspath__canonicalize(rel_path, pool);
baton.requested_depth = depth;
baton.pool = pool;
baton.scratchpool = svn_pool_create(pool);
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/options.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/options.c?rev=1062039&r1=1062038&r2=1062039&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/options.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/options.c Fri Jan 21 21:45:41 2011
@@ -108,9 +108,11 @@ end_element(void *baton, int state,
options_ctx_t *oc = baton;
if (state == ELEM_href)
- oc->activity_coll = svn_string_create(svn_uri_canonicalize(oc->cdata->data,
- oc->pool),
- oc->pool);
+ oc->activity_coll =
+ svn_string_create(svn_ra_neon__uri_canonicalize(oc->cdata->data,
+ oc->pool,
+ oc->pool),
+ oc->pool);
return SVN_NO_ERROR;
}
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/props.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/props.c?rev=1062039&r1=1062038&r2=1062039&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/props.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/props.c Fri Jan 21 21:45:41 2011
@@ -413,7 +413,10 @@ static svn_error_t * end_element(void *b
case ELEM_href:
/* Special handling for <href> that belongs to the <response> tag. */
if (rsrc->href_parent == ELEM_response)
- return assign_rsrc_url(pc->rsrc, svn_uri_canonicalize(cdata, pc->pool),
+ return assign_rsrc_url(pc->rsrc,
+ svn_ra_neon__uri_canonicalize(cdata,
+ pc->pool,
+ pc->pool),
pc->pool);
/* Use the parent element's name, not the href. */
@@ -425,7 +428,9 @@ static svn_error_t * end_element(void *b
/* All other href's we'll treat as property values. */
name = parent_defn->name;
- value = svn_string_create(svn_uri_canonicalize(cdata, pc->pool),
+ value = svn_string_create(svn_ra_neon__uri_canonicalize(cdata,
+ pc->pool,
+ pc->pool),
pc->pool);
break;
@@ -723,8 +728,10 @@ svn_ra_neon__search_for_starting_props(s
return err; /* found a _real_ error */
/* else... lop off the basename and try again. */
+ /* ### TODO: path_s is an absolute, schema-less URI, but
+ ### technically not an FS_PATH. */
svn_stringbuf_set(lopped_path,
- svn_path_join(svn_uri_basename(path_s->data, iterpool),
+ svn_path_join(svn_path_basename(path_s->data, iterpool),
lopped_path->data, iterpool));
len = path_s->len;
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/ra_neon.h
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/ra_neon.h?rev=1062039&r1=1062038&r2=1062039&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/ra_neon.h (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/ra_neon.h Fri Jan 21 21:45:41 2011
@@ -1010,6 +1010,16 @@ const char *
svn_ra_neon__request_get_location(svn_ra_neon__request_t *request,
apr_pool_t *pool);
+/* Canonicalize an absolute URI, in the general sense. URI might be a
+ * full, absolute, schema-ful URL. It might be just the path portion
+ * of a URL. Whatever the case, it is a URI-encoded identifier of
+ * *some sort*, as will be the returned form thereof.
+ */
+const char *
+svn_ra_neon__uri_canonicalize(const char *uri,
+ apr_pool_t *scratch_pool,
+ apr_pool_t *result_pool);
+
/*
* Implements the get_locations RA layer function. */
Modified: subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/util.c?rev=1062039&r1=1062038&r2=1062039&view=diff
==============================================================================
--- subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/util.c (original)
+++ subversion/branches/uris-as-urls/subversion/libsvn_ra_neon/util.c Fri Jan 21 21:45:41 2011
@@ -1570,8 +1570,24 @@ svn_ra_neon__request_get_location(svn_ra
apr_pool_t *pool)
{
const char *val = ne_get_response_header(request->ne_req, "Location");
- return val ? svn_uri_join(request->url,
- svn_uri_canonicalize(val, pool),
- pool)
- : NULL;
+ return val ? svn_ra_neon__uri_canonicalize(val, pool, pool) : NULL;
}
+
+
+const char *
+svn_ra_neon__uri_canonicalize(const char *uri,
+ apr_pool_t *scratch_pool,
+ apr_pool_t *result_pool)
+{
+ if (svn_path_is_url(uri))
+ return svn_url_canonicalize(uri, result_pool);
+
+ return apr_pstrcat(result_pool, "/",
+ svn_path_uri_encode(
+ svn_relpath_canonicalize(
+ svn_path_uri_decode(uri, scratch_pool),
+ scratch_pool),
+ result_pool),
+ NULL);
+}
+