You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by iv...@apache.org on 2011/02/20 17:20:13 UTC
svn commit: r1072623 - in /subversion/trunk/subversion/libsvn_ra_serf:
property.c ra_serf.h serf.c update.c
Author: ivan
Date: Sun Feb 20 16:20:13 2011
New Revision: 1072623
URL: http://svn.apache.org/viewvc?rev=1072623&view=rev
Log:
ra_serf: Remove code duplication.
* subversion/libsvn_ra_serf/property.c
* subversion/libsvn_ra_serf/ra_serf.h
(svn_ra_serf__get_resource_type): New.
* subversion/libsvn_ra_serf/update.c
* subversion/libsvn_ra_serf/serf.c
(svn_ra_serf__check_path, resource_is_directory, svn_ra_serf__get_file):
Use svn_ra_serf__get_resource_type().
Modified:
subversion/trunk/subversion/libsvn_ra_serf/property.c
subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
subversion/trunk/subversion/libsvn_ra_serf/serf.c
subversion/trunk/subversion/libsvn_ra_serf/update.c
Modified: subversion/trunk/subversion/libsvn_ra_serf/property.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/property.c?rev=1072623&r1=1072622&r2=1072623&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/property.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/property.c Sun Feb 20 16:20:13 2011
@@ -1043,3 +1043,33 @@ svn_ra_serf__get_baseline_info(const cha
return SVN_NO_ERROR;
}
+
+svn_error_t *
+svn_ra_serf__get_resource_type(svn_node_kind_t *kind,
+ apr_hash_t *props,
+ const char *url,
+ svn_revnum_t revision)
+{
+ const char *res_type;
+
+ res_type = svn_ra_serf__get_ver_prop(props, url, revision,
+ "DAV:", "resourcetype");
+ if (!res_type)
+ {
+ /* How did this happen? */
+ return svn_error_create(SVN_ERR_RA_DAV_PROPS_NOT_FOUND, NULL,
+ _("The PROPFIND response did not include the "
+ "requested resourcetype value"));
+ }
+
+ if (strcmp(res_type, "collection") == 0)
+ {
+ *kind = svn_node_dir;
+ }
+ else
+ {
+ *kind = svn_node_file;
+ }
+
+ return SVN_NO_ERROR;
+}
Modified: subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h?rev=1072623&r1=1072622&r2=1072623&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Sun Feb 20 16:20:13 2011
@@ -1003,6 +1003,13 @@ svn_ra_serf__set_prop(apr_hash_t *props,
const char *ns, const char *name,
const svn_string_t *val, apr_pool_t *pool);
+svn_error_t *
+svn_ra_serf__get_resource_type(svn_node_kind_t *kind,
+ apr_hash_t *props,
+ const char *url,
+ svn_revnum_t revision);
+
+
/** MERGE-related functions **/
typedef struct svn_ra_serf__merge_context_t svn_ra_serf__merge_context_t;
Modified: subversion/trunk/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/serf.c?rev=1072623&r1=1072622&r2=1072623&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/serf.c Sun Feb 20 16:20:13 2011
@@ -626,7 +626,7 @@ svn_ra_serf__check_path(svn_ra_session_t
svn_ra_serf__session_t *session = ra_session->priv;
apr_hash_t *props;
svn_ra_serf__propfind_context_t *prop_ctx;
- const char *path, *res_type;
+ const char *path;
svn_revnum_t fetched_rev;
svn_error_t *err = fetch_path_props(&prop_ctx, &props, &path, &fetched_rev,
@@ -644,23 +644,7 @@ svn_ra_serf__check_path(svn_ra_session_t
if (err)
return err;
- res_type = svn_ra_serf__get_ver_prop(props, path, fetched_rev,
- "DAV:", "resourcetype");
- if (!res_type)
- {
- /* How did this happen? */
- return svn_error_create(SVN_ERR_RA_DAV_OPTIONS_REQ_FAILED, NULL,
- _("The OPTIONS response did not include the "
- "requested resourcetype value"));
- }
- else if (strcmp(res_type, "collection") == 0)
- {
- *kind = svn_node_dir;
- }
- else
- {
- *kind = svn_node_file;
- }
+ SVN_ERR(svn_ra_serf__get_resource_type(kind, props, path, fetched_rev));
}
return SVN_NO_ERROR;
@@ -877,21 +861,14 @@ resource_is_directory(apr_hash_t *props,
const char *path,
svn_revnum_t revision)
{
- const char *res_type;
+ svn_node_kind_t kind;
- res_type = svn_ra_serf__get_ver_prop(props, path, revision,
- "DAV:", "resourcetype");
- if (!res_type)
- {
- /* How did this happen? */
- return svn_error_create(SVN_ERR_RA_DAV_OPTIONS_REQ_FAILED, NULL,
- _("The PROPFIND response did not include the "
- "requested resourcetype value"));
- }
- else if (strcmp(res_type, "collection") != 0)
+ SVN_ERR(svn_ra_serf__get_resource_type(&kind, props, path, revision));
+
+ if (kind != svn_node_dir)
{
- return svn_error_create(SVN_ERR_FS_NOT_DIRECTORY, NULL,
- _("Can't get entries of non-directory"));
+ return svn_error_create(SVN_ERR_FS_NOT_DIRECTORY, NULL,
+ _("Can't get entries of non-directory"));
}
return SVN_NO_ERROR;
Modified: subversion/trunk/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/update.c?rev=1072623&r1=1072622&r2=1072623&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/update.c Sun Feb 20 16:20:13 2011
@@ -2701,7 +2701,7 @@ svn_ra_serf__get_file(svn_ra_session_t *
svn_ra_serf__handler_t *handler;
const char *fetch_url;
apr_hash_t *fetch_props;
- const char *res_type;
+ svn_node_kind_t res_kind;
/* What connection should we go on? */
conn = session->conns[session->cur_conn];
@@ -2733,19 +2733,12 @@ svn_ra_serf__get_file(svn_ra_session_t *
pool));
/* Verify that resource type is not colelction. */
- res_type = svn_ra_serf__get_ver_prop(fetch_props, fetch_url, revision,
- "DAV:", "resourcetype");
- if (!res_type)
+ SVN_ERR(svn_ra_serf__get_resource_type(&res_kind, fetch_props, fetch_url,
+ revision));
+ if (res_kind != svn_node_file)
{
- /* How did this happen? */
- return svn_error_create(SVN_ERR_RA_DAV_PROPS_NOT_FOUND, NULL,
- _("The PROPFIND response did not include the "
- "requested resourcetype value"));
- }
- else if (strcmp(res_type, "collection") == 0)
- {
- return svn_error_create(SVN_ERR_FS_NOT_FILE, NULL,
- _("Can't get text contents of a directory"));
+ return svn_error_create(SVN_ERR_FS_NOT_FILE, NULL,
+ _("Can't get text contents of a directory"));
}
/* TODO Filter out all of our props into a usable format. */