Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/libsvn_ra_serf/log.c view on Meta::CPAN
svn_boolean_t want_message;
} log_context_t;
#define D_ "DAV:"
#define S_ SVN_XML_NAMESPACE
static const svn_ra_serf__xml_transition_t log_ttable[] = {
{ INITIAL, S_, "log-report", REPORT,
FALSE, { NULL }, FALSE },
/* Note that we have an opener here. We need to construct a new LOG_ENTRY
to record multiple paths. */
{ REPORT, S_, "log-item", ITEM,
FALSE, { NULL }, TRUE },
{ ITEM, D_, SVN_DAV__VERSION_NAME, VERSION,
TRUE, { NULL }, TRUE },
{ ITEM, D_, "creator-displayname", CREATOR,
TRUE, { "?encoding", NULL }, TRUE },
{ ITEM, S_, "date", DATE,
TRUE, { "?encoding", NULL }, TRUE },
{ ITEM, D_, "comment", COMMENT,
TRUE, { "?encoding", NULL }, TRUE },
{ ITEM, S_, "revprop", REVPROP,
TRUE, { "name", "?encoding", NULL }, TRUE },
{ ITEM, S_, "has-children", HAS_CHILDREN,
FALSE, { NULL }, TRUE },
{ ITEM, S_, "subtractive-merge", SUBTRACTIVE_MERGE,
FALSE, { NULL }, TRUE },
{ ITEM, S_, "added-path", ADDED_PATH,
TRUE, { "?node-kind", "?text-mods", "?prop-mods",
"?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
{ ITEM, S_, "replaced-path", REPLACED_PATH,
TRUE, { "?node-kind", "?text-mods", "?prop-mods",
"?copyfrom-path", "?copyfrom-rev", NULL }, TRUE },
{ ITEM, S_, "deleted-path", DELETED_PATH,
TRUE, { "?node-kind", "?text-mods", "?prop-mods", NULL }, TRUE },
{ ITEM, S_, "modified-path", MODIFIED_PATH,
TRUE, { "?node-kind", "?text-mods", "?prop-mods", NULL }, TRUE },
{ 0 }
};
/* Store CDATA into REVPROPS, associated with PROPNAME. If ENCODING is not
NULL, then it must base "base64" and CDATA will be decoded first.
NOTE: PROPNAME must live longer than REVPROPS. */
static svn_error_t *
collect_revprop(apr_hash_t *revprops,
const char *propname,
const svn_string_t *cdata,
const char *encoding)
{
apr_pool_t *result_pool = apr_hash_pool_get(revprops);
const svn_string_t *decoded;
if (encoding)
{
/* Check for a known encoding type. This is easy -- there's
only one. */
if (strcmp(encoding, "base64") != 0)
{
return svn_error_createf(SVN_ERR_RA_DAV_MALFORMED_DATA, NULL,
_("Unsupported encoding '%s'"),
encoding);
}
decoded = svn_base64_decode_string(cdata, result_pool);
}
else
{
decoded = svn_string_dup(cdata, result_pool);
}
/* Caller has ensured PROPNAME has sufficient lifetime. */
svn_hash_sets(revprops, propname, decoded);
return SVN_NO_ERROR;
}
/* Record ACTION on the path in CDATA into PATHS. Other properties about
the action are pulled from ATTRS. */
static svn_error_t *
collect_path(apr_hash_t *paths,
char action,
const svn_string_t *cdata,
apr_hash_t *attrs)
{
apr_pool_t *result_pool = apr_hash_pool_get(paths);
svn_log_changed_path2_t *lcp;
const char *copyfrom_path;
const char *copyfrom_rev;
const char *path;
lcp = svn_log_changed_path2_create(result_pool);
lcp->action = action;
lcp->copyfrom_rev = SVN_INVALID_REVNUM;
/* COPYFROM_* are only recorded for ADDED_PATH and REPLACED_PATH. */
copyfrom_path = svn_hash_gets(attrs, "copyfrom-path");
copyfrom_rev = svn_hash_gets(attrs, "copyfrom-rev");
if (copyfrom_path && copyfrom_rev)
{
svn_revnum_t rev = SVN_STR_TO_REV(copyfrom_rev);
if (SVN_IS_VALID_REVNUM(rev))
{
lcp->copyfrom_path = apr_pstrdup(result_pool, copyfrom_path);
lcp->copyfrom_rev = rev;
}
}
lcp->node_kind = svn_node_kind_from_word(svn_hash_gets(attrs, "node-kind"));
lcp->text_modified = svn_tristate__from_word(svn_hash_gets(attrs,
"text-mods"));
lcp->props_modified = svn_tristate__from_word(svn_hash_gets(attrs,
"prop-mods"));
path = apr_pstrmemdup(result_pool, cdata->data, cdata->len);
svn_hash_sets(paths, path, lcp);
return SVN_NO_ERROR;
}
/* Conforms to svn_ra_serf__xml_opened_t */
static svn_error_t *
log_opened(svn_ra_serf__xml_estate_t *xes,
void *baton,
int entered_state,
const svn_ra_serf__dav_props_t *tag,
apr_pool_t *scratch_pool)
{
log_context_t *log_ctx = baton;
if (entered_state == ITEM)
{
apr_pool_t *state_pool = svn_ra_serf__xml_state_pool(xes);
log_ctx->collect_revprops = apr_hash_make(state_pool);
log_ctx->collect_paths = apr_hash_make(state_pool);
}
return SVN_NO_ERROR;
}
/* Conforms to svn_ra_serf__xml_closed_t */
static svn_error_t *
log_closed(svn_ra_serf__xml_estate_t *xes,
void *baton,
int leaving_state,
const svn_string_t *cdata,
apr_hash_t *attrs,
apr_pool_t *scratch_pool)
{
log_context_t *log_ctx = baton;
if (leaving_state == ITEM)
{
svn_log_entry_t *log_entry;
const char *rev_str;
if (log_ctx->limit && (log_ctx->nest_level == 0)
&& (++log_ctx->count > log_ctx->limit))
{
return SVN_NO_ERROR;
}
log_entry = svn_log_entry_create(scratch_pool);
/* Pick up the paths from the context. These have the same lifetime
as this state. That is long enough for us to pass the paths to
the receiver callback. */
if (apr_hash_count(log_ctx->collect_paths) > 0)
{
log_entry->changed_paths = log_ctx->collect_paths;
log_entry->changed_paths2 = log_ctx->collect_paths;
}
/* ... and same story for the collected revprops. */
log_entry->revprops = log_ctx->collect_revprops;
log_entry->has_children = svn_hash__get_bool(attrs,
"has-children",
FALSE);
log_entry->subtractive_merge = svn_hash__get_bool(attrs,
"subtractive-merge",
FALSE);
rev_str = svn_hash_gets(attrs, "revision");
if (rev_str)
log_entry->revision = SVN_STR_TO_REV(rev_str);
else
log_entry->revision = SVN_INVALID_REVNUM;
/* Give the info to the reporter */
SVN_ERR(log_ctx->receiver(log_ctx->receiver_baton,
log_entry,
scratch_pool));
if (log_entry->has_children)
{
log_ctx->nest_level++;
}
if (! SVN_IS_VALID_REVNUM(log_entry->revision))
{
SVN_ERR_ASSERT(log_ctx->nest_level);
log_ctx->nest_level--;
}
/* These hash tables are going to be unusable once this state's
pool is destroyed. But let's not leave stale pointers in
structures that have a longer life. */
log_ctx->collect_revprops = NULL;
log_ctx->collect_paths = NULL;
}
else if (leaving_state == VERSION)
{
svn_ra_serf__xml_note(xes, ITEM, "revision", cdata->data);
}
else if (leaving_state == CREATOR)
{
if (log_ctx->want_author)
{
SVN_ERR(collect_revprop(log_ctx->collect_revprops,
SVN_PROP_REVISION_AUTHOR,
cdata,
svn_hash_gets(attrs, "encoding")));
}
}
else if (leaving_state == DATE)
{
if (log_ctx->want_date)
{
SVN_ERR(collect_revprop(log_ctx->collect_revprops,
SVN_PROP_REVISION_DATE,
cdata,
svn_hash_gets(attrs, "encoding")));
}
}
else if (leaving_state == COMMENT)
{
if (log_ctx->want_message)
{
SVN_ERR(collect_revprop(log_ctx->collect_revprops,
SVN_PROP_REVISION_LOG,
cdata,
svn_hash_gets(attrs, "encoding")));
}
}
else if (leaving_state == REVPROP)
{
apr_pool_t *result_pool = apr_hash_pool_get(log_ctx->collect_revprops);
SVN_ERR(collect_revprop(
log_ctx->collect_revprops,
apr_pstrdup(result_pool,
svn_hash_gets(attrs, "name")),
cdata,
svn_hash_gets(attrs, "encoding")
));
}
else if (leaving_state == HAS_CHILDREN)
{
svn_ra_serf__xml_note(xes, ITEM, "has-children", "yes");
}
else if (leaving_state == SUBTRACTIVE_MERGE)
{
svn_ra_serf__xml_note(xes, ITEM, "subtractive-merge", "yes");
}
else
{
char action;
if (leaving_state == ADDED_PATH)
action = 'A';
else if (leaving_state == REPLACED_PATH)
action = 'R';
else if (leaving_state == DELETED_PATH)
action = 'D';
else
{
SVN_ERR_ASSERT(leaving_state == MODIFIED_PATH);
action = 'M';
}
SVN_ERR(collect_path(log_ctx->collect_paths, action, cdata, attrs));
}
return SVN_NO_ERROR;
}
static svn_error_t *
create_log_body(serf_bucket_t **body_bkt,
void *baton,
serf_bucket_alloc_t *alloc,
apr_pool_t *pool)
{
serf_bucket_t *buckets;
log_context_t *log_ctx = baton;
buckets = serf_bucket_aggregate_create(alloc);
svn_ra_serf__add_open_tag_buckets(buckets, alloc,
"S:log-report",
"xmlns:S", SVN_XML_NAMESPACE,
NULL);
svn_ra_serf__add_tag_buckets(buckets,
"S:start-revision",
apr_ltoa(pool, log_ctx->start),
alloc);
svn_ra_serf__add_tag_buckets(buckets,
"S:end-revision",
apr_ltoa(pool, log_ctx->end),
alloc);
if (log_ctx->limit)
{
svn_ra_serf__add_tag_buckets(buckets,
"S:limit", apr_ltoa(pool, log_ctx->limit),
alloc);
}
if (log_ctx->changed_paths)
{
svn_ra_serf__add_tag_buckets(buckets,
"S:discover-changed-paths", NULL,
alloc);
}
if (log_ctx->strict_node_history)
{
svn_ra_serf__add_tag_buckets(buckets,
"S:strict-node-history", NULL,
alloc);
}
if (log_ctx->include_merged_revisions)
{
svn_ra_serf__add_tag_buckets(buckets,
"S:include-merged-revisions", NULL,
alloc);
}
if (log_ctx->revprops)
( run in 2.054 seconds using v1.01-cache-2.11-cpan-2398b32b56e )