diff options
Diffstat (limited to 'subversion/libsvn_client/cat.c')
-rw-r--r-- | subversion/libsvn_client/cat.c | 105 |
1 files changed, 53 insertions, 52 deletions
diff --git a/subversion/libsvn_client/cat.c b/subversion/libsvn_client/cat.c index 2964af7..7c58f88 100644 --- a/subversion/libsvn_client/cat.c +++ b/subversion/libsvn_client/cat.c @@ -27,6 +27,7 @@ /*** Includes. ***/ +#include "svn_hash.h" #include "svn_client.h" #include "svn_string.h" #include "svn_error.h" @@ -62,13 +63,14 @@ svn_client__get_normalized_stream(svn_stream_t **normal_stream, svn_string_t *eol_style, *keywords, *special; const char *eol = NULL; svn_boolean_t local_mod = FALSE; - apr_time_t tm; svn_stream_t *input; svn_node_kind_t kind; SVN_ERR_ASSERT(SVN_CLIENT__REVKIND_IS_LOCAL_TO_WC(revision->kind)); - SVN_ERR(svn_wc_read_kind(&kind, wc_ctx, local_abspath, FALSE, scratch_pool)); + SVN_ERR(svn_wc_read_kind2(&kind, wc_ctx, local_abspath, + (revision->kind != svn_opt_revision_working), + FALSE, scratch_pool)); if (kind == svn_node_unknown || kind == svn_node_none) return svn_error_createf(SVN_ERR_UNVERSIONED_RESOURCE, NULL, @@ -87,7 +89,7 @@ svn_client__get_normalized_stream(svn_stream_t **normal_stream, result_pool, scratch_pool)); if (input == NULL) return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL, - _("'%s' has no base revision until it is committed"), + _("'%s' has no pristine version until it is committed"), svn_dirent_local_style(local_abspath, scratch_pool)); SVN_ERR(svn_wc_get_pristine_props(&props, wc_ctx, local_abspath, @@ -104,45 +106,36 @@ svn_client__get_normalized_stream(svn_stream_t **normal_stream, scratch_pool)); SVN_ERR(svn_wc_status3(&status, wc_ctx, local_abspath, scratch_pool, scratch_pool)); - if (status->text_status != svn_wc_status_normal) + if (status->node_status != svn_wc_status_normal) local_mod = TRUE; } - eol_style = apr_hash_get(props, SVN_PROP_EOL_STYLE, - APR_HASH_KEY_STRING); - keywords = apr_hash_get(props, SVN_PROP_KEYWORDS, - APR_HASH_KEY_STRING); - special = apr_hash_get(props, SVN_PROP_SPECIAL, - APR_HASH_KEY_STRING); + eol_style = svn_hash_gets(props, SVN_PROP_EOL_STYLE); + keywords = svn_hash_gets(props, SVN_PROP_KEYWORDS); + special = svn_hash_gets(props, SVN_PROP_SPECIAL); if (eol_style) svn_subst_eol_style_from_value(&style, &eol, eol_style->data); - if (local_mod && (! special)) - { - /* Use the modified time from the working copy if - the file */ - SVN_ERR(svn_io_file_affected_time(&tm, local_abspath, scratch_pool)); - } - else - { - SVN_ERR(svn_wc__node_get_changed_info(NULL, &tm, NULL, wc_ctx, - local_abspath, scratch_pool, - scratch_pool)); - } - if (keywords) { svn_revnum_t changed_rev; const char *rev_str; const char *author; const char *url; + apr_time_t tm; + const char *repos_root_url; + const char *repos_relpath; - SVN_ERR(svn_wc__node_get_changed_info(&changed_rev, NULL, &author, wc_ctx, + SVN_ERR(svn_wc__node_get_changed_info(&changed_rev, &tm, &author, wc_ctx, local_abspath, scratch_pool, scratch_pool)); - SVN_ERR(svn_wc__node_get_url(&url, wc_ctx, local_abspath, scratch_pool, - scratch_pool)); + SVN_ERR(svn_wc__node_get_repos_info(NULL, &repos_relpath, &repos_root_url, + NULL, + wc_ctx, local_abspath, scratch_pool, + scratch_pool)); + url = svn_path_url_add_component2(repos_root_url, repos_relpath, + scratch_pool); if (local_mod) { @@ -152,14 +145,22 @@ svn_client__get_normalized_stream(svn_stream_t **normal_stream, current user's username */ rev_str = apr_psprintf(scratch_pool, "%ldM", changed_rev); author = _("(local)"); + + if (! special) + { + /* Use the modified time from the working copy for files */ + SVN_ERR(svn_io_file_affected_time(&tm, local_abspath, + scratch_pool)); + } } else { rev_str = apr_psprintf(scratch_pool, "%ld", changed_rev); } - SVN_ERR(svn_subst_build_keywords2(&kw, keywords->data, rev_str, url, tm, - author, scratch_pool)); + SVN_ERR(svn_subst_build_keywords3(&kw, keywords->data, rev_str, url, + repos_root_url, tm, author, + scratch_pool)); } /* Wrap the output stream if translation is needed. */ @@ -183,11 +184,11 @@ svn_client_cat2(svn_stream_t *out, apr_pool_t *pool) { svn_ra_session_t *ra_session; - svn_revnum_t rev; + svn_client__pathrev_t *loc; svn_string_t *eol_style; svn_string_t *keywords; apr_hash_t *props; - const char *url; + const char *repos_root_url; svn_stream_t *output = out; svn_error_t *err; @@ -227,20 +228,24 @@ svn_client_cat2(svn_stream_t *out, } /* Get an RA plugin for this filesystem object. */ - SVN_ERR(svn_client__ra_session_from_path(&ra_session, &rev, - &url, path_or_url, NULL, - peg_revision, - revision, ctx, pool)); + SVN_ERR(svn_client__ra_session_from_path2(&ra_session, &loc, + path_or_url, NULL, + peg_revision, + revision, ctx, pool)); + + /* Find the repos root URL */ + SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_root_url, pool)); /* Grab some properties we need to know in order to figure out if anything special needs to be done with this file. */ - err = svn_ra_get_file(ra_session, "", rev, NULL, NULL, &props, pool); + err = svn_ra_get_file(ra_session, "", loc->rev, NULL, NULL, &props, pool); if (err) { if (err->apr_err == SVN_ERR_FS_NOT_FILE) { return svn_error_createf(SVN_ERR_CLIENT_IS_DIRECTORY, err, - _("URL '%s' refers to a directory"), url); + _("URL '%s' refers to a directory"), + loc->url); } else { @@ -248,8 +253,8 @@ svn_client_cat2(svn_stream_t *out, } } - eol_style = apr_hash_get(props, SVN_PROP_EOL_STYLE, APR_HASH_KEY_STRING); - keywords = apr_hash_get(props, SVN_PROP_KEYWORDS, APR_HASH_KEY_STRING); + eol_style = svn_hash_gets(props, SVN_PROP_EOL_STYLE); + keywords = svn_hash_gets(props, SVN_PROP_KEYWORDS); if (eol_style || keywords) { @@ -272,22 +277,18 @@ svn_client_cat2(svn_stream_t *out, svn_string_t *cmt_rev, *cmt_date, *cmt_author; apr_time_t when = 0; - cmt_rev = apr_hash_get(props, SVN_PROP_ENTRY_COMMITTED_REV, - APR_HASH_KEY_STRING); - cmt_date = apr_hash_get(props, SVN_PROP_ENTRY_COMMITTED_DATE, - APR_HASH_KEY_STRING); - cmt_author = apr_hash_get(props, SVN_PROP_ENTRY_LAST_AUTHOR, - APR_HASH_KEY_STRING); + cmt_rev = svn_hash_gets(props, SVN_PROP_ENTRY_COMMITTED_REV); + cmt_date = svn_hash_gets(props, SVN_PROP_ENTRY_COMMITTED_DATE); + cmt_author = svn_hash_gets(props, SVN_PROP_ENTRY_LAST_AUTHOR); if (cmt_date) SVN_ERR(svn_time_from_cstring(&when, cmt_date->data, pool)); - SVN_ERR(svn_subst_build_keywords2 - (&kw, keywords->data, - cmt_rev->data, - url, - when, - cmt_author ? cmt_author->data : NULL, - pool)); + SVN_ERR(svn_subst_build_keywords3(&kw, keywords->data, + cmt_rev->data, loc->url, + repos_root_url, when, + cmt_author ? + cmt_author->data : NULL, + pool)); } else kw = NULL; @@ -297,7 +298,7 @@ svn_client_cat2(svn_stream_t *out, eol_str, FALSE, kw, TRUE, pool); } - SVN_ERR(svn_ra_get_file(ra_session, "", rev, output, NULL, NULL, pool)); + SVN_ERR(svn_ra_get_file(ra_session, "", loc->rev, output, NULL, NULL, pool)); if (out != output) /* Close the interjected stream */ |