/* This implements the svn_client_blame_receiver3_t interface. */ static svn_error_t * blame_receiver(void *baton, svn_revnum_t start_revnum, svn_revnum_t end_revnum, apr_int64_t line_no, svn_revnum_t revision, apr_hash_t *rev_props, svn_revnum_t merged_revision, apr_hash_t *merged_rev_props, const char *merged_path, const char *line, svn_boolean_t local_change, apr_pool_t *pool) { svn_cl__opt_state_t *opt_state = ((blame_baton_t *) baton)->opt_state; svn_stream_t *out = ((blame_baton_t *)baton)->out; svn_boolean_t use_merged = FALSE; if (opt_state->use_merge_history) { /* Choose which revision to use. If they aren't equal, prefer the earliest revision. Since we do a forward blame, we want to the first revision which put the line in its current state, so we use the earliest revision. If we ever switch to a backward blame algorithm, we may need to adjust this. */ if (merged_revision < revision) { SVN_ERR(svn_stream_printf(out, pool, "G ")); use_merged = TRUE; } else SVN_ERR(svn_stream_printf(out, pool, " ")); } if (use_merged) SVN_ERR(print_line_info(out, merged_revision, svn_prop_get_value(merged_rev_props, SVN_PROP_REVISION_AUTHOR), svn_prop_get_value(merged_rev_props, SVN_PROP_REVISION_DATE), merged_path, opt_state->verbose, end_revnum, pool)); else SVN_ERR(print_line_info(out, revision, svn_prop_get_value(rev_props, SVN_PROP_REVISION_AUTHOR), svn_prop_get_value(rev_props, SVN_PROP_REVISION_DATE), NULL, opt_state->verbose, end_revnum, pool)); return svn_stream_printf(out, pool, "%s%s", line, APR_EOL_STR); }
/* * Contact the server (using CONN) to calculate baseline * information for BASELINE_URL at REVISION (which may be * SVN_INVALID_REVNUM to query the HEAD revision). * * If ACTUAL_REVISION is non-NULL, set *ACTUAL_REVISION to revision * retrieved from the server as part of this process (which should * match REVISION when REVISION is valid). Set *BASECOLL_URL_P to the * baseline collection URL. */ static svn_error_t * retrieve_baseline_info(svn_revnum_t *actual_revision, const char **basecoll_url_p, svn_ra_serf__session_t *session, const char *baseline_url, svn_revnum_t revision, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { apr_hash_t *props; apr_hash_t *dav_props; const char *basecoll_url; SVN_ERR(svn_ra_serf__fetch_node_props(&props, session, baseline_url, revision, baseline_props, scratch_pool, scratch_pool)); dav_props = apr_hash_get(props, "DAV:", 4); /* If DAV_PROPS is NULL, then svn_prop_get_value() will return NULL. */ basecoll_url = svn_prop_get_value(dav_props, "baseline-collection"); if (!basecoll_url) { return svn_error_create(SVN_ERR_RA_DAV_PROPS_NOT_FOUND, NULL, _("The PROPFIND response did not include " "the requested baseline-collection value")); } *basecoll_url_p = svn_urlpath__canonicalize(basecoll_url, result_pool); if (actual_revision) { const char *version_name; version_name = svn_prop_get_value(dav_props, SVN_DAV__VERSION_NAME); if (version_name) { apr_int64_t rev; SVN_ERR(svn_cstring_atoi64(&rev, version_name)); *actual_revision = (svn_revnum_t)rev; } if (!version_name || !SVN_IS_VALID_REVNUM(*actual_revision)) return svn_error_create(SVN_ERR_RA_DAV_PROPS_NOT_FOUND, NULL, _("The PROPFIND response did not include " "the requested version-name value")); } return SVN_NO_ERROR; }
svn_error_t * svn_ra_serf__fetch_dav_prop(const char **value, 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) { apr_hash_t *props; apr_hash_t *dav_props; 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); if (dav_props == NULL) return svn_error_create(SVN_ERR_RA_DAV_PROPS_NOT_FOUND, NULL, _("The PROPFIND response did not include " "the requested 'DAV:' properties")); /* We wouldn't get here if the resource was not found (404), so the property should be present. Note: it is okay to call apr_pstrdup() with NULL. */ *value = apr_pstrdup(result_pool, svn_prop_get_value(dav_props, propname)); return SVN_NO_ERROR; }
svn_error_t * svn_wc__get_translate_info(svn_subst_eol_style_t *style, const char **eol, apr_hash_t **keywords, svn_boolean_t *special, svn_wc__db_t *db, const char *local_abspath, apr_hash_t *props, svn_boolean_t for_normalization, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { const char *propval; SVN_ERR_ASSERT(svn_dirent_is_absolute(local_abspath)); if (props == NULL) SVN_ERR(svn_wc__get_actual_props(&props, db, local_abspath, scratch_pool, scratch_pool)); if (eol) { propval = svn_prop_get_value(props, SVN_PROP_EOL_STYLE); svn_subst_eol_style_from_value(style, eol, propval); } if (keywords) { propval = svn_prop_get_value(props, SVN_PROP_KEYWORDS); if (!propval || *propval == '\0') *keywords = NULL; else SVN_ERR(svn_wc__expand_keywords(keywords, db, local_abspath, NULL, propval, for_normalization, result_pool, scratch_pool)); } if (special) { propval = svn_prop_get_value(props, SVN_PROP_SPECIAL); *special = (propval != NULL); } return SVN_NO_ERROR; }
/* This implements the svn_client_blame_receiver3_t interface, printing XML to stdout. */ static svn_error_t * blame_receiver_xml(void *baton, svn_revnum_t start_revnum, svn_revnum_t end_revnum, apr_int64_t line_no, svn_revnum_t revision, apr_hash_t *rev_props, svn_revnum_t merged_revision, apr_hash_t *merged_rev_props, const char *merged_path, const char *line, svn_boolean_t local_change, apr_pool_t *pool) { svn_cl__opt_state_t *opt_state = ((blame_baton_t *) baton)->opt_state; svn_stringbuf_t *sb = ((blame_baton_t *) baton)->sbuf; /* "<entry ...>" */ /* line_no is 0-based, but the rest of the world is probably Pascal programmers, so we make them happy and output 1-based line numbers. */ svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "entry", "line-number", apr_psprintf(pool, "%" APR_INT64_T_FMT, line_no + 1), NULL); if (SVN_IS_VALID_REVNUM(revision)) svn_cl__print_xml_commit(&sb, revision, svn_prop_get_value(rev_props, SVN_PROP_REVISION_AUTHOR), svn_prop_get_value(rev_props, SVN_PROP_REVISION_DATE), pool); if (opt_state->use_merge_history && SVN_IS_VALID_REVNUM(merged_revision)) { /* "<merged>" */ svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "merged", "path", merged_path, NULL); svn_cl__print_xml_commit(&sb, merged_revision, svn_prop_get_value(merged_rev_props, SVN_PROP_REVISION_AUTHOR), svn_prop_get_value(merged_rev_props, SVN_PROP_REVISION_DATE), pool); /* "</merged>" */ svn_xml_make_close_tag(&sb, pool, "merged"); } /* "</entry>" */ svn_xml_make_close_tag(&sb, pool, "entry"); SVN_ERR(svn_cl__error_checked_fputs(sb->data, stdout)); svn_stringbuf_setempty(sb); return SVN_NO_ERROR; }
/* Return the value of the svn:mime-type property held in PROPS, or NULL if no such property exists. */ static const char * get_prop_mimetype(apr_hash_t *props) { return svn_prop_get_value(props, SVN_PROP_MIME_TYPE); }