Modified: subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/getlocations.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/getlocations.c?rev=1655189&r1=1655188&r2=1655189&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/getlocations.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/getlocations.c Tue Jan 27 23:27:44 2015 @@ -114,7 +114,8 @@ static svn_error_t * create_get_locations_body(serf_bucket_t **body_bkt, void *baton, serf_bucket_alloc_t *alloc, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { serf_bucket_t *buckets; loc_context_t *loc_ctx = baton; @@ -175,23 +176,20 @@ svn_ra_serf__get_locations(svn_ra_sessio *locations = loc_ctx->paths; SVN_ERR(svn_ra_serf__get_stable_url(&req_url, NULL /* latest_revnum */, - session, NULL /* conn */, - NULL /* url */, peg_revision, + session, NULL /* url */, peg_revision, pool, pool)); xmlctx = svn_ra_serf__xml_context_create(getloc_ttable, NULL, getloc_closed, NULL, loc_ctx, pool); - handler = svn_ra_serf__create_expat_handler(xmlctx, NULL, pool); + handler = svn_ra_serf__create_expat_handler(session, xmlctx, NULL, pool); handler->method = "REPORT"; handler->path = req_url; handler->body_delegate = create_get_locations_body; handler->body_delegate_baton = loc_ctx; handler->body_type = "text/xml"; - handler->conn = session->conns[0]; - handler->session = session; SVN_ERR(svn_ra_serf__context_run_one(handler, pool));
Modified: subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/getlocationsegments.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/getlocationsegments.c?rev=1655189&r1=1655188&r2=1655189&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/getlocationsegments.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/getlocationsegments.c Tue Jan 27 23:27:44 2015 @@ -114,7 +114,8 @@ static svn_error_t * create_gls_body(serf_bucket_t **body_bkt, void *baton, serf_bucket_alloc_t *alloc, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { serf_bucket_t *buckets; gls_context_t *gls_ctx = baton; @@ -178,23 +179,20 @@ svn_ra_serf__get_location_segments(svn_r gls_ctx->receiver_baton = receiver_baton; SVN_ERR(svn_ra_serf__get_stable_url(&req_url, NULL /* latest_revnum */, - session, NULL /* conn */, - NULL /* url */, peg_revision, + session, NULL /* url */, peg_revision, pool, pool)); xmlctx = svn_ra_serf__xml_context_create(gls_ttable, NULL, gls_closed, NULL, gls_ctx, pool); - handler = svn_ra_serf__create_expat_handler(xmlctx, NULL, pool); + handler = svn_ra_serf__create_expat_handler(session, xmlctx, NULL, pool); handler->method = "REPORT"; handler->path = req_url; handler->body_delegate = create_gls_body; handler->body_delegate_baton = gls_ctx; handler->body_type = "text/xml"; - handler->conn = session->conns[0]; - handler->session = session; err = svn_ra_serf__context_run_one(handler, pool); Modified: subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/getlocks.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/getlocks.c?rev=1655189&r1=1655188&r2=1655189&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/getlocks.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/getlocks.c Tue Jan 27 23:27:44 2015 @@ -213,7 +213,8 @@ static svn_error_t * create_getlocks_body(serf_bucket_t **body_bkt, void *baton, serf_bucket_alloc_t *alloc, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { lock_context_t *lock_ctx = baton; serf_bucket_t *buckets; @@ -244,8 +245,7 @@ svn_ra_serf__get_locks(svn_ra_session_t svn_error_t *err; req_url = svn_path_url_add_component2(session->session_url.path, path, pool); - SVN_ERR(svn_ra_serf__get_relative_path(&rel_path, req_url, session, - NULL, pool)); + SVN_ERR(svn_ra_serf__get_relative_path(&rel_path, req_url, session, pool)); lock_ctx = apr_pcalloc(pool, sizeof(*lock_ctx)); lock_ctx->pool = pool; @@ -257,13 +257,11 @@ svn_ra_serf__get_locks(svn_ra_session_t NULL, getlocks_closed, NULL, lock_ctx, pool); - handler = svn_ra_serf__create_expat_handler(xmlctx, NULL, pool); + handler = svn_ra_serf__create_expat_handler(session, xmlctx, NULL, pool); handler->method = "REPORT"; handler->path = req_url; handler->body_type = "text/xml"; - handler->conn = session->conns[0]; - handler->session = session; handler->body_delegate = create_getlocks_body; handler->body_delegate_baton = lock_ctx; Modified: subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/inherited_props.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/inherited_props.c?rev=1655189&r1=1655188&r2=1655189&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/inherited_props.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/inherited_props.c Tue Jan 27 23:27:44 2015 @@ -199,7 +199,8 @@ static svn_error_t * create_iprops_body(serf_bucket_t **bkt, void *baton, serf_bucket_alloc_t *alloc, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { iprops_context_t *iprops_ctx = baton; serf_bucket_t *body_bkt; @@ -231,21 +232,6 @@ typedef struct iprop_rq_info_t svn_ra_serf__handler_t *handler; } iprop_rq_info_t; -/* Removes all non regular properties from PROPS */ -static void -keep_only_regular_props(apr_hash_t *props, - apr_pool_t *scratch_pool) -{ - apr_hash_index_t *hi; - - for (hi = apr_hash_first(scratch_pool, props); hi; hi = apr_hash_next(hi)) - { - const char *propname = apr_hash_this_key(hi); - - if (svn_property_kind2(propname) != svn_prop_regular_kind) - svn_hash_sets(props, propname, NULL); - } -} /* Assumes session reparented to the repository root. The old session root is passed as session_url */ @@ -287,17 +273,19 @@ get_iprops_via_more_requests(svn_ra_sess rq->props = apr_hash_make(scratch_pool); SVN_ERR(svn_ra_serf__get_stable_url(&rq->urlpath, NULL, session, - session->conns[0], svn_path_url_add_component2( session->repos_root.path, relpath, scratch_pool), revision, scratch_pool, scratch_pool)); - SVN_ERR(svn_ra_serf__deliver_props(&rq->handler, rq->props, session, - session->conns[0], rq->urlpath, - rev_marker, "0", all_props, - scratch_pool)); + SVN_ERR(svn_ra_serf__create_propfind_handler( + &rq->handler, session, + rq->urlpath, + rev_marker, "0", all_props, + svn_ra_serf__deliver_svn_props, + rq->props, + scratch_pool)); /* Allow ignoring authz problems */ rq->handler->no_fail_on_http_failure_status = TRUE; @@ -335,29 +323,18 @@ get_iprops_via_more_requests(svn_ra_sess apr_hash_t *node_props; svn_prop_inherited_item_t *new_iprop; - if (rq->handler->sline.code >= 400 && rq->handler->sline.code != 403) + if (rq->handler->sline.code != 207 && rq->handler->sline.code != 403) { - return svn_error_trace( - svn_ra_serf__error_on_status(rq->handler->sline, - rq->handler->path, - rq->handler->location)); - } + if (rq->handler->server_error) + SVN_ERR(svn_ra_serf__server_error_create(rq->handler, + scratch_pool)); - /* Obtain the real properties from the double hash */ - node_props = apr_hash_get(rq->props, &rev_marker, sizeof(rev_marker)); - - if (!node_props) - continue; - - node_props = svn_hash_gets(node_props, rq->urlpath); - - if (!node_props) - continue; + return svn_error_trace(svn_ra_serf__unexpected_status(rq->handler)); + } - SVN_ERR(svn_ra_serf__flatten_props(&node_props, node_props, - scratch_pool, scratch_pool)); + node_props = rq->props; - keep_only_regular_props(node_props, scratch_pool); + svn_ra_serf__keep_only_regular_props(node_props, scratch_pool); if (!apr_hash_count(node_props)) continue; @@ -410,7 +387,6 @@ svn_ra_serf__get_inherited_props(svn_ra_ scratch_pool)); } - /* For now, use implementation in libsvn_ra */ err = get_iprops_via_more_requests(ra_session, iprops, session_uri, path, revision, result_pool, scratch_pool); @@ -426,7 +402,6 @@ svn_ra_serf__get_inherited_props(svn_ra_ SVN_ERR(svn_ra_serf__get_stable_url(&req_url, NULL /* latest_revnum */, session, - NULL /* conn */, NULL /* url */, revision, scratch_pool, scratch_pool)); @@ -448,12 +423,12 @@ svn_ra_serf__get_inherited_props(svn_ra_ NULL, iprops_ctx, scratch_pool); - handler = svn_ra_serf__create_expat_handler(xmlctx, NULL, scratch_pool); + handler = svn_ra_serf__create_expat_handler(session, xmlctx, NULL, + scratch_pool); handler->method = "REPORT"; handler->path = req_url; - handler->conn = session->conns[0]; - handler->session = session; + handler->body_delegate = create_iprops_body; handler->body_delegate_baton = iprops_ctx; handler->body_type = "text/xml"; Modified: subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/lock.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/lock.c?rev=1655189&r1=1655188&r2=1655189&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/lock.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/lock.c Tue Jan 27 23:27:44 2015 @@ -191,7 +191,8 @@ locks_closed(svn_ra_serf__xml_estate_t * static svn_error_t * set_lock_headers(serf_bucket_t *headers, void *baton, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { lock_ctx_t *lock_ctx = baton; @@ -399,7 +400,8 @@ static svn_error_t * create_lock_body(serf_bucket_t **body_bkt, void *baton, serf_bucket_alloc_t *alloc, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { lock_ctx_t *ctx = baton; serf_bucket_t *buckets; @@ -482,7 +484,8 @@ svn_ra_serf__lock(svn_ra_session_t *ra_s NULL, locks_closed, NULL, lock_ctx, lock_pool); - handler = svn_ra_serf__create_expat_handler(xmlctx, NULL, lock_pool); + handler = svn_ra_serf__create_expat_handler(session, xmlctx, NULL, + lock_pool); handler->method = "LOCK"; handler->path = req_url; @@ -495,8 +498,6 @@ svn_ra_serf__lock(svn_ra_session_t *ra_s if (session->cur_conn >= session->num_conns) session->cur_conn = 0; - handler->session = session; - handler->header_delegate = set_lock_headers; handler->header_delegate_baton = lock_ctx; @@ -528,7 +529,8 @@ svn_ra_serf__lock(svn_ra_session_t *ra_s static svn_error_t * set_unlock_headers(serf_bucket_t *headers, void *baton, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { lock_ctx_t *ctx = baton; @@ -647,12 +649,10 @@ svn_ra_serf__unlock(svn_ra_session_t *ra req_url = svn_path_url_add_component2(session->session_url.path, lock_ctx->path, lock_pool); - handler = svn_ra_serf__create_handler(lock_pool); + handler = svn_ra_serf__create_handler(session, lock_pool); handler->method = "UNLOCK"; handler->path = req_url; - handler->conn = session->conns[0]; - handler->session = session; handler->header_delegate = set_unlock_headers; handler->header_delegate_baton = lock_ctx; Modified: subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/log.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/log.c?rev=1655189&r1=1655188&r2=1655189&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/log.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/log.c Tue Jan 27 23:27:44 2015 @@ -412,7 +412,8 @@ static svn_error_t * create_log_body(serf_bucket_t **body_bkt, void *baton, serf_bucket_alloc_t *alloc, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { serf_bucket_t *buckets; log_context_t *log_ctx = baton; @@ -579,7 +580,7 @@ svn_ra_serf__get_log(svn_ra_session_t *r peg_rev = (start == SVN_INVALID_REVNUM || start > end) ? start : end; SVN_ERR(svn_ra_serf__get_stable_url(&req_url, NULL /* latest_revnum */, - session, NULL /* conn */, + session, NULL /* url */, peg_rev, pool, pool)); @@ -587,15 +588,13 @@ svn_ra_serf__get_log(svn_ra_session_t *r log_opened, log_closed, NULL, log_ctx, pool); - handler = svn_ra_serf__create_expat_handler(xmlctx, NULL, pool); + handler = svn_ra_serf__create_expat_handler(session, xmlctx, NULL, pool); handler->method = "REPORT"; handler->path = req_url; handler->body_delegate = create_log_body; handler->body_delegate_baton = log_ctx; handler->body_type = "text/xml"; - handler->conn = session->conns[0]; - handler->session = session; SVN_ERR(svn_ra_serf__context_run_one(handler, pool)); Modified: subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/merge.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/merge.c?rev=1655189&r1=1655188&r2=1655189&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/merge.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/merge.c Tue Jan 27 23:27:44 2015 @@ -271,7 +271,8 @@ merge_closed(svn_ra_serf__xml_estate_t * static svn_error_t * setup_merge_headers(serf_bucket_t *headers, void *baton, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { merge_context_t *ctx = baton; @@ -337,7 +338,8 @@ static svn_error_t* create_merge_body(serf_bucket_t **bkt, void *baton, serf_bucket_alloc_t *alloc, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { merge_context_t *ctx = baton; serf_bucket_t *body_bkt; @@ -389,7 +391,6 @@ create_merge_body(serf_bucket_t **bkt, svn_error_t * svn_ra_serf__run_merge(const svn_commit_info_t **commit_info, svn_ra_serf__session_t *session, - svn_ra_serf__connection_t *conn, const char *merge_resource_url, apr_hash_t *lock_tokens, svn_boolean_t keep_locks, @@ -418,14 +419,13 @@ svn_ra_serf__run_merge(const svn_commit_ NULL, merge_closed, NULL, merge_ctx, scratch_pool); - handler = svn_ra_serf__create_expat_handler(xmlctx, NULL, scratch_pool); + handler = svn_ra_serf__create_expat_handler(session, xmlctx, NULL, + scratch_pool); handler->method = "MERGE"; handler->path = merge_ctx->merge_url; handler->body_delegate = create_merge_body; handler->body_delegate_baton = merge_ctx; - handler->conn = conn; - handler->session = session; handler->header_delegate = setup_merge_headers; handler->header_delegate_baton = merge_ctx; @@ -439,5 +439,13 @@ svn_ra_serf__run_merge(const svn_commit_ *commit_info = merge_ctx->commit_info; + /* Sanity check (Reported to be triggered by CodePlex's svnbridge) */ + if (! SVN_IS_VALID_REVNUM(merge_ctx->commit_info->revision)) + { + return svn_error_create(SVN_ERR_RA_DAV_PROPS_NOT_FOUND, NULL, + _("The MERGE response did not include " + "a new revision")); + } + return SVN_NO_ERROR; } Modified: subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/mergeinfo.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/mergeinfo.c?rev=1655189&r1=1655188&r2=1655189&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/mergeinfo.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/mergeinfo.c Tue Jan 27 23:27:44 2015 @@ -135,7 +135,8 @@ static svn_error_t * create_mergeinfo_body(serf_bucket_t **bkt, void *baton, serf_bucket_alloc_t *alloc, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { mergeinfo_context_t *mergeinfo_ctx = baton; serf_bucket_t *body_bkt; @@ -200,7 +201,7 @@ svn_ra_serf__get_mergeinfo(svn_ra_sessio *catalog = NULL; SVN_ERR(svn_ra_serf__get_stable_url(&path, NULL /* latest_revnum */, - session, NULL /* conn */, + session, NULL /* url */, revision, pool, pool)); @@ -216,12 +217,11 @@ svn_ra_serf__get_mergeinfo(svn_ra_sessio NULL, mergeinfo_closed, NULL, mergeinfo_ctx, pool); - handler = svn_ra_serf__create_expat_handler(xmlctx, NULL, pool); + handler = svn_ra_serf__create_expat_handler(session, xmlctx, NULL, pool); handler->method = "REPORT"; handler->path = path; - handler->conn = session->conns[0]; - handler->session = session; + handler->body_delegate = create_mergeinfo_body; handler->body_delegate_baton = mergeinfo_ctx; handler->body_type = "text/xml"; Modified: subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/multistatus.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/multistatus.c?rev=1655189&r1=1655188&r2=1655189&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/multistatus.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/multistatus.c Tue Jan 27 23:27:44 2015 @@ -619,7 +619,8 @@ svn_ra_serf__setup_error_parsing(svn_ra_ ms_baton, ms_baton->pool); - tmp_handler = svn_ra_serf__create_expat_handler(ms_baton->xmlctx, + tmp_handler = svn_ra_serf__create_expat_handler(handler->session, + ms_baton->xmlctx, expected_status, result_pool); Modified: subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/options.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/options.c?rev=1655189&r1=1655188&r2=1655189&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/options.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/options.c Tue Jan 27 23:27:44 2015 @@ -116,7 +116,8 @@ static svn_error_t * create_options_body(serf_bucket_t **body_bkt, void *baton, serf_bucket_alloc_t *alloc, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { serf_bucket_t *body; body = serf_bucket_aggregate_create(alloc); @@ -388,7 +389,6 @@ options_response_handler(serf_request_t static svn_error_t * create_options_req(options_context_t **opt_ctx, svn_ra_serf__session_t *session, - svn_ra_serf__connection_t *conn, apr_pool_t *pool) { options_context_t *new_ctx; @@ -405,14 +405,12 @@ create_options_req(options_context_t **o NULL, options_closed, NULL, new_ctx, pool); - handler = svn_ra_serf__create_expat_handler(xmlctx, NULL, pool); + handler = svn_ra_serf__create_expat_handler(session, xmlctx, NULL, pool); handler->method = "OPTIONS"; handler->path = session->session_url.path; handler->body_delegate = create_options_body; handler->body_type = "text/xml"; - handler->conn = conn; - handler->session = session; new_ctx->handler = handler; @@ -429,15 +427,14 @@ create_options_req(options_context_t **o svn_error_t * svn_ra_serf__v2_get_youngest_revnum(svn_revnum_t *youngest, - svn_ra_serf__connection_t *conn, + svn_ra_serf__session_t *session, apr_pool_t *scratch_pool) { - svn_ra_serf__session_t *session = conn->session; options_context_t *opt_ctx; SVN_ERR_ASSERT(SVN_RA_SERF__HAVE_HTTPV2_SUPPORT(session)); - SVN_ERR(create_options_req(&opt_ctx, session, conn, scratch_pool)); + SVN_ERR(create_options_req(&opt_ctx, session, scratch_pool)); SVN_ERR(svn_ra_serf__context_run_one(opt_ctx->handler, scratch_pool)); if (opt_ctx->handler->sline.code != 200) @@ -456,21 +453,40 @@ svn_ra_serf__v2_get_youngest_revnum(svn_ svn_error_t * svn_ra_serf__v1_get_activity_collection(const char **activity_url, - svn_ra_serf__connection_t *conn, + svn_ra_serf__session_t *session, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - svn_ra_serf__session_t *session = conn->session; options_context_t *opt_ctx; SVN_ERR_ASSERT(!SVN_RA_SERF__HAVE_HTTPV2_SUPPORT(session)); - SVN_ERR(create_options_req(&opt_ctx, session, conn, scratch_pool)); + if (session->activity_collection_url) + { + *activity_url = apr_pstrdup(result_pool, + session->activity_collection_url); + return SVN_NO_ERROR; + } + + SVN_ERR(create_options_req(&opt_ctx, session, scratch_pool)); SVN_ERR(svn_ra_serf__context_run_one(opt_ctx->handler, scratch_pool)); if (opt_ctx->handler->sline.code != 200) return svn_error_trace(svn_ra_serf__unexpected_status(opt_ctx->handler)); + /* Cache the result. */ + if (opt_ctx->activity_collection) + { + session->activity_collection_url = + apr_pstrdup(session->pool, opt_ctx->activity_collection); + } + else + { + return svn_error_create(SVN_ERR_RA_DAV_OPTIONS_REQ_FAILED, NULL, + _("The OPTIONS response did not include the " + "requested activity-collection-set value")); + } + *activity_url = apr_pstrdup(result_pool, opt_ctx->activity_collection); return SVN_NO_ERROR; @@ -489,9 +505,11 @@ svn_ra_serf__exchange_capabilities(svn_r { options_context_t *opt_ctx; + if (corrected_url) + *corrected_url = NULL; + /* This routine automatically fills in serf_sess->capabilities */ - SVN_ERR(create_options_req(&opt_ctx, serf_sess, serf_sess->conns[0], - scratch_pool)); + SVN_ERR(create_options_req(&opt_ctx, serf_sess, scratch_pool)); SVN_ERR(svn_ra_serf__context_run_one(opt_ctx->handler, scratch_pool)); @@ -525,7 +543,8 @@ static svn_error_t * create_simple_options_body(serf_bucket_t **body_bkt, void *baton, serf_bucket_alloc_t *alloc, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { serf_bucket_t *body; serf_bucket_t *s; @@ -547,11 +566,9 @@ svn_ra_serf__probe_proxy(svn_ra_serf__se { svn_ra_serf__handler_t *handler; - handler = svn_ra_serf__create_handler(scratch_pool); + handler = svn_ra_serf__create_handler(serf_sess, scratch_pool); handler->method = "OPTIONS"; handler->path = serf_sess->session_url.path; - handler->conn = serf_sess->conns[0]; - handler->session = serf_sess; /* We don't care about the response body, so discard it. */ handler->response_handler = svn_ra_serf__handle_discard_body; Modified: subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/property.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/property.c?rev=1655189&r1=1655188&r2=1655189&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/property.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/property.c Tue Jan 27 23:27:44 2015 @@ -64,8 +64,7 @@ typedef struct propfind_context_t { /* the requested path */ const char *path; - /* the requested version (number and string form) */ - svn_revnum_t rev; + /* the requested version (in string form) */ const char *label; /* the request depth */ @@ -74,7 +73,7 @@ typedef struct propfind_context_t { /* the list of requested properties */ const svn_ra_serf__dav_props_t *find_props; - svn_ra_serf__prop_func prop_func; + svn_ra_serf__prop_func_t prop_func; void *prop_func_baton; /* hash table containing all the properties associated with the @@ -169,6 +168,29 @@ propfind_opened(svn_ra_serf__xml_estate_ return SVN_NO_ERROR; } +/* Set PROPS for NS:NAME VAL. Helper for propfind_closed */ +static void +set_ns_prop(apr_hash_t *ns_props, + const char *ns, const char *name, + const svn_string_t *val, apr_pool_t *result_pool) +{ + apr_hash_t *props = svn_hash_gets(ns_props, ns); + + if (!props) + { + props = apr_hash_make(result_pool); + ns = apr_pstrdup(result_pool, ns); + svn_hash_sets(ns_props, ns, props); + } + + if (val) + { + name = apr_pstrdup(result_pool, name); + val = svn_string_dup(val, result_pool); + } + + svn_hash_sets(props, name, val); +} /* Conforms to svn_ra_serf__xml_closed_t */ static svn_error_t * @@ -226,8 +248,6 @@ propfind_closed(svn_ra_serf__xml_estate_ { const char *encoding; const svn_string_t *val_str; - apr_hash_t *gathered; - const char *path; const char *ns; const char *name; const char *altvalue; @@ -253,9 +273,7 @@ propfind_closed(svn_ra_serf__xml_estate_ val_str = cdata; } - /* The current path sits on the RESPONSE state. Gather up all the - state from this PROPVAL to the (grandparent) RESPONSE state, - and grab the path from there. + /* The current path sits on the RESPONSE state. Now, it would be nice if we could, at this point, know that the status code for this property indicated a problem -- then @@ -265,19 +283,12 @@ propfind_closed(svn_ra_serf__xml_estate_ here, setting the property and value as expected. Once we know for sure the status code associate with the property, we'll decide its fate. */ - gathered = svn_ra_serf__xml_gather_since(xes, RESPONSE); - - /* These will be dup'd into CTX->POOL, as necessary. */ - path = svn_hash_gets(gathered, "path"); - if (path == NULL) - path = ctx->path; ns = svn_hash_gets(attrs, "ns"); name = svn_hash_gets(attrs, "name"); - svn_ra_serf__set_ver_prop(ctx->ps_props, - path, ctx->rev, ns, name, val_str, - apr_hash_pool_get(ctx->ps_props)); + set_ns_prop(ctx->ps_props, ns, name, val_str, + apr_hash_pool_get(ctx->ps_props)); } else { @@ -285,153 +296,60 @@ propfind_closed(svn_ra_serf__xml_estate_ SVN_ERR_ASSERT(leaving_state == PROPSTAT); - gathered = svn_ra_serf__xml_gather_since(xes, PROPSTAT); + gathered = svn_ra_serf__xml_gather_since(xes, RESPONSE); /* If we've squirreled away a note that says we want to ignore these properties, we'll do so. Otherwise, we need to copy them from the temporary hash into the ctx->ret_props hash. */ if (! svn_hash_gets(gathered, "ignore-prop")) { - SVN_ERR(svn_ra_serf__walk_all_paths(ctx->ps_props, ctx->rev, - ctx->prop_func, - ctx->prop_func_baton, - scratch_pool)); - } + apr_hash_index_t *hi_ns; + const char *path; + apr_pool_t *iterpool = svn_pool_create(scratch_pool); - ctx->ps_props = NULL; /* Allocated in PROPSTAT state pool */ - } - - return SVN_NO_ERROR; -} - - -const svn_string_t * -svn_ra_serf__get_ver_prop_string(apr_hash_t *props, - const char *path, - svn_revnum_t rev, - const char *ns, - const char *name) -{ - apr_hash_t *ver_props, *path_props, *ns_props; - void *val = NULL; - - ver_props = apr_hash_get(props, &rev, sizeof(rev)); - if (ver_props) - { - path_props = svn_hash_gets(ver_props, path); - if (path_props) - { - ns_props = svn_hash_gets(path_props, ns); - if (ns_props) + path = svn_hash_gets(gathered, "path"); + if (!path) + path = ctx->path; + + for (hi_ns = apr_hash_first(scratch_pool, ctx->ps_props); + hi_ns; + hi_ns = apr_hash_next(hi_ns)) { - val = svn_hash_gets(ns_props, name); + const char *ns = apr_hash_this_key(hi_ns); + apr_hash_t *props = apr_hash_this_val(hi_ns); + apr_hash_index_t *hi_prop; + + svn_pool_clear(iterpool); + + for (hi_prop = apr_hash_first(iterpool, props); + hi_prop; + hi_prop = apr_hash_next(hi_prop)) + { + const char *name = apr_hash_this_key(hi_prop); + const svn_string_t *value = apr_hash_this_val(hi_prop); + + SVN_ERR(ctx->prop_func(ctx->prop_func_baton, path, + ns, name, value, iterpool)); + } } - } - } - - return val; -} - -const char * -svn_ra_serf__get_ver_prop(apr_hash_t *props, - const char *path, - svn_revnum_t rev, - const char *ns, - const char *name) -{ - const svn_string_t *val; - - val = svn_ra_serf__get_ver_prop_string(props, path, rev, ns, name); - - if (val) - { - return val->data; - } - - return NULL; -} - -const svn_string_t * -svn_ra_serf__get_prop_string(apr_hash_t *props, - const char *path, - const char *ns, - const char *name) -{ - return svn_ra_serf__get_ver_prop_string(props, path, SVN_INVALID_REVNUM, - ns, name); -} - -const char * -svn_ra_serf__get_prop(apr_hash_t *props, - const char *path, - const char *ns, - const char *name) -{ - return svn_ra_serf__get_ver_prop(props, path, SVN_INVALID_REVNUM, ns, name); -} - -void -svn_ra_serf__set_ver_prop(apr_hash_t *props, - const char *path, svn_revnum_t rev, - const char *ns, const char *name, - const svn_string_t *val, apr_pool_t *pool) -{ - apr_hash_t *ver_props, *path_props, *ns_props; - - ver_props = apr_hash_get(props, &rev, sizeof(rev)); - if (!ver_props) - { - ver_props = apr_hash_make(pool); - apr_hash_set(props, apr_pmemdup(pool, &rev, sizeof(rev)), sizeof(rev), - ver_props); - } - - path_props = svn_hash_gets(ver_props, path); - - if (!path_props) - { - path_props = apr_hash_make(pool); - path = apr_pstrdup(pool, path); - svn_hash_sets(ver_props, path, path_props); - - /* todo: we know that we'll fail the next check, but fall through - * for now for simplicity's sake. - */ - } - ns_props = svn_hash_gets(path_props, ns); - if (!ns_props) - { - ns_props = apr_hash_make(pool); - ns = apr_pstrdup(pool, ns); - svn_hash_sets(path_props, ns, ns_props); - } + svn_pool_destroy(iterpool); + } - if (val) - { - name = apr_pstrdup(pool, name); - val = svn_string_dup(val, pool); + ctx->ps_props = NULL; /* Allocated in PROPSTAT state pool */ } - svn_hash_sets(ns_props, name, val); + return SVN_NO_ERROR; } -void -svn_ra_serf__set_prop(apr_hash_t *props, - const char *path, - const char *ns, const char *name, - const svn_string_t *val, apr_pool_t *pool) -{ - svn_ra_serf__set_ver_prop(props, path, SVN_INVALID_REVNUM, ns, name, - val, pool); -} static svn_error_t * setup_propfind_headers(serf_bucket_t *headers, - void *setup_baton, - apr_pool_t *pool) + void *setup_baton, + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { propfind_context_t *ctx = setup_baton; @@ -452,7 +370,8 @@ static svn_error_t * create_propfind_body(serf_bucket_t **bkt, void *setup_baton, serf_bucket_alloc_t *alloc, - apr_pool_t *pool) + apr_pool_t *pool /* request pool */, + apr_pool_t *scratch_pool) { propfind_context_t *ctx = setup_baton; @@ -527,16 +446,15 @@ create_propfind_body(serf_bucket_t **bkt svn_error_t * -svn_ra_serf__deliver_props2(svn_ra_serf__handler_t **propfind_handler, - svn_ra_serf__session_t *sess, - svn_ra_serf__connection_t *conn, - const char *path, - svn_revnum_t rev, - const char *depth, - const svn_ra_serf__dav_props_t *find_props, - svn_ra_serf__prop_func prop_func, - void *prop_func_baton, - apr_pool_t *pool) +svn_ra_serf__create_propfind_handler(svn_ra_serf__handler_t **propfind_handler, + svn_ra_serf__session_t *sess, + const char *path, + svn_revnum_t rev, + const char *depth, + const svn_ra_serf__dav_props_t *find_props, + svn_ra_serf__prop_func_t prop_func, + void *prop_func_baton, + apr_pool_t *pool) { propfind_context_t *new_prop_ctx; svn_ra_serf__handler_t *handler; @@ -549,7 +467,6 @@ svn_ra_serf__deliver_props2(svn_ra_serf_ new_prop_ctx->prop_func = prop_func; new_prop_ctx->prop_func_baton = prop_func_baton; new_prop_ctx->depth = depth; - new_prop_ctx->rev = rev; if (SVN_IS_VALID_REVNUM(rev)) { @@ -566,7 +483,7 @@ svn_ra_serf__deliver_props2(svn_ra_serf_ NULL, new_prop_ctx, pool); - handler = svn_ra_serf__create_expat_handler(xmlctx, + handler = svn_ra_serf__create_expat_handler(sess, xmlctx, propfind_expected_status, pool); @@ -578,8 +495,7 @@ svn_ra_serf__deliver_props2(svn_ra_serf_ handler->header_delegate = setup_propfind_headers; handler->header_delegate_baton = new_prop_ctx; - handler->session = sess; - handler->conn = conn; + handler->no_dav_headers = TRUE; new_prop_ctx->handler = handler; @@ -588,254 +504,85 @@ svn_ra_serf__deliver_props2(svn_ra_serf_ return SVN_NO_ERROR; } -/* Baton for deliver_prop */ -struct deliver_prop_baton_t -{ - apr_pool_t *result_pool; - apr_hash_t *prop_vals; - svn_revnum_t rev; -}; - -/* Implements svn_ra_serf__prop_func for svn_ra_serf__deliver_props */ -static svn_error_t * -deliver_prop(void *baton, - const char *path, - const char *ns, - const char *name, - const svn_string_t *value, - apr_pool_t *scratch_pool) -{ - struct deliver_prop_baton_t *dpb = baton; - - svn_ra_serf__set_ver_prop(dpb->prop_vals, - path, dpb->rev, - ns, name, value, - dpb->result_pool); - return SVN_NO_ERROR; -} - svn_error_t * -svn_ra_serf__deliver_props(svn_ra_serf__handler_t **propfind_handler, - apr_hash_t *prop_vals, - svn_ra_serf__session_t *sess, - svn_ra_serf__connection_t *conn, - const char *url, - svn_revnum_t rev, - const char *depth, - const svn_ra_serf__dav_props_t *lookup_props, - apr_pool_t *pool) +svn_ra_serf__deliver_svn_props(void *baton, + const char *path, + const char *ns, + const char *name, + const svn_string_t *value, + apr_pool_t *scratch_pool) { - struct deliver_prop_baton_t *dpb = apr_pcalloc(pool, sizeof(*dpb)); - - dpb->result_pool = apr_hash_pool_get(prop_vals); - dpb->prop_vals = prop_vals; - dpb->rev = rev; - - return svn_error_trace(svn_ra_serf__deliver_props2(propfind_handler, - sess, conn, - url, rev, - depth, - lookup_props, - deliver_prop, dpb, - pool)); -} - - + apr_hash_t *props = baton; + apr_pool_t *result_pool = apr_hash_pool_get(props); + const char *prop_name; -/* - * This helper function will block until the PROP_CTX indicates that is done - * or another error is returned. - */ -svn_error_t * -svn_ra_serf__wait_for_props(svn_ra_serf__handler_t *handler, - apr_pool_t *scratch_pool) -{ - SVN_ERR(svn_ra_serf__context_run_one(handler, scratch_pool)); + prop_name = svn_ra_serf__svnname_from_wirename(ns, name, result_pool); + if (prop_name == NULL) + return SVN_NO_ERROR; - if (handler->sline.code != 207) - return svn_error_trace(svn_ra_serf__unexpected_status(handler)); + svn_hash_sets(props, prop_name, svn_string_dup(value, result_pool)); return SVN_NO_ERROR; } /* - * This is a blocking version of deliver_props. + * Implementation of svn_ra_serf__prop_func_t that delivers all DAV properties + * in (const char * -> apr_hash_t *) on Namespace pointing to a second hash + * (const char * -> svn_string_t *) to the values. */ -svn_error_t * -svn_ra_serf__retrieve_props(apr_hash_t **results, - svn_ra_serf__session_t *sess, - svn_ra_serf__connection_t *conn, - const char *url, - svn_revnum_t rev, - const char *depth, - const svn_ra_serf__dav_props_t *props, - apr_pool_t *result_pool, - apr_pool_t *scratch_pool) +static svn_error_t * +deliver_node_props(void *baton, + const char *path, + const char *ns, + const char *name, + const svn_string_t *value, + apr_pool_t *scratch_pool) { - svn_ra_serf__handler_t *handler; + apr_hash_t *nss = baton; + apr_hash_t *props; + apr_pool_t *result_pool = apr_hash_pool_get(nss); + + props = svn_hash_gets(nss, ns); - *results = apr_hash_make(result_pool); + if (!props) + { + props = apr_hash_make(result_pool); - SVN_ERR(svn_ra_serf__deliver_props(&handler, *results, sess, conn, url, - rev, depth, props, result_pool)); - SVN_ERR(svn_ra_serf__wait_for_props(handler, scratch_pool)); + ns = apr_pstrdup(result_pool, ns); + svn_hash_sets(nss, ns, props); + } + + name = apr_pstrdup(result_pool, name); + svn_hash_sets(props, name, svn_string_dup(value, result_pool)); return SVN_NO_ERROR; } - svn_error_t * svn_ra_serf__fetch_node_props(apr_hash_t **results, - svn_ra_serf__connection_t *conn, + svn_ra_serf__session_t *session, const char *url, svn_revnum_t revision, const svn_ra_serf__dav_props_t *which_props, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - apr_hash_t *multiprops; - apr_hash_t *ver_props; - - /* Note: a couple extra hash tables and whatnot get into RESULT_POOL. - Not a big deal at this point. Theoretically, we could fetch all - props into SCRATCH_POOL, then copy just the REVISION/URL props - into RESULT_POOL. Too much work for too little gain... */ - SVN_ERR(svn_ra_serf__retrieve_props(&multiprops, conn->session, conn, - url, revision, "0", which_props, - result_pool, scratch_pool)); - - ver_props = apr_hash_get(multiprops, &revision, sizeof(revision)); - if (ver_props != NULL) - { - *results = svn_hash_gets(ver_props, url); - if (*results != NULL) - return SVN_NO_ERROR; - } - - return svn_error_create(SVN_ERR_RA_DAV_PROPS_NOT_FOUND, NULL, - _("The PROPFIND response did not include " - "the requested properties")); -} - - -svn_error_t * -svn_ra_serf__walk_node_props(apr_hash_t *props, - svn_ra_serf__walker_visitor_t walker, - void *baton, - apr_pool_t *scratch_pool) -{ - apr_pool_t *iterpool; - apr_hash_index_t *ns_hi; - - iterpool = svn_pool_create(scratch_pool); - for (ns_hi = apr_hash_first(scratch_pool, props); ns_hi; - ns_hi = apr_hash_next(ns_hi)) - { - void *ns_val; - const void *ns_name; - apr_hash_index_t *name_hi; - - /* NOTE: We do not clear ITERPOOL in this loop. Generally, there are - very few namespaces, so this loop will not have many iterations. - Instead, ITERPOOL is used for the inner loop. */ - - apr_hash_this(ns_hi, &ns_name, NULL, &ns_val); - - for (name_hi = apr_hash_first(scratch_pool, ns_val); name_hi; - name_hi = apr_hash_next(name_hi)) - { - void *prop_val; - const void *prop_name; - - /* See note above, regarding clearing of this pool. */ - svn_pool_clear(iterpool); - - apr_hash_this(name_hi, &prop_name, NULL, &prop_val); - - SVN_ERR(walker(baton, ns_name, prop_name, prop_val, iterpool)); - } - } - svn_pool_destroy(iterpool); - - return SVN_NO_ERROR; -} - - -svn_error_t * -svn_ra_serf__walk_all_props(apr_hash_t *props, - const char *name, - svn_revnum_t rev, - svn_ra_serf__walker_visitor_t walker, - void *baton, - apr_pool_t *scratch_pool) -{ - apr_hash_t *ver_props; - apr_hash_t *path_props; - - ver_props = apr_hash_get(props, &rev, sizeof(rev)); - if (!ver_props) - return SVN_NO_ERROR; - - path_props = svn_hash_gets(ver_props, name); - if (!path_props) - return SVN_NO_ERROR; - - return svn_error_trace(svn_ra_serf__walk_node_props(path_props, - walker, baton, - scratch_pool)); -} - - -svn_error_t * -svn_ra_serf__walk_all_paths(apr_hash_t *props, - svn_revnum_t rev, - svn_ra_serf__path_rev_walker_t walker, - void *baton, - apr_pool_t *pool) -{ - apr_hash_index_t *path_hi; - apr_hash_t *ver_props; - - ver_props = apr_hash_get(props, &rev, sizeof(rev)); - - if (!ver_props) - { - return SVN_NO_ERROR; - } + apr_hash_t *props; + svn_ra_serf__handler_t *handler; - for (path_hi = apr_hash_first(pool, ver_props); path_hi; - path_hi = apr_hash_next(path_hi)) - { - void *path_props; - const void *path_name; - apr_hash_index_t *ns_hi; + props = apr_hash_make(result_pool); - apr_hash_this(path_hi, &path_name, NULL, &path_props); - for (ns_hi = apr_hash_first(pool, path_props); ns_hi; - ns_hi = apr_hash_next(ns_hi)) - { - void *ns_val; - const void *ns_name; - apr_hash_index_t *name_hi; - apr_hash_this(ns_hi, &ns_name, NULL, &ns_val); - for (name_hi = apr_hash_first(pool, ns_val); name_hi; - name_hi = apr_hash_next(name_hi)) - { - void *prop_val; - const void *prop_name; + SVN_ERR(svn_ra_serf__create_propfind_handler(&handler, session, + url, revision, "0", which_props, + deliver_node_props, + props, scratch_pool)); - apr_hash_this(name_hi, &prop_name, NULL, &prop_val); - /* use a subpool? */ - SVN_ERR(walker(baton, path_name, ns_name, prop_name, prop_val, - pool)); - } - } - } + SVN_ERR(svn_ra_serf__context_run_one(handler, scratch_pool)); + *results = props; return SVN_NO_ERROR; } - const char * svn_ra_serf__svnname_from_wirename(const char *ns, const char *name, @@ -879,96 +626,6 @@ svn_ra_serf__svnname_from_wirename(const return apr_pstrcat(result_pool, ns, name, SVN_VA_NULL); } - -/* Conforms to svn_ra_serf__walker_visitor_t */ -static svn_error_t * -set_flat_props(void *baton, - const char *ns, - const char *name, - const svn_string_t *value, - apr_pool_t *pool) -{ - apr_hash_t *props = baton; - apr_pool_t *result_pool = apr_hash_pool_get(props); - const char *prop_name; - - /* ### is VAL in the proper pool? */ - - prop_name = svn_ra_serf__svnname_from_wirename(ns, name, result_pool); - if (prop_name != NULL) - svn_hash_sets(props, prop_name, value); - - return SVN_NO_ERROR; -} - - -svn_error_t * -svn_ra_serf__flatten_props(apr_hash_t **flat_props, - apr_hash_t *props, - apr_pool_t *result_pool, - apr_pool_t *scratch_pool) -{ - *flat_props = apr_hash_make(result_pool); - - return svn_error_trace(svn_ra_serf__walk_node_props( - props, - set_flat_props, - *flat_props /* baton */, - scratch_pool)); -} - - -static svn_error_t * -select_revprops(void *baton, - const char *ns, - const char *name, - const svn_string_t *val, - apr_pool_t *scratch_pool) -{ - apr_hash_t *revprops = baton; - apr_pool_t *result_pool = apr_hash_pool_get(revprops); - const char *prop_name; - - /* ### copy NAME into the RESULT_POOL? */ - /* ### copy VAL into the RESULT_POOL? */ - - if (strcmp(ns, SVN_DAV_PROP_NS_CUSTOM) == 0) - prop_name = name; - else if (strcmp(ns, SVN_DAV_PROP_NS_SVN) == 0) - prop_name = apr_pstrcat(result_pool, SVN_PROP_PREFIX, name, SVN_VA_NULL); - else if (strcmp(ns, SVN_PROP_PREFIX) == 0) - prop_name = apr_pstrcat(result_pool, SVN_PROP_PREFIX, name, SVN_VA_NULL); - else if (strcmp(ns, "") == 0) - prop_name = name; - else - { - /* do nothing for now? */ - return SVN_NO_ERROR; - } - - svn_hash_sets(revprops, prop_name, val); - - return SVN_NO_ERROR; -} - - -svn_error_t * -svn_ra_serf__select_revprops(apr_hash_t **revprops, - const char *name, - svn_revnum_t rev, - apr_hash_t *all_revprops, - apr_pool_t *result_pool, - apr_pool_t *scratch_pool) -{ - *revprops = apr_hash_make(result_pool); - - return svn_error_trace(svn_ra_serf__walk_all_props( - all_revprops, name, rev, - select_revprops, *revprops, - scratch_pool)); -} - - /* * Contact the server (using CONN) to calculate baseline * information for BASELINE_URL at REVISION (which may be @@ -982,7 +639,7 @@ svn_ra_serf__select_revprops(apr_hash_t static svn_error_t * retrieve_baseline_info(svn_revnum_t *actual_revision, const char **basecoll_url_p, - svn_ra_serf__connection_t *conn, + svn_ra_serf__session_t *session, const char *baseline_url, svn_revnum_t revision, apr_pool_t *result_pool, @@ -992,7 +649,7 @@ retrieve_baseline_info(svn_revnum_t *act apr_hash_t *dav_props; const char *basecoll_url; - SVN_ERR(svn_ra_serf__fetch_node_props(&props, conn, + SVN_ERR(svn_ra_serf__fetch_node_props(&props, session, baseline_url, revision, baseline_props, scratch_pool, scratch_pool)); @@ -1042,7 +699,7 @@ retrieve_baseline_info(svn_revnum_t *act static svn_error_t * v1_get_youngest_revnum(svn_revnum_t *youngest, const char **basecoll_url, - svn_ra_serf__connection_t *conn, + svn_ra_serf__session_t *session, const char *vcc_url, apr_pool_t *result_pool, apr_pool_t *scratch_pool) @@ -1052,7 +709,7 @@ v1_get_youngest_revnum(svn_revnum_t *you /* Fetching DAV:checked-in from the VCC (with no Label: to specify a revision) will return the latest Baseline resource's URL. */ - SVN_ERR(svn_ra_serf__fetch_dav_prop(&baseline_url, conn, vcc_url, + SVN_ERR(svn_ra_serf__fetch_dav_prop(&baseline_url, session, vcc_url, SVN_INVALID_REVNUM, "checked-in", scratch_pool, scratch_pool)); @@ -1071,15 +728,15 @@ v1_get_youngest_revnum(svn_revnum_t *you /* First check baseline information cache. */ SVN_ERR(svn_ra_serf__blncache_get_baseline_info(&bc_url, youngest, - conn->session->blncache, + session->blncache, baseline_url, scratch_pool)); if (!bc_url) { - SVN_ERR(retrieve_baseline_info(youngest, &bc_url, conn, + SVN_ERR(retrieve_baseline_info(youngest, &bc_url, session, baseline_url, SVN_INVALID_REVNUM, scratch_pool, scratch_pool)); - SVN_ERR(svn_ra_serf__blncache_set(conn->session->blncache, + SVN_ERR(svn_ra_serf__blncache_set(session->blncache, baseline_url, *youngest, bc_url, scratch_pool)); } @@ -1100,12 +757,12 @@ svn_ra_serf__get_youngest_revnum(svn_rev if (SVN_RA_SERF__HAVE_HTTPV2_SUPPORT(session)) return svn_error_trace(svn_ra_serf__v2_get_youngest_revnum( - youngest, session->conns[0], scratch_pool)); + youngest, session, scratch_pool)); - SVN_ERR(svn_ra_serf__discover_vcc(&vcc_url, session, NULL, scratch_pool)); + SVN_ERR(svn_ra_serf__discover_vcc(&vcc_url, session, scratch_pool)); return svn_error_trace(v1_get_youngest_revnum(youngest, NULL, - session->conns[0], vcc_url, + session, vcc_url, scratch_pool, scratch_pool)); } @@ -1122,9 +779,9 @@ static svn_error_t * get_baseline_info(const char **bc_url, svn_revnum_t *revnum_used, svn_ra_serf__session_t *session, - svn_ra_serf__connection_t *conn, svn_revnum_t revision, - apr_pool_t *pool) + apr_pool_t *result_pool, + apr_pool_t *scratch_pool) { /* If we detected HTTP v2 support on the server, we can construct the baseline collection URL ourselves, and fetch the latest @@ -1138,10 +795,10 @@ get_baseline_info(const char **bc_url, else { SVN_ERR(svn_ra_serf__v2_get_youngest_revnum( - revnum_used, conn, pool)); + revnum_used, session, scratch_pool)); } - *bc_url = apr_psprintf(pool, "%s/%ld", + *bc_url = apr_psprintf(result_pool, "%s/%ld", session->rev_root_stub, *revnum_used); } @@ -1150,20 +807,22 @@ get_baseline_info(const char **bc_url, { const char *vcc_url; - SVN_ERR(svn_ra_serf__discover_vcc(&vcc_url, session, conn, pool)); + SVN_ERR(svn_ra_serf__discover_vcc(&vcc_url, session, scratch_pool)); if (SVN_IS_VALID_REVNUM(revision)) { /* First check baseline information cache. */ SVN_ERR(svn_ra_serf__blncache_get_bc_url(bc_url, session->blncache, - revision, pool)); + revision, result_pool)); if (!*bc_url) { - SVN_ERR(retrieve_baseline_info(NULL, bc_url, conn, - vcc_url, revision, pool, pool)); + SVN_ERR(retrieve_baseline_info(NULL, bc_url, session, + vcc_url, revision, + result_pool, scratch_pool)); SVN_ERR(svn_ra_serf__blncache_set(session->blncache, NULL, - revision, *bc_url, pool)); + revision, *bc_url, + scratch_pool)); } *revnum_used = revision; @@ -1171,8 +830,8 @@ get_baseline_info(const char **bc_url, else { SVN_ERR(v1_get_youngest_revnum(revnum_used, bc_url, - conn, vcc_url, - pool, pool)); + session, vcc_url, + result_pool, scratch_pool)); } } @@ -1184,7 +843,6 @@ svn_error_t * svn_ra_serf__get_stable_url(const char **stable_url, svn_revnum_t *latest_revnum, svn_ra_serf__session_t *session, - svn_ra_serf__connection_t *conn, const char *url, svn_revnum_t revision, apr_pool_t *result_pool, @@ -1198,15 +856,10 @@ svn_ra_serf__get_stable_url(const char * if (! url) url = session->session_url.path; - /* If the caller didn't provide a specific connection for us to use, - we'll use the default connection. */ - if (! conn) - conn = session->conns[0]; - SVN_ERR(get_baseline_info(&basecoll_url, &revnum_used, - session, conn, revision, scratch_pool)); + session, revision, scratch_pool, scratch_pool)); SVN_ERR(svn_ra_serf__get_relative_path(&repos_relpath, url, - session, conn, scratch_pool)); + session, scratch_pool)); *stable_url = svn_path_url_add_component2(basecoll_url, repos_relpath, result_pool); @@ -1218,38 +871,8 @@ svn_ra_serf__get_stable_url(const char * svn_error_t * -svn_ra_serf__get_resource_type(svn_node_kind_t *kind, - apr_hash_t *props) -{ - apr_hash_t *dav_props; - const char *res_type; - - dav_props = apr_hash_get(props, "DAV:", 4); - res_type = svn_prop_get_value(dav_props, "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; -} - - -svn_error_t * svn_ra_serf__fetch_dav_prop(const char **value, - svn_ra_serf__connection_t *conn, + svn_ra_serf__session_t *session, const char *url, svn_revnum_t revision, const char *propname, @@ -1259,7 +882,7 @@ svn_ra_serf__fetch_dav_prop(const char * apr_hash_t *props; apr_hash_t *dav_props; - SVN_ERR(svn_ra_serf__fetch_node_props(&props, conn, url, revision, + SVN_ERR(svn_ra_serf__fetch_node_props(&props, session, url, revision, checked_in_props, scratch_pool, scratch_pool)); dav_props = apr_hash_get(props, "DAV:", 4); @@ -1276,3 +899,19 @@ svn_ra_serf__fetch_dav_prop(const char * return SVN_NO_ERROR; } + +/* Removes all non regular properties from PROPS */ +void +svn_ra_serf__keep_only_regular_props(apr_hash_t *props, + apr_pool_t *scratch_pool) +{ + apr_hash_index_t *hi; + + for (hi = apr_hash_first(scratch_pool, props); hi; hi = apr_hash_next(hi)) + { + const char *propname = apr_hash_this_key(hi); + + if (svn_property_kind2(propname) != svn_prop_regular_kind) + svn_hash_sets(props, propname, NULL); + } +} Modified: subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/ra_serf.h URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/ra_serf.h?rev=1655189&r1=1655188&r2=1655189&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/ra_serf.h (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_ra_serf/ra_serf.h Tue Jan 27 23:27:44 2015 @@ -378,23 +378,23 @@ typedef svn_error_t * /* Callback when the request is done */ typedef svn_error_t * (*svn_ra_serf__response_done_delegate_t)(serf_request_t *request, - void *handler_baton, + void *done_baton, apr_pool_t *scratch_pool); /* Callback for when a request body is needed. */ -/* ### should pass a scratch_pool */ typedef svn_error_t * (*svn_ra_serf__request_body_delegate_t)(serf_bucket_t **body_bkt, void *baton, serf_bucket_alloc_t *alloc, - apr_pool_t *request_pool); + apr_pool_t *request_pool, + apr_pool_t *scratch_pool); /* Callback for when request headers are needed. */ -/* ### should pass a scratch_pool */ typedef svn_error_t * (*svn_ra_serf__request_header_delegate_t)(serf_bucket_t *headers, void *baton, - apr_pool_t *request_pool); + apr_pool_t *request_pool, + apr_pool_t *scratch_pool); /* Callback for when a response has an error. */ typedef svn_error_t * @@ -639,9 +639,11 @@ typedef struct svn_ra_serf__xml_transiti } svn_ra_serf__xml_transition_t; -/* Constructor for */ +/* Constructor for svn_ra_serf__handler_t. Initializes a new handler + with default settings for SESSION. */ svn_ra_serf__handler_t * -svn_ra_serf__create_handler(apr_pool_t *result_pool); +svn_ra_serf__create_handler(svn_ra_serf__session_t *session, + apr_pool_t *result_pool); /* Construct an XML parsing context, based on the TTABLE transition table. As content is parsed, the CLOSED_CB callback will be invoked according @@ -685,7 +687,8 @@ svn_ra_serf__xml_context_done(svn_ra_ser This also initializes HANDLER_POOL to the given RESULT_POOL. */ svn_ra_serf__handler_t * -svn_ra_serf__create_expat_handler(svn_ra_serf__xml_context_t *xmlctx, +svn_ra_serf__create_expat_handler(svn_ra_serf__session_t *session, + svn_ra_serf__xml_context_t *xmlctx, const int *expected_status, apr_pool_t *result_pool); @@ -916,84 +919,51 @@ svn_ra_serf__add_cdata_len_buckets(serf_ /** PROPFIND-related functions **/ +/* Removes all non regular properties from PROPS */ +void +svn_ra_serf__keep_only_regular_props(apr_hash_t *props, + apr_pool_t *scratch_pool); + + /* Callback used via svn_ra_serf__deliver_props2 */ typedef svn_error_t * -(*svn_ra_serf__prop_func)(void *baton, - const char *path, - const char *ns, - const char *name, - const svn_string_t *value, - apr_pool_t *scratch_pool); +(*svn_ra_serf__prop_func_t)(void *baton, + const char *path, + const char *ns, + const char *name, + const svn_string_t *value, + apr_pool_t *scratch_pool); /* - * This function will deliver a PROP_CTX PROPFIND request in the SESS - * serf context for the properties listed in LOOKUP_PROPS at URL for - * DEPTH ("0","1","infinity"). - * - * This function will not block waiting for the response. Callers are - * expected to call svn_ra_serf__wait_for_props(). + * Implementation of svn_ra_serf__prop_func_t that just delivers svn compatible + * properties in the apr_hash_t * that is used as baton. */ svn_error_t * -svn_ra_serf__deliver_props(svn_ra_serf__handler_t **propfind_handler, - apr_hash_t *prop_vals, - svn_ra_serf__session_t *sess, - svn_ra_serf__connection_t *conn, - const char *url, - svn_revnum_t rev, - const char *depth, - const svn_ra_serf__dav_props_t *lookup_props, - apr_pool_t *pool); - +svn_ra_serf__deliver_svn_props(void *baton, + const char *path, + const char *ns, + const char *name, + const svn_string_t *value, + apr_pool_t *scratch_pool); /* - * This function will deliver a PROP_CTX PROPFIND request in the SESS - * serf context for the properties listed in LOOKUP_PROPS at URL for - * DEPTH ("0","1","infinity"). - * - * This function will not block waiting for the response. Callers are - * expected to call svn_ra_serf__wait_for_props(). - */ -svn_error_t * -svn_ra_serf__deliver_props2(svn_ra_serf__handler_t **propfind_handler, - svn_ra_serf__session_t *sess, - svn_ra_serf__connection_t *conn, - const char *path, - svn_revnum_t rev, - const char *depth, - const svn_ra_serf__dav_props_t *find_props, - svn_ra_serf__prop_func prop_func, - void *prop_func_baton, - apr_pool_t *pool); -/* - * This helper function will block until PROPFIND_HANDLER indicates that is - * done or another error is returned. - */ -svn_error_t * -svn_ra_serf__wait_for_props(svn_ra_serf__handler_t *handler, - apr_pool_t *scratch_pool); - -/* This is a blocking version of deliver_props. - - The properties are fetched and placed into RESULTS, allocated in - RESULT_POOL. - - ### more docco about the other params. - - Temporary allocations are made in SCRATCH_POOL. -*/ -svn_error_t * -svn_ra_serf__retrieve_props(apr_hash_t **results, - svn_ra_serf__session_t *sess, - svn_ra_serf__connection_t *conn, - const char *url, - svn_revnum_t rev, - const char *depth, - const svn_ra_serf__dav_props_t *props, - apr_pool_t *result_pool, - apr_pool_t *scratch_pool); + * This function will create a handler for a PROPFIND request, which will deliver + * properties to PROP_FUNC() with PROP_BATON for the properties listed in LOOKUP_PROPS + * at URL for DEPTH ("0","1","infinity"). + */ +svn_error_t * +svn_ra_serf__create_propfind_handler(svn_ra_serf__handler_t **handler, + svn_ra_serf__session_t *session, + const char *path, + svn_revnum_t rev, + const char *depth, + const svn_ra_serf__dav_props_t *find_props, + svn_ra_serf__prop_func_t prop_func, + void *prop_func_baton, + apr_pool_t *result_pool); -/* Using CONN, fetch the properties specified by WHICH_PROPS using CONN +/* Using SESSION, fetch the properties specified by WHICH_PROPS using CONN for URL at REVISION. The resulting properties are placed into a 2-level hash in RESULTS, mapping NAMESPACE -> hash<PROPNAME, PROPVALUE>, which is allocated in RESULT_POOL. @@ -1006,7 +976,7 @@ svn_ra_serf__retrieve_props(apr_hash_t * Temporary allocations are made in SCRATCH_POOL. */ svn_error_t * svn_ra_serf__fetch_node_props(apr_hash_t **results, - svn_ra_serf__connection_t *conn, + svn_ra_serf__session_t *session, const char *url, svn_revnum_t revision, const svn_ra_serf__dav_props_t *which_props, @@ -1014,7 +984,7 @@ svn_ra_serf__fetch_node_props(apr_hash_t apr_pool_t *scratch_pool); -/* Using CONN, fetch a DAV: property from the resource identified by URL +/* Using SESSION, fetch a DAV: property from the resource identified by URL within REVISION. The PROPNAME may be one of: "checked-in" @@ -1028,66 +998,13 @@ svn_ra_serf__fetch_node_props(apr_hash_t Temporary allocations are made in SCRATCH_POOL. */ svn_error_t * svn_ra_serf__fetch_dav_prop(const char **value, - svn_ra_serf__connection_t *conn, + svn_ra_serf__session_t *session, const char *url, svn_revnum_t revision, const char *propname, apr_pool_t *result_pool, apr_pool_t *scratch_pool); - -/* Set PROPS for PATH at REV revision with a NS:NAME VAL. - * - * The POOL governs allocation. - */ -void -svn_ra_serf__set_ver_prop(apr_hash_t *props, - const char *path, svn_revnum_t rev, - const char *ns, const char *name, - const svn_string_t *val, apr_pool_t *pool); -#define svn_ra_serf__set_rev_prop svn_ra_serf__set_ver_prop - -/** Property walker functions **/ - -typedef svn_error_t * -(*svn_ra_serf__walker_visitor_t)(void *baton, - const char *ns, - const char *name, - const svn_string_t *val, - apr_pool_t *pool); - -svn_error_t * -svn_ra_serf__walk_all_props(apr_hash_t *props, - const char *name, - svn_revnum_t rev, - svn_ra_serf__walker_visitor_t walker, - void *baton, - apr_pool_t *pool); - - -/* Like walk_all_props(), but a 2-level hash. */ -svn_error_t * -svn_ra_serf__walk_node_props(apr_hash_t *props, - svn_ra_serf__walker_visitor_t walker, - void *baton, - apr_pool_t *scratch_pool); - - -typedef svn_error_t * -(*svn_ra_serf__path_rev_walker_t)(void *baton, - const char *path, - const char *ns, - const char *name, - const svn_string_t *val, - apr_pool_t *pool); -svn_error_t * -svn_ra_serf__walk_all_paths(apr_hash_t *props, - svn_revnum_t rev, - svn_ra_serf__path_rev_walker_t walker, - void *baton, - apr_pool_t *pool); - - /* Map a property name, as passed over the wire, into its corresponding Subversion-internal name. The returned name will be a static value, or allocated within RESULT_POOL. @@ -1099,75 +1016,6 @@ svn_ra_serf__svnname_from_wirename(const const char *name, apr_pool_t *result_pool); - -/* Select the basic revision properties from the set of "all" properties. - Return these in *REVPROPS, allocated from RESULT_POOL. */ -svn_error_t * -svn_ra_serf__select_revprops(apr_hash_t **revprops, - const char *name, - svn_revnum_t rev, - apr_hash_t *all_revprops, - apr_pool_t *result_pool, - apr_pool_t *scratch_pool); - - -/* PROPS is nested hash tables mapping NS -> NAME -> VALUE. - This function takes the NS:NAME:VALUE hashes and flattens them into a set of - names to VALUE. The names are composed of NS:NAME, with specific - rewrite from wire names (DAV) to SVN names. This mapping is managed - by the svn_ra_serf__set_baton_props() function. - - FLAT_PROPS is allocated in RESULT_POOL. - ### right now, we do a shallow copy from PROPS to FLAT_PROPS. therefore, - ### the names and values in PROPS must be in the proper pool. - - Temporary allocations are made in SCRATCH_POOL. */ -svn_error_t * -svn_ra_serf__flatten_props(apr_hash_t **flat_props, - apr_hash_t *props, - apr_pool_t *result_pool, - apr_pool_t *scratch_pool); - - -/* Return the property value for PATH at REV revision with a NS:NAME. - * PROPS is a four-level nested hash: (svn_revnum_t => char *path => - * char *ns => char *name => svn_string_t *). */ -const svn_string_t * -svn_ra_serf__get_ver_prop_string(apr_hash_t *props, - const char *path, svn_revnum_t rev, - const char *ns, const char *name); - -/* Same as svn_ra_serf__get_ver_prop_string(), but returns a C string. */ -const char * -svn_ra_serf__get_ver_prop(apr_hash_t *props, - const char *path, svn_revnum_t rev, - const char *ns, const char *name); - -/* Same as svn_ra_serf__get_ver_prop_string(), but for the unknown revision. */ -const svn_string_t * -svn_ra_serf__get_prop_string(apr_hash_t *props, - const char *path, - const char *ns, - const char *name); - -/* Same as svn_ra_serf__get_ver_prop(), but for the unknown revision. */ -const char * -svn_ra_serf__get_prop(apr_hash_t *props, - const char *path, - const char *ns, - const char *name); - -/* Same as svn_ra_serf__set_rev_prop(), but for the unknown revision. */ -void -svn_ra_serf__set_prop(apr_hash_t *props, const char *path, - 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); - - /** MERGE-related functions **/ /* Create an MERGE request aimed at the SESSION url, requesting the @@ -1178,7 +1026,6 @@ svn_ra_serf__get_resource_type(svn_node_ svn_error_t * svn_ra_serf__run_merge(const svn_commit_info_t **commit_info, svn_ra_serf__session_t *session, - svn_ra_serf__connection_t *conn, const char *merge_resource_url, apr_hash_t *lock_tokens, svn_boolean_t keep_locks, @@ -1206,7 +1053,7 @@ svn_ra_serf__probe_proxy(svn_ra_serf__se All temporary allocations will be made in SCRATCH_POOL. */ svn_error_t * svn_ra_serf__v2_get_youngest_revnum(svn_revnum_t *youngest, - svn_ra_serf__connection_t *conn, + svn_ra_serf__session_t *session, apr_pool_t *scratch_pool); @@ -1221,35 +1068,29 @@ svn_ra_serf__v2_get_youngest_revnum(svn_ All temporary allocations will be made in SCRATCH_POOL. */ svn_error_t * svn_ra_serf__v1_get_activity_collection(const char **activity_url, - svn_ra_serf__connection_t *conn, + svn_ra_serf__session_t *session, apr_pool_t *result_pool, apr_pool_t *scratch_pool); /* Set @a VCC_URL to the default VCC for our repository based on @a * ORIG_PATH for the session @a SESSION, ensuring that the VCC URL and - * repository root URLs are cached in @a SESSION. Use @a CONN for any - * required network communications if it is non-NULL; otherwise use the - * default connection. + * repository root URLs are cached in @a SESSION. * - * All temporary allocations will be made in @a POOL. */ + * All temporary allocations will be made in @a SCRATCH_POOL. */ svn_error_t * svn_ra_serf__discover_vcc(const char **vcc_url, svn_ra_serf__session_t *session, - svn_ra_serf__connection_t *conn, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /* Set @a REPORT_TARGET to the URI of the resource at which generic - * (path-agnostic) REPORTs should be aimed for @a SESSION. Use @a - * CONN for any required network communications if it is non-NULL; - * otherwise use the default connection. + * (path-agnostic) REPORTs should be aimed for @a SESSION. * * All temporary allocations will be made in @a POOL. */ svn_error_t * svn_ra_serf__report_resource(const char **report_target, svn_ra_serf__session_t *session, - svn_ra_serf__connection_t *conn, apr_pool_t *pool); /* Set @a REL_PATH to a path (not URI-encoded) relative to the root of @@ -1261,7 +1102,6 @@ svn_error_t * svn_ra_serf__get_relative_path(const char **rel_path, const char *orig_path, svn_ra_serf__session_t *session, - svn_ra_serf__connection_t *conn, apr_pool_t *pool); @@ -1288,11 +1128,9 @@ svn_ra_serf__get_youngest_revnum(svn_rev The DAV RA provider(s) solve this by generating a URL that is specific to a revision by using a URL into a "baseline collection". - For a specified SESSION, with an optional CONN (if NULL, then the - session's default connection will be used; specifically SESSION->conns[0]), - generate a revision-stable URL for URL at REVISION. If REVISION is - SVN_INVALID_REVNUM, then the stable URL will refer to the youngest - revision at the time this function was called. + For a specified SESSION, generate a revision-stable URL for URL at + REVISION. If REVISION is SVN_INVALID_REVNUM, then the stable URL will + refer to the youngest revision at the time this function was called. If URL is NULL, then the session root will be used. @@ -1311,7 +1149,6 @@ svn_error_t * svn_ra_serf__get_stable_url(const char **stable_url, svn_revnum_t *latest_revnum, svn_ra_serf__session_t *session, - svn_ra_serf__connection_t *conn, const char *url, svn_revnum_t revision, apr_pool_t *result_pool, @@ -1461,7 +1298,12 @@ svn_ra_serf__get_dated_revision(svn_ra_s apr_time_t tm, apr_pool_t *pool); -/* Implements svn_ra__vtable_t.get_commit_editor(). */ +/* Implements svn_ra__vtable_t.get_commit_editor(). + * + * Note: Like other commit editors, the returned editor requires that the + * @c copyfrom_path parameter passed to its @c add_file and @c add_directory + * methods is a URL, not a relative path. + */ svn_error_t * svn_ra_serf__get_commit_editor(svn_ra_session_t *session, const svn_delta_editor_t **editor,
