/* Set *REVNUM to the revision specified by REVISION (or to SVN_INVALID_REVNUM if that has the type 'unspecified'), possibly making use of the YOUNGEST revision number in REPOS. */ static svn_error_t * get_revnum (svn_revnum_t *revnum, const svn_opt_revision_t *revision, svn_revnum_t youngest, svn_repos_t *repos, apr_pool_t *pool) { if (revision->kind == svn_opt_revision_number) *revnum = revision->value.number; else if (revision->kind == svn_opt_revision_head) *revnum = youngest; else if (revision->kind == svn_opt_revision_date) SVN_ERR (svn_repos_dated_revision (revnum, repos, revision->value.date, pool)); else if (revision->kind == svn_opt_revision_unspecified) *revnum = SVN_INVALID_REVNUM; else return svn_error_create (SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("Invalid revision specifier")); if (*revnum > youngest) return svn_error_createf (SVN_ERR_CL_ARG_PARSING_ERROR, NULL, _("Revisions must not be greater than the youngest revision (%ld)"), youngest); return SVN_NO_ERROR; }
static svn_error_t * svn_ra_local__get_dated_revision(svn_ra_session_t *session, svn_revnum_t *revision, apr_time_t tm, apr_pool_t *pool) { svn_ra_local__session_baton_t *sess = session->priv; return svn_repos_dated_revision(revision, sess->repos, tm, pool); }
/* Respond to a S:dated-rev-report request. The request contains a * DAV:creationdate element giving the requested date; the response * contains a DAV:version-name element giving the most recent revision * as of that date. */ dav_error * dav_svn__dated_rev_report(const dav_resource *resource, const apr_xml_doc *doc, ap_filter_t *output) { apr_xml_elem *child; int ns; apr_time_t tm = (apr_time_t) -1; svn_revnum_t rev; apr_bucket_brigade *bb; svn_error_t *err; apr_status_t apr_err; dav_error *derr = NULL; /* Find the DAV:creationdate element and get the requested time from it. */ ns = dav_svn__find_ns(doc->namespaces, "DAV:"); if (ns != -1) { for (child = doc->root->first_child; child != NULL; child = child->next) { if (child->ns != ns || strcmp(child->name, SVN_DAV__CREATIONDATE) != 0) continue; /* If this fails, we'll notice below, so ignore any error for now. */ svn_error_clear (svn_time_from_cstring(&tm, dav_xml_get_cdata(child, resource->pool, 1), resource->pool)); } } if (tm == (apr_time_t) -1) { return dav_svn__new_error(resource->pool, HTTP_BAD_REQUEST, 0, "The request does not contain a valid " "'DAV:" SVN_DAV__CREATIONDATE "' element."); } /* Do the actual work of finding the revision by date. */ if ((err = svn_repos_dated_revision(&rev, resource->info->repos->repos, tm, resource->pool)) != SVN_NO_ERROR) { svn_error_clear(err); return dav_svn__new_error(resource->pool, HTTP_INTERNAL_SERVER_ERROR, 0, "Could not access revision times."); } bb = apr_brigade_create(resource->pool, output->c->bucket_alloc); apr_err = ap_fprintf(output, bb, DAV_XML_HEADER DEBUG_CR "<S:dated-rev-report xmlns:S=\"" SVN_XML_NAMESPACE "\" " "xmlns:D=\"DAV:\">" DEBUG_CR "<D:" SVN_DAV__VERSION_NAME ">%ld</D:" SVN_DAV__VERSION_NAME ">""</S:dated-rev-report>", rev); if (apr_err) derr = dav_svn__convert_err(svn_error_create(apr_err, 0, NULL), HTTP_INTERNAL_SERVER_ERROR, "Error writing REPORT response.", resource->pool); return dav_svn__final_flush_or_error(resource->info->r, bb, output, derr, resource->pool); }