#include <apr_hash.h>
#include "svn_cmdline.h"
#include "svn_string.h"
#include "svn_error.h"
#include "svn_subst.h"
#include "svn_props.h"
#include "svn_opt.h"
#include "cl.h"
#include "svn_private_config.h"
svn_error_t *
svn_cl__revprop_prepare(const svn_opt_revision_t *revision,
apr_array_header_t *targets,
const char **URL,
apr_pool_t *pool)
{
const char *target;
if (revision->kind != svn_opt_revision_number
&& revision->kind != svn_opt_revision_date
&& revision->kind != svn_opt_revision_head)
return svn_error_create
(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("Must specify the revision as a number, a date or 'HEAD' "
"when operating on a revision property"));
if (targets->nelts != 1)
return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("Wrong number of targets specified"));
target = ((const char **) (targets->elts))[0];
SVN_ERR(svn_client_url_from_path(URL, target, pool));
if (*URL == NULL)
return svn_error_create
(SVN_ERR_UNVERSIONED_RESOURCE, NULL,
_("Either a URL or versioned item is required"));
return SVN_NO_ERROR;
}
svn_error_t *
svn_cl__print_prop_hash(apr_hash_t *prop_hash,
svn_boolean_t names_only,
apr_pool_t *pool)
{
apr_hash_index_t *hi;
for (hi = apr_hash_first(pool, prop_hash); hi; hi = apr_hash_next(hi))
{
const void *key;
void *val;
const char *pname;
svn_string_t *propval;
const char *pname_stdout;
apr_hash_this(hi, &key, NULL, &val);
pname = key;
propval = val;
if (svn_prop_needs_translation(pname))
SVN_ERR(svn_subst_detranslate_string(&propval, propval,
TRUE, pool));
SVN_ERR(svn_cmdline_cstring_from_utf8(&pname_stdout, pname, pool));
if (names_only)
printf(" %s\n", pname_stdout);
else
printf(" %s : %s\n", pname_stdout, propval->data);
}
return SVN_NO_ERROR;
}