/* Helper for svn_cl__append_tree_conflict_info_xml(). * Appends the attributes of the given VERSION to ATT_HASH. * SIDE is the content of the version tag's side="..." attribute, * currently one of "source-left" or "source-right".*/ static svn_error_t * add_conflict_version_xml(svn_stringbuf_t **pstr, const char *side, const svn_wc_conflict_version_t *version, apr_pool_t *pool) { apr_hash_t *att_hash = apr_hash_make(pool); apr_hash_set(att_hash, "side", APR_HASH_KEY_STRING, side); if (version->repos_url) apr_hash_set(att_hash, "repos-url", APR_HASH_KEY_STRING, version->repos_url); if (version->path_in_repos) apr_hash_set(att_hash, "path-in-repos", APR_HASH_KEY_STRING, version->path_in_repos); if (SVN_IS_VALID_REVNUM(version->peg_rev)) apr_hash_set(att_hash, "revision", APR_HASH_KEY_STRING, apr_ltoa(pool, version->peg_rev)); if (version->node_kind != svn_node_unknown) apr_hash_set(att_hash, "kind", APR_HASH_KEY_STRING, svn_cl__node_kind_str_xml(version->node_kind)); svn_xml_make_open_tag_hash(pstr, pool, svn_xml_self_closing, "version", att_hash); return SVN_NO_ERROR; }
svn_error_t * svn_cl__append_tree_conflict_info_xml( svn_stringbuf_t *str, const svn_wc_conflict_description2_t *conflict, apr_pool_t *pool) { apr_hash_t *att_hash = apr_hash_make(pool); const char *tmp; apr_hash_set(att_hash, "victim", APR_HASH_KEY_STRING, svn_dirent_basename(conflict->local_abspath, pool)); apr_hash_set(att_hash, "kind", APR_HASH_KEY_STRING, svn_cl__node_kind_str_xml(conflict->node_kind)); apr_hash_set(att_hash, "operation", APR_HASH_KEY_STRING, svn_cl__operation_str_xml(conflict->operation, pool)); tmp = svn_token__to_word(map_conflict_action_xml, conflict->action); apr_hash_set(att_hash, "action", APR_HASH_KEY_STRING, tmp); tmp = svn_token__to_word(map_conflict_reason_xml, conflict->reason); apr_hash_set(att_hash, "reason", APR_HASH_KEY_STRING, tmp); /* Open the tree-conflict tag. */ svn_xml_make_open_tag_hash(&str, pool, svn_xml_normal, "tree-conflict", att_hash); /* Add child tags for OLDER_VERSION and THEIR_VERSION. */ if (conflict->src_left_version) SVN_ERR(add_conflict_version_xml(&str, "source-left", conflict->src_left_version, pool)); if (conflict->src_right_version) SVN_ERR(add_conflict_version_xml(&str, "source-right", conflict->src_right_version, pool)); svn_xml_make_close_tag(&str, pool, "tree-conflict"); return SVN_NO_ERROR; }
svn_error_t * svn_cl__print_status_xml(const char *path, svn_wc_status2_t *status, apr_pool_t *pool) { svn_stringbuf_t *sb = svn_stringbuf_create("", pool); apr_hash_t *att_hash; if (status->text_status == svn_wc_status_none && status->repos_text_status == svn_wc_status_none) return SVN_NO_ERROR; svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "entry", "path", svn_path_local_style(path, pool), NULL); att_hash = apr_hash_make(pool); apr_hash_set(att_hash, "item", APR_HASH_KEY_STRING, generate_status_desc(status->text_status)); apr_hash_set(att_hash, "props", APR_HASH_KEY_STRING, generate_status_desc(status->prop_status)); if (status->locked) apr_hash_set(att_hash, "wc-locked", APR_HASH_KEY_STRING, "true"); if (status->copied) apr_hash_set(att_hash, "copied", APR_HASH_KEY_STRING, "true"); if (status->switched) apr_hash_set(att_hash, "switched", APR_HASH_KEY_STRING, "true"); if (status->entry && ! status->entry->copied) apr_hash_set(att_hash, "revision", APR_HASH_KEY_STRING, apr_psprintf(pool, "%ld", status->entry->revision)); svn_xml_make_open_tag_hash(&sb, pool, svn_xml_normal, "wc-status", att_hash); if (status->entry && SVN_IS_VALID_REVNUM(status->entry->cmt_rev)) { svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "commit", "revision", apr_psprintf(pool, "%ld", status->entry->cmt_rev), NULL); svn_cl__xml_tagged_cdata(&sb, pool, "author", status->entry->cmt_author); if (status->entry->cmt_date) svn_cl__xml_tagged_cdata(&sb, pool, "date", svn_time_to_cstring (status->entry->cmt_date, pool)); svn_xml_make_close_tag(&sb, pool, "commit"); } if (status->entry && status->entry->lock_token) { svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "lock", NULL); svn_cl__xml_tagged_cdata(&sb, pool, "token", status->entry->lock_token); /* If lock_owner is NULL, assume WC is corrupt. */ if (status->entry->lock_owner) svn_cl__xml_tagged_cdata(&sb, pool, "owner", status->entry->lock_owner); else return svn_error_createf(SVN_ERR_WC_CORRUPT, NULL, _("'%s' has lock token, but no lock owner"), svn_path_local_style(path, pool)); svn_cl__xml_tagged_cdata(&sb, pool, "comment", status->entry->lock_comment); svn_cl__xml_tagged_cdata(&sb, pool, "created", svn_time_to_cstring (status->entry->lock_creation_date, pool)); svn_xml_make_close_tag(&sb, pool, "lock"); } svn_xml_make_close_tag(&sb, pool, "wc-status"); if (status->repos_text_status != svn_wc_status_none || status->repos_prop_status != svn_wc_status_none || status->repos_lock) { svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "repos-status", "item", generate_status_desc(status->repos_text_status), "props", generate_status_desc(status->repos_prop_status), NULL); if (status->repos_lock) { svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "lock", NULL); svn_cl__xml_tagged_cdata(&sb, pool, "token", status->repos_lock->token); svn_cl__xml_tagged_cdata(&sb, pool, "owner", status->repos_lock->owner); svn_cl__xml_tagged_cdata(&sb, pool, "comment", status->repos_lock->comment); svn_cl__xml_tagged_cdata(&sb, pool, "created", svn_time_to_cstring (status->repos_lock->creation_date, pool)); if (status->repos_lock->expiration_date != 0) { svn_cl__xml_tagged_cdata(&sb, pool, "expires", svn_time_to_cstring (status->repos_lock->expiration_date, pool)); } svn_xml_make_close_tag(&sb, pool, "lock"); } svn_xml_make_close_tag(&sb, pool, "repos-status"); } svn_xml_make_close_tag(&sb, pool, "entry"); return svn_cl__error_checked_fputs(sb->data, stdout); }
svn_error_t * svn_cl__print_status_xml(const char *cwd_abspath, const char *path, const svn_client_status_t *status, svn_client_ctx_t *ctx, apr_pool_t *pool) { svn_stringbuf_t *sb = svn_stringbuf_create_empty(pool); apr_hash_t *att_hash; const char *local_abspath = status->local_abspath; svn_boolean_t tree_conflicted = FALSE; if (status->node_status == svn_wc_status_none && status->repos_node_status == svn_wc_status_none) return SVN_NO_ERROR; if (status->conflicted) SVN_ERR(svn_wc_conflicted_p3(NULL, NULL, &tree_conflicted, ctx->wc_ctx, local_abspath, pool)); path = make_relpath(cwd_abspath, path, pool, pool); svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "entry", "path", svn_dirent_local_style(path, pool), NULL); att_hash = apr_hash_make(pool); svn_hash_sets(att_hash, "item", generate_status_desc(combined_status(status))); svn_hash_sets(att_hash, "props", generate_status_desc( (status->node_status != svn_wc_status_deleted) ? status->prop_status : svn_wc_status_none)); if (status->wc_is_locked) svn_hash_sets(att_hash, "wc-locked", "true"); if (status->copied) svn_hash_sets(att_hash, "copied", "true"); if (status->switched) svn_hash_sets(att_hash, "switched", "true"); if (status->file_external) svn_hash_sets(att_hash, "file-external", "true"); if (status->versioned && ! status->copied) svn_hash_sets(att_hash, "revision", apr_psprintf(pool, "%ld", status->revision)); if (tree_conflicted) svn_hash_sets(att_hash, "tree-conflicted", "true"); if (status->moved_from_abspath || status->moved_to_abspath) { const char *relpath; if (status->moved_from_abspath) { relpath = make_relpath(cwd_abspath, status->moved_from_abspath, pool, pool); relpath = svn_dirent_local_style(relpath, pool); svn_hash_sets(att_hash, "moved-from", relpath); } if (status->moved_to_abspath) { relpath = make_relpath(cwd_abspath, status->moved_to_abspath, pool, pool); relpath = svn_dirent_local_style(relpath, pool); svn_hash_sets(att_hash, "moved-to", relpath); } } svn_xml_make_open_tag_hash(&sb, pool, svn_xml_normal, "wc-status", att_hash); if (SVN_IS_VALID_REVNUM(status->changed_rev)) { svn_cl__print_xml_commit(&sb, status->changed_rev, status->changed_author, svn_time_to_cstring(status->changed_date, pool), pool); } if (status->lock) svn_cl__print_xml_lock(&sb, status->lock, pool); svn_xml_make_close_tag(&sb, pool, "wc-status"); if (status->repos_node_status != svn_wc_status_none || status->repos_lock) { svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "repos-status", "item", generate_status_desc(combined_repos_status(status)), "props", generate_status_desc(status->repos_prop_status), NULL); if (status->repos_lock) svn_cl__print_xml_lock(&sb, status->repos_lock, pool); svn_xml_make_close_tag(&sb, pool, "repos-status"); } svn_xml_make_close_tag(&sb, pool, "entry"); return svn_cl__error_checked_fputs(sb->data, stdout); }