svn_error_t * svn_ra_serf__get_stable_url(const char **stable_url, svn_revnum_t *latest_revnum, svn_ra_serf__session_t *session, const char *url, svn_revnum_t revision, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { const char *basecoll_url; const char *repos_relpath; svn_revnum_t revnum_used; /* No URL? No sweat. We'll use the session URL. */ if (! url) url = session->session_url.path; SVN_ERR(get_baseline_info(&basecoll_url, &revnum_used, session, revision, scratch_pool, scratch_pool)); SVN_ERR(svn_ra_serf__get_relative_path(&repos_relpath, url, session, scratch_pool)); *stable_url = svn_path_url_add_component2(basecoll_url, repos_relpath, result_pool); if (latest_revnum) *latest_revnum = revnum_used; return SVN_NO_ERROR; }
svn_error_t * svn_ra_serf__get_locks(svn_ra_session_t *ra_session, apr_hash_t **locks, const char *path, svn_depth_t depth, apr_pool_t *pool) { lock_context_t *lock_ctx; svn_ra_serf__session_t *session = ra_session->priv; svn_ra_serf__handler_t *handler; svn_ra_serf__xml_context_t *xmlctx; const char *req_url, *rel_path; 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)); lock_ctx = apr_pcalloc(pool, sizeof(*lock_ctx)); lock_ctx->pool = pool; lock_ctx->path = apr_pstrcat(pool, "/", rel_path, (char *)NULL); lock_ctx->requested_depth = depth; lock_ctx->hash = apr_hash_make(pool); xmlctx = svn_ra_serf__xml_context_create(getlocks_ttable, NULL, getlocks_closed, NULL, lock_ctx, pool); handler = svn_ra_serf__create_expat_handler(xmlctx, 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; SVN_ERR(svn_ra_serf__context_run_one(handler, pool)); /* We get a 404 when a path doesn't exist in HEAD, but it might have existed earlier (E.g. 'svn ls http://s/svn/trunk/file@1' */ if (handler->sline.code != 404) { SVN_ERR(svn_ra_serf__error_on_status(handler->sline, handler->path, handler->location)); } *locks = lock_ctx->hash; return SVN_NO_ERROR; }
svn_error_t * svn_ra_serf__get_locks(svn_ra_session_t *ra_session, apr_hash_t **locks, const char *path, svn_depth_t depth, apr_pool_t *pool) { lock_context_t *lock_ctx; svn_ra_serf__session_t *session = ra_session->priv; svn_ra_serf__handler_t *handler; svn_ra_serf__xml_context_t *xmlctx; const char *req_url, *rel_path; 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, pool)); lock_ctx = apr_pcalloc(pool, sizeof(*lock_ctx)); lock_ctx->pool = pool; lock_ctx->path = apr_pstrcat(pool, "/", rel_path, SVN_VA_NULL); lock_ctx->requested_depth = depth; lock_ctx->hash = apr_hash_make(pool); xmlctx = svn_ra_serf__xml_context_create(getlocks_ttable, NULL, getlocks_closed, NULL, lock_ctx, 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->body_delegate = create_getlocks_body; handler->body_delegate_baton = lock_ctx; err = svn_ra_serf__context_run_one(handler, pool); if (err) { if (svn_error_find_cause(err, SVN_ERR_UNSUPPORTED_FEATURE)) { /* The server told us that it doesn't support this report type. We return the documented error for svn_ra_get_locks(), but with the original error report */ return svn_error_create(SVN_ERR_RA_NOT_IMPLEMENTED, err, NULL); } else if (err->apr_err == SVN_ERR_FS_NOT_FOUND) { /* File doesn't exist in HEAD: Not an error */ svn_error_clear(err); } else return svn_error_trace(err); } /* We get a 404 when a path doesn't exist in HEAD, but it might have existed earlier (E.g. 'svn ls http://s/svn/trunk/file@1' */ if (handler->sline.code != 200 && handler->sline.code != 404) { return svn_error_trace(svn_ra_serf__unexpected_status(handler)); } *locks = lock_ctx->hash; return SVN_NO_ERROR; }