svn_error_t * svn_ra_neon__get_starting_props(svn_ra_neon__resource_t **rsrc, svn_ra_neon__session_t *sess, const char *url, const char *label, apr_pool_t *pool) { svn_string_t *propval; SVN_ERR(svn_ra_neon__get_props_resource(rsrc, sess, url, label, starting_props, pool)); /* Cache some of the resource information. */ if (! sess->vcc) { propval = apr_hash_get((*rsrc)->propset, SVN_RA_NEON__PROP_VCC, APR_HASH_KEY_STRING); if (propval) sess->vcc = apr_pstrdup(sess->pool, propval->data); } if (! sess->uuid) { propval = apr_hash_get((*rsrc)->propset, SVN_RA_NEON__PROP_REPOSITORY_UUID, APR_HASH_KEY_STRING); if (propval) sess->uuid = apr_pstrdup(sess->pool, propval->data); } return SVN_NO_ERROR; }
svn_error_t * svn_ra_neon__get_one_prop(const svn_string_t **propval, svn_ra_neon__session_t *sess, const char *url, const char *label, const ne_propname *propname, apr_pool_t *pool) { svn_ra_neon__resource_t *rsrc; ne_propname props[2] = { { 0 } }; const char *name; const svn_string_t *value; props[0] = *propname; SVN_ERR(svn_ra_neon__get_props_resource(&rsrc, sess, url, label, props, pool)); name = apr_pstrcat(pool, propname->nspace, propname->name, NULL); value = apr_hash_get(rsrc->propset, name, APR_HASH_KEY_STRING); if (value == NULL) { /* ### need an SVN_ERR here */ return svn_error_createf(SVN_ERR_FS_NOT_FOUND, NULL, _("'%s' was not present on the resource"), name); } *propval = value; return SVN_NO_ERROR; }
/* Sets *SUPPORTS_DEADPROP_COUNT to non-zero if server supports * deadprop-count property. */ svn_error_t * svn_ra_neon__get_deadprop_count_support(svn_boolean_t *supported, svn_ra_neon__session_t *ras, const char *final_url, apr_pool_t *pool) { /* The property we need to fetch to see whether the server we are connected to supports the deadprop-count property. */ static const ne_propname deadprop_count_support_props[] = { { SVN_DAV_PROP_NS_DAV, "deadprop-count" }, { NULL } }; if (SVN_RA_NEON__HAVE_HTTPV2_SUPPORT(ras)) { /* HTTPv2 enabled servers always supports deadprop-count property. */ *supported = TRUE; return SVN_NO_ERROR; } /* Check if we already checked deadprop_count support. */ if (ras->supports_deadprop_count == svn_tristate_unknown) { svn_ra_neon__resource_t *rsrc; const svn_string_t *deadprop_count; SVN_ERR(svn_ra_neon__get_props_resource(&rsrc, ras, final_url, NULL, deadprop_count_support_props, pool)); deadprop_count = apr_hash_get(rsrc->propset, SVN_RA_NEON__PROP_DEADPROP_COUNT, APR_HASH_KEY_STRING); if (deadprop_count != NULL) { ras->supports_deadprop_count = svn_tristate_true; } else { ras->supports_deadprop_count = svn_tristate_false; } } *supported = (ras->supports_deadprop_count == svn_tristate_true); return SVN_NO_ERROR; }
svn_error_t *svn_ra_neon__get_baseline_props(svn_string_t *bc_relative, svn_ra_neon__resource_t **bln_rsrc, svn_ra_neon__session_t *sess, const char *url, svn_revnum_t revision, const ne_propname *which_props, apr_pool_t *pool) { svn_ra_neon__resource_t *rsrc; const char *vcc; const svn_string_t *relative_path; const char *my_bc_relative; const char *lopped_path; /* ### we may be able to replace some/all of this code with an ### expand-property REPORT when that is available on the server. */ /* ------------------------------------------------------------------- STEP 1 Fetch the following properties from the given URL (or, if URL no longer exists in HEAD, get the properties from the nearest still-existing parent resource): *) DAV:version-controlled-configuration so that we can reach the baseline information. *) svn:baseline-relative-path so that we can find this resource within a Baseline Collection. If we need to search up parent directories, then the relative path is this property value *plus* any trailing components we had to chop off. *) DAV:resourcetype so that we can identify whether this resource is a collection or not -- assuming we never had to search up parent directories. */ SVN_ERR(svn_ra_neon__search_for_starting_props(&rsrc, &lopped_path, sess, url, pool)); SVN_ERR(svn_ra_neon__get_vcc(&vcc, sess, url, pool)); if (vcc == NULL) { /* ### better error reporting... */ /* ### need an SVN_ERR here */ return svn_error_create(APR_EGENERAL, NULL, _("The VCC property was not found on the " "resource")); } /* Allocate our own bc_relative path. */ relative_path = apr_hash_get(rsrc->propset, SVN_RA_NEON__PROP_BASELINE_RELPATH, APR_HASH_KEY_STRING); if (relative_path == NULL) { /* ### better error reporting... */ /* ### need an SVN_ERR here */ return svn_error_create(APR_EGENERAL, NULL, _("The relative-path property was not " "found on the resource")); } /* don't forget to tack on the parts we lopped off in order to find the VCC... We are expected to return a URI decoded relative path, so decode the lopped path first. */ my_bc_relative = svn_path_join(relative_path->data, svn_path_uri_decode(lopped_path, pool), pool); /* if they want the relative path (could be, they're just trying to find the baseline collection), then return it */ if (bc_relative) { bc_relative->data = my_bc_relative; bc_relative->len = strlen(my_bc_relative); } /* ------------------------------------------------------------------- STEP 2 We have the Version Controlled Configuration (VCC). From here, we need to reach the Baseline for specified revision. If the revision is SVN_INVALID_REVNUM, then we're talking about the HEAD revision. We have one extra step to reach the Baseline: *) Fetch the DAV:checked-in from the VCC; it points to the Baseline. If we have a specific revision, then we use a Label header when fetching props from the VCC. This will direct us to the Baseline with that label (in this case, the label == the revision number). From the Baseline, we fetch the following properties: *) DAV:baseline-collection, which is a complete tree of the Baseline (in SVN terms, this tree is rooted at a specific revision) *) DAV:version-name to get the revision of the Baseline that we are querying. When asking about the HEAD, this tells us its revision. */ if (revision == SVN_INVALID_REVNUM) { /* Fetch the latest revision */ const svn_string_t *baseline; /* Get the Baseline from the DAV:checked-in value, then fetch its DAV:baseline-collection property. */ /* ### should wrap this with info about rsrc==VCC */ SVN_ERR(svn_ra_neon__get_one_prop(&baseline, sess, vcc, NULL, &svn_ra_neon__checked_in_prop, pool)); /* ### do we want to optimize the props we fetch, based on what the ### user asked for? i.e. omit version-name if latest_rev is NULL */ SVN_ERR(svn_ra_neon__get_props_resource(&rsrc, sess, baseline->data, NULL, which_props, pool)); } else { /* Fetch a specific revision */ char label[20]; /* ### send Label hdr, get DAV:baseline-collection [from the baseline] */ apr_snprintf(label, sizeof(label), "%ld", revision); /* ### do we want to optimize the props we fetch, based on what the ### user asked for? i.e. omit version-name if latest_rev is NULL */ SVN_ERR(svn_ra_neon__get_props_resource(&rsrc, sess, vcc, label, which_props, pool)); } /* Return the baseline rsrc, which now contains whatever set of props the caller wanted. */ *bln_rsrc = rsrc; return SVN_NO_ERROR; }