diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-08-05 16:22:51 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-08-05 16:22:51 +0000 |
commit | cf46733632c7279a9fd0fe6ce26f9185a4ae82a9 (patch) | |
tree | da27775a2161723ef342e91af41a8b51fedef405 /subversion/libsvn_client/cat.c | |
parent | bb0ef45f7c46b0ae221b26265ef98a768c33f820 (diff) | |
download | subversion-tarball-master.tar.gz |
subversion-1.9.7HEADsubversion-1.9.7master
Diffstat (limited to 'subversion/libsvn_client/cat.c')
-rw-r--r-- | subversion/libsvn_client/cat.c | 67 |
1 files changed, 48 insertions, 19 deletions
diff --git a/subversion/libsvn_client/cat.c b/subversion/libsvn_client/cat.c index 7c58f88..8c6aac8 100644 --- a/subversion/libsvn_client/cat.c +++ b/subversion/libsvn_client/cat.c @@ -176,18 +176,21 @@ svn_client__get_normalized_stream(svn_stream_t **normal_stream, } svn_error_t * -svn_client_cat2(svn_stream_t *out, +svn_client_cat3(apr_hash_t **returned_props, + svn_stream_t *out, const char *path_or_url, const svn_opt_revision_t *peg_revision, const svn_opt_revision_t *revision, + svn_boolean_t expand_keywords, svn_client_ctx_t *ctx, - apr_pool_t *pool) + apr_pool_t *result_pool, + apr_pool_t *scratch_pool) { svn_ra_session_t *ra_session; svn_client__pathrev_t *loc; svn_string_t *eol_style; svn_string_t *keywords; - apr_hash_t *props; + apr_hash_t *props = NULL; const char *repos_root_url; svn_stream_t *output = out; svn_error_t *err; @@ -201,8 +204,6 @@ svn_client_cat2(svn_stream_t *out, } else { - peg_revision = svn_cl__rev_default_to_head_or_working(peg_revision, - path_or_url); revision = svn_cl__rev_default_to_peg(revision, peg_revision); } @@ -213,32 +214,39 @@ svn_client_cat2(svn_stream_t *out, const char *local_abspath; svn_stream_t *normal_stream; - SVN_ERR(svn_dirent_get_absolute(&local_abspath, path_or_url, pool)); + SVN_ERR(svn_dirent_get_absolute(&local_abspath, path_or_url, + scratch_pool)); SVN_ERR(svn_client__get_normalized_stream(&normal_stream, ctx->wc_ctx, - local_abspath, revision, TRUE, FALSE, + local_abspath, revision, + expand_keywords, FALSE, ctx->cancel_func, ctx->cancel_baton, - pool, pool)); + scratch_pool, scratch_pool)); /* We don't promise to close output, so disown it to ensure we don't. */ - output = svn_stream_disown(output, pool); + output = svn_stream_disown(output, scratch_pool); + + if (returned_props) + SVN_ERR(svn_wc_prop_list2(returned_props, ctx->wc_ctx, local_abspath, + result_pool, scratch_pool)); return svn_error_trace(svn_stream_copy3(normal_stream, output, ctx->cancel_func, - ctx->cancel_baton, pool)); + ctx->cancel_baton, scratch_pool)); } /* Get an RA plugin for this filesystem object. */ SVN_ERR(svn_client__ra_session_from_path2(&ra_session, &loc, path_or_url, NULL, peg_revision, - revision, ctx, pool)); + revision, ctx, scratch_pool)); /* Find the repos root URL */ - SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_root_url, pool)); + SVN_ERR(svn_ra_get_repos_root2(ra_session, &repos_root_url, scratch_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, "", loc->rev, NULL, NULL, &props, pool); + err = svn_ra_get_file(ra_session, "", loc->rev, NULL, NULL, &props, + result_pool); if (err) { if (err->apr_err == SVN_ERR_FS_NOT_FILE) @@ -272,7 +280,7 @@ svn_client_cat2(svn_stream_t *out, } - if (keywords) + if (keywords && expand_keywords) { svn_string_t *cmt_rev, *cmt_date, *cmt_author; apr_time_t when = 0; @@ -281,24 +289,45 @@ svn_client_cat2(svn_stream_t *out, 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_time_from_cstring(&when, cmt_date->data, scratch_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)); + scratch_pool)); } else kw = NULL; /* Interject a translating stream */ - output = svn_subst_stream_translated(svn_stream_disown(out, pool), - eol_str, FALSE, kw, TRUE, pool); + output = svn_subst_stream_translated(svn_stream_disown(out, + scratch_pool), + eol_str, FALSE, kw, TRUE, + scratch_pool); + } + + if (returned_props) + { + /* filter entry and WC props */ + apr_hash_index_t *hi; + const void *key; + apr_ssize_t klen; + + for (hi = apr_hash_first(scratch_pool, props); + hi; hi = apr_hash_next(hi)) + { + apr_hash_this(hi, &key, &klen, NULL); + if (!svn_wc_is_normal_prop(key)) + apr_hash_set(props, key, klen, NULL); + } + + *returned_props = props; } - SVN_ERR(svn_ra_get_file(ra_session, "", loc->rev, output, NULL, NULL, pool)); + SVN_ERR(svn_ra_get_file(ra_session, "", loc->rev, output, NULL, NULL, + scratch_pool)); if (out != output) /* Close the interjected stream */ |