static svn_error_t * svn_ra_local__get_location_segments(svn_ra_session_t *session, const char *path, svn_revnum_t peg_revision, svn_revnum_t start_rev, svn_revnum_t end_rev, svn_location_segment_receiver_t receiver, void *receiver_baton, apr_pool_t *pool) { svn_ra_local__session_baton_t *sess = session->priv; const char *abs_path = svn_path_join(sess->fs_path->data, path, pool); return svn_repos_node_location_segments(sess->repos, abs_path, peg_revision, start_rev, end_rev, receiver, receiver_baton, NULL, NULL, pool); }
dav_error * dav_svn__get_location_segments_report(const dav_resource *resource, const apr_xml_doc *doc, ap_filter_t *output) { svn_error_t *serr; dav_error *derr = NULL; apr_bucket_brigade *bb; int ns; apr_xml_elem *child; const char *abs_path = NULL; svn_revnum_t peg_revision = SVN_INVALID_REVNUM; svn_revnum_t start_rev = SVN_INVALID_REVNUM; svn_revnum_t end_rev = SVN_INVALID_REVNUM; dav_svn__authz_read_baton arb; struct location_segment_baton location_segment_baton; /* Sanity check. */ if (!resource->info->repos_path) return dav_svn__new_error(resource->pool, HTTP_BAD_REQUEST, 0, "The request does not specify a repository path"); ns = dav_svn__find_ns(doc->namespaces, SVN_XML_NAMESPACE); if (ns == -1) { return dav_svn__new_error_svn(resource->pool, HTTP_BAD_REQUEST, 0, "The request does not contain the 'svn:' " "namespace, so it is not going to have " "certain required elements"); } /* Gather the parameters. */ for (child = doc->root->first_child; child != NULL; child = child->next) { /* If this element isn't one of ours, then skip it. */ if (child->ns != ns) continue; if (strcmp(child->name, "peg-revision") == 0) { peg_revision = SVN_STR_TO_REV(dav_xml_get_cdata(child, resource->pool, 1)); } else if (strcmp(child->name, "start-revision") == 0) { start_rev = SVN_STR_TO_REV(dav_xml_get_cdata(child, resource->pool, 1)); } else if (strcmp(child->name, "end-revision") == 0) { end_rev = SVN_STR_TO_REV(dav_xml_get_cdata(child, resource->pool, 1)); } else if (strcmp(child->name, "path") == 0) { const char *rel_path = dav_xml_get_cdata(child, resource->pool, 0); if ((derr = dav_svn__test_canonical(rel_path, resource->pool))) return derr; /* Force REL_PATH to be a relative path, not an fspath. */ rel_path = svn_relpath_canonicalize(rel_path, resource->pool); /* Append the REL_PATH to the base FS path to get an absolute repository path. */ abs_path = svn_fspath__join(resource->info->repos_path, rel_path, resource->pool); } } /* Check that all parameters are present and valid. */ if (! abs_path) return dav_svn__new_error_svn(resource->pool, HTTP_BAD_REQUEST, 0, "Not all parameters passed"); /* No START_REV or PEG_REVISION? We'll use HEAD. */ if (!SVN_IS_VALID_REVNUM(start_rev) || !SVN_IS_VALID_REVNUM(peg_revision)) { svn_revnum_t youngest; serr = svn_fs_youngest_rev(&youngest, resource->info->repos->fs, resource->pool); if (serr != NULL) return dav_svn__convert_err(serr, HTTP_INTERNAL_SERVER_ERROR, "Could not determine youngest revision", resource->pool); if (!SVN_IS_VALID_REVNUM(start_rev)) start_rev = youngest; if (!SVN_IS_VALID_REVNUM(peg_revision)) peg_revision = youngest; } /* No END_REV? We'll use 0. */ if (!SVN_IS_VALID_REVNUM(end_rev)) end_rev = 0; if (end_rev > start_rev) return dav_svn__new_error_svn(resource->pool, HTTP_BAD_REQUEST, 0, "End revision must not be younger than " "start revision"); if (start_rev > peg_revision) return dav_svn__new_error_svn(resource->pool, HTTP_BAD_REQUEST, 0, "Start revision must not be younger than " "peg revision"); /* Build an authz read baton. */ arb.r = resource->info->r; arb.repos = resource->info->repos; /* Build the bucket brigade we'll use for output. */ bb = apr_brigade_create(resource->pool, output->c->bucket_alloc); /* Do what we came here for. */ location_segment_baton.sent_opener = FALSE; location_segment_baton.output = output; location_segment_baton.bb = bb; if ((serr = svn_repos_node_location_segments(resource->info->repos->repos, abs_path, peg_revision, start_rev, end_rev, location_segment_receiver, &location_segment_baton, dav_svn__authz_read_func(&arb), &arb, resource->pool))) { derr = dav_svn__convert_err(serr, HTTP_BAD_REQUEST, NULL, resource->pool); goto cleanup; } if ((serr = maybe_send_opener(&location_segment_baton))) { derr = dav_svn__convert_err(serr, HTTP_INTERNAL_SERVER_ERROR, "Error beginning REPORT response.", resource->pool); goto cleanup; } if ((serr = dav_svn__brigade_puts(bb, output, "</S:get-location-segments-report>" DEBUG_CR))) { derr = dav_svn__convert_err(serr, HTTP_INTERNAL_SERVER_ERROR, "Error ending REPORT response.", resource->pool); goto cleanup; } cleanup: return dav_svn__final_flush_or_error(resource->info->r, bb, output, derr, resource->pool); }