static const char * log_depth(svn_depth_t depth, apr_pool_t *pool) { if (depth == svn_depth_unknown) return ""; return apr_pstrcat(pool, " depth=", svn_depth_to_word(depth), SVN_VA_NULL); }
static void copy_warning_notify_func(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool) { struct copy_warning_notify_baton *b = baton; /* Call the wrapped notification system (if any). */ if (b->wrapped_func) b->wrapped_func(b->wrapped_baton, notify, pool); /* If we're being notified about a copy of a directory when our commit depth is less-than-infinite, and we've not already warned about this situation, then warn about it (and remember that we now have.) */ if ((! b->warned) && (b->depth < svn_depth_infinity) && (notify->kind == svn_node_dir) && ((notify->action == svn_wc_notify_commit_copied) || (notify->action == svn_wc_notify_commit_copied_replaced))) { svn_error_t *err; err = svn_cmdline_printf(pool, _("svn: The depth of this commit is '%s', " "but copies are always performed " "recursively in the repository.\n"), svn_depth_to_word(b->depth)); /* ### FIXME: Try to return this error showhow? */ svn_error_clear(err); /* We'll only warn once. */ b->warned = TRUE; } }
static svn_error_t * set_path(void *report_baton, const char *path, svn_revnum_t revision, svn_depth_t depth, svn_boolean_t start_empty, const char *lock_token, apr_pool_t *pool) { struct report_baton *rb = report_baton; SVN_ERR(svn_stream_printf(rb->out, pool, "set_path(%s, %ld, %s, %s, %s)\n", path, revision, svn_depth_to_word(depth), BOOLEAN_TO_WORD(start_empty), lock_token)); SVN_ERR(rb->wrapped_reporter->set_path(rb->wrapped_report_baton, path, revision, depth, start_empty, lock_token, pool)); return SVN_NO_ERROR; }
/* Implements svn_ra_serf__request_body_delegate_t */ static svn_error_t * create_getlocks_body(serf_bucket_t **body_bkt, void *baton, serf_bucket_alloc_t *alloc, apr_pool_t *pool) { lock_context_t *lock_ctx = baton; serf_bucket_t *buckets; buckets = serf_bucket_aggregate_create(alloc); svn_ra_serf__add_open_tag_buckets( buckets, alloc, "S:get-locks-report", "xmlns:S", SVN_XML_NAMESPACE, "depth", svn_depth_to_word(lock_ctx->requested_depth), NULL); svn_ra_serf__add_close_tag_buckets(buckets, alloc, "S:get-locks-report"); *body_bkt = buckets; return SVN_NO_ERROR; }
/* A callback of type svn_client_info_receiver2_t. Prints svn info in xml mode to standard out */ static svn_error_t * print_info_xml(void *baton, const char *target, const svn_client_info2_t *info, apr_pool_t *pool) { svn_stringbuf_t *sb = svn_stringbuf_create("", pool); const char *rev_str; const char *path_prefix = baton; if (SVN_IS_VALID_REVNUM(info->rev)) rev_str = apr_psprintf(pool, "%ld", info->rev); else rev_str = apr_pstrdup(pool, _("Resource is not under version control.")); /* "<entry ...>" */ svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "entry", "path", svn_cl__local_style_skip_ancestor( path_prefix, target, pool), "kind", svn_cl__node_kind_str_xml(info->kind), "revision", rev_str, NULL); svn_cl__xml_tagged_cdata(&sb, pool, "url", info->URL); if (info->repos_root_URL || info->repos_UUID) { /* "<repository>" */ svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "repository", NULL); /* "<root> xx </root>" */ svn_cl__xml_tagged_cdata(&sb, pool, "root", info->repos_root_URL); /* "<uuid> xx </uuid>" */ svn_cl__xml_tagged_cdata(&sb, pool, "uuid", info->repos_UUID); /* "</repository>" */ svn_xml_make_close_tag(&sb, pool, "repository"); } if (info->wc_info) { /* "<wc-info>" */ svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "wc-info", NULL); /* "<wcroot-abspath> xx </wcroot-abspath>" */ if (info->wc_info->wcroot_abspath) svn_cl__xml_tagged_cdata(&sb, pool, "wcroot-abspath", info->wc_info->wcroot_abspath); /* "<schedule> xx </schedule>" */ svn_cl__xml_tagged_cdata(&sb, pool, "schedule", schedule_str(info->wc_info->schedule)); /* "<depth> xx </depth>" */ { svn_depth_t depth = info->wc_info->depth; /* In the entries world info just passed depth infinity for files */ if (depth == svn_depth_unknown && info->kind == svn_node_file) depth = svn_depth_infinity; svn_cl__xml_tagged_cdata(&sb, pool, "depth", svn_depth_to_word(depth)); } /* "<copy-from-url> xx </copy-from-url>" */ svn_cl__xml_tagged_cdata(&sb, pool, "copy-from-url", info->wc_info->copyfrom_url); /* "<copy-from-rev> xx </copy-from-rev>" */ if (SVN_IS_VALID_REVNUM(info->wc_info->copyfrom_rev)) svn_cl__xml_tagged_cdata(&sb, pool, "copy-from-rev", apr_psprintf(pool, "%ld", info->wc_info->copyfrom_rev)); /* "<text-updated> xx </text-updated>" */ if (info->wc_info->recorded_time) svn_cl__xml_tagged_cdata(&sb, pool, "text-updated", svn_time_to_cstring( info->wc_info->recorded_time, pool)); /* "<checksum> xx </checksum>" */ /* ### Print the checksum kind. */ svn_cl__xml_tagged_cdata(&sb, pool, "checksum", svn_checksum_to_cstring(info->wc_info->checksum, pool)); if (info->wc_info->changelist) /* "<changelist> xx </changelist>" */ svn_cl__xml_tagged_cdata(&sb, pool, "changelist", info->wc_info->changelist); /* "</wc-info>" */ svn_xml_make_close_tag(&sb, pool, "wc-info"); } if (info->last_changed_author || SVN_IS_VALID_REVNUM(info->last_changed_rev) || info->last_changed_date) { svn_cl__print_xml_commit(&sb, info->last_changed_rev, info->last_changed_author, svn_time_to_cstring(info->last_changed_date, pool), pool); } if (info->wc_info && info->wc_info->conflicts) { int i; for (i = 0; i < info->wc_info->conflicts->nelts; i++) { const svn_wc_conflict_description2_t *conflict = APR_ARRAY_IDX(info->wc_info->conflicts, i, const svn_wc_conflict_description2_t *); switch (conflict->kind) { case svn_wc_conflict_kind_text: /* "<conflict>" */ svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "conflict", NULL); /* "<prev-base-file> xx </prev-base-file>" */ svn_cl__xml_tagged_cdata(&sb, pool, "prev-base-file", conflict->base_abspath); /* "<prev-wc-file> xx </prev-wc-file>" */ svn_cl__xml_tagged_cdata(&sb, pool, "prev-wc-file", conflict->my_abspath); /* "<cur-base-file> xx </cur-base-file>" */ svn_cl__xml_tagged_cdata(&sb, pool, "cur-base-file", conflict->their_abspath); /* "</conflict>" */ svn_xml_make_close_tag(&sb, pool, "conflict"); break; case svn_wc_conflict_kind_property: /* "<conflict>" */ svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "conflict", NULL); /* "<prop-file> xx </prop-file>" */ svn_cl__xml_tagged_cdata(&sb, pool, "prop-file", conflict->their_abspath); /* "</conflict>" */ svn_xml_make_close_tag(&sb, pool, "conflict"); break; case svn_wc_conflict_kind_tree: SVN_ERR(svn_cl__append_tree_conflict_info_xml(sb, conflict, pool)); break; } } }
svn_error_t * svn_ra_neon__get_locks(svn_ra_session_t *session, apr_hash_t **locks, const char *path, svn_depth_t depth, apr_pool_t *pool) { svn_ra_neon__session_t *ras = session->priv; const char *body, *url, *rel_path; svn_error_t *err; int status_code = 0; get_locks_baton_t baton; /* We always run the report on the 'public' URL, which represents HEAD anyway. If the path doesn't exist in HEAD, then there can't possibly be a lock, so we just return no locks. */ url = svn_path_url_add_component2(ras->url->data, path, pool); SVN_ERR(svn_ra_neon__get_path_relative_to_root(session, &rel_path, url, pool)); baton.lock_hash = apr_hash_make(pool); baton.path = svn_fspath__canonicalize(rel_path, pool); baton.requested_depth = depth; baton.pool = pool; baton.scratchpool = svn_pool_create(pool); baton.current_lock = NULL; baton.encoding = NULL; baton.cdata_accum = svn_stringbuf_create("", pool); body = apr_psprintf(pool, "<?xml version=\"1.0\" encoding=\"utf-8\"?>" "<S:get-locks-report xmlns:S=\"" SVN_XML_NAMESPACE "\" " "xmlns:D=\"DAV:\" depth=\"%s\">" "</S:get-locks-report>", svn_depth_to_word(depth)); err = svn_ra_neon__parsed_request(ras, "REPORT", url, body, NULL, NULL, getlocks_start_element, getlocks_cdata_handler, getlocks_end_element, &baton, NULL, /* extra headers */ &status_code, FALSE, pool); svn_pool_destroy(baton.scratchpool); if (err && err->apr_err == SVN_ERR_FS_NOT_FOUND) { svn_error_clear(err); *locks = baton.lock_hash; return SVN_NO_ERROR; } /* ### Should svn_ra_neon__parsed_request() take care of storing auth ### info itself? */ err = svn_ra_neon__maybe_store_auth_info_after_result(err, ras, pool); /* Map status 501: Method Not Implemented to our not implemented error. 1.0.x servers and older don't support this report. */ if (status_code == 501) return svn_error_create(SVN_ERR_RA_NOT_IMPLEMENTED, err, _("Server does not support locking features")); if (err && err->apr_err == SVN_ERR_UNSUPPORTED_FEATURE) return svn_error_create(SVN_ERR_RA_NOT_IMPLEMENTED, err, _("Server does not support locking features")); else if (err) return err; *locks = baton.lock_hash; return SVN_NO_ERROR; }
/* Implements svn_ra_serf__request_body_delegate_t */ static svn_error_t * create_list_body(serf_bucket_t **body_bkt, void *baton, serf_bucket_alloc_t *alloc, apr_pool_t *pool /* request pool */, apr_pool_t *scratch_pool) { serf_bucket_t *buckets; list_context_t *list_ctx = baton; int i; buckets = serf_bucket_aggregate_create(alloc); svn_ra_serf__add_open_tag_buckets(buckets, alloc, "S:list-report", "xmlns:S", SVN_XML_NAMESPACE, SVN_VA_NULL); svn_ra_serf__add_tag_buckets(buckets, "S:path", list_ctx->path, alloc); svn_ra_serf__add_tag_buckets(buckets, "S:revision", apr_ltoa(pool, list_ctx->revision), alloc); svn_ra_serf__add_tag_buckets(buckets, "S:depth", svn_depth_to_word(list_ctx->depth), alloc); if (list_ctx->patterns) { for (i = 0; i < list_ctx->patterns->nelts; i++) { char *name = APR_ARRAY_IDX(list_ctx->patterns, i, char *); svn_ra_serf__add_tag_buckets(buckets, "S:pattern", name, alloc); } if (list_ctx->patterns->nelts == 0) { svn_ra_serf__add_empty_tag_buckets(buckets, alloc, "S:no-patterns", SVN_VA_NULL); } } for (i = 0; i < list_ctx->props->nelts; i++) { const svn_ra_serf__dav_props_t *prop = &APR_ARRAY_IDX(list_ctx->props, i, const svn_ra_serf__dav_props_t); const char *name = apr_pstrcat(pool, prop->xmlns, prop->name, SVN_VA_NULL); svn_ra_serf__add_tag_buckets(buckets, "S:prop", name, alloc); } svn_ra_serf__add_close_tag_buckets(buckets, alloc, "S:list-report"); *body_bkt = buckets; return SVN_NO_ERROR; }
/* A callback of type svn_info_receiver_t. Prints svn info in xml mode to standard out */ static svn_error_t * print_info_xml(void *baton, const char *target, const svn_info_t *info, apr_pool_t *pool) { svn_stringbuf_t *sb = svn_stringbuf_create("", pool); const char *rev_str; if (SVN_IS_VALID_REVNUM(info->rev)) rev_str = apr_psprintf(pool, "%ld", info->rev); else rev_str = apr_pstrdup(pool, _("Resource is not under version control.")); /* "<entry ...>" */ svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "entry", "path", svn_path_local_style(target, pool), "kind", svn_cl__node_kind_str_xml(info->kind), "revision", rev_str, NULL); svn_cl__xml_tagged_cdata(&sb, pool, "url", info->URL); if (info->repos_root_URL || info->repos_UUID) { /* "<repository>" */ svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "repository", NULL); /* "<root> xx </root>" */ svn_cl__xml_tagged_cdata(&sb, pool, "root", info->repos_root_URL); /* "<uuid> xx </uuid>" */ svn_cl__xml_tagged_cdata(&sb, pool, "uuid", info->repos_UUID); /* "</repository>" */ svn_xml_make_close_tag(&sb, pool, "repository"); } if (info->has_wc_info) { /* "<wc-info>" */ svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "wc-info", NULL); /* "<schedule> xx </schedule>" */ svn_cl__xml_tagged_cdata(&sb, pool, "schedule", schedule_str(info->schedule)); /* "<depth> xx </depth>" */ svn_cl__xml_tagged_cdata(&sb, pool, "depth", svn_depth_to_word(info->depth)); /* "<copy-from-url> xx </copy-from-url>" */ svn_cl__xml_tagged_cdata(&sb, pool, "copy-from-url", info->copyfrom_url); /* "<copy-from-rev> xx </copy-from-rev>" */ if (SVN_IS_VALID_REVNUM(info->copyfrom_rev)) svn_cl__xml_tagged_cdata(&sb, pool, "copy-from-rev", apr_psprintf(pool, "%ld", info->copyfrom_rev)); /* "<text-updated> xx </text-updated>" */ if (info->text_time) svn_cl__xml_tagged_cdata(&sb, pool, "text-updated", svn_time_to_cstring(info->text_time, pool)); /* "<checksum> xx </checksum>" */ svn_cl__xml_tagged_cdata(&sb, pool, "checksum", info->checksum); if (info->changelist) /* "<changelist> xx </changelist>" */ svn_cl__xml_tagged_cdata(&sb, pool, "changelist", info->changelist); /* "</wc-info>" */ svn_xml_make_close_tag(&sb, pool, "wc-info"); } if (info->last_changed_author || SVN_IS_VALID_REVNUM(info->last_changed_rev) || info->last_changed_date) { svn_cl__print_xml_commit(&sb, info->last_changed_rev, info->last_changed_author, svn_time_to_cstring(info->last_changed_date, pool), pool); } if (info->conflict_old || info->conflict_wrk || info->conflict_new || info->prejfile) { /* "<conflict>" */ svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "conflict", NULL); /* "<prev-base-file> xx </prev-base-file>" */ svn_cl__xml_tagged_cdata(&sb, pool, "prev-base-file", info->conflict_old); /* "<prev-wc-file> xx </prev-wc-file>" */ svn_cl__xml_tagged_cdata(&sb, pool, "prev-wc-file", info->conflict_wrk); /* "<cur-base-file> xx </cur-base-file>" */ svn_cl__xml_tagged_cdata(&sb, pool, "cur-base-file", info->conflict_new); /* "<prop-file> xx </prop-file>" */ svn_cl__xml_tagged_cdata(&sb, pool, "prop-file", info->prejfile); /* "</conflict>" */ svn_xml_make_close_tag(&sb, pool, "conflict"); } if (info->lock) { /* "<lock>" */ svn_xml_make_open_tag(&sb, pool, svn_xml_normal, "lock", NULL); /* "<token> xx </token>" */ svn_cl__xml_tagged_cdata(&sb, pool, "token", info->lock->token); /* "<owner> xx </owner>" */ svn_cl__xml_tagged_cdata(&sb, pool, "owner", info->lock->owner); /* "<comment ...> xxxx </comment>" */ svn_cl__xml_tagged_cdata(&sb, pool, "comment", info->lock->comment); /* "<created> xx </created>" */ svn_cl__xml_tagged_cdata(&sb, pool, "created", svn_time_to_cstring (info->lock->creation_date, pool)); /* "<expires> xx </expires>" */ svn_cl__xml_tagged_cdata(&sb, pool, "expires", svn_time_to_cstring (info->lock->expiration_date, pool)); /* "</lock>" */ svn_xml_make_close_tag(&sb, pool, "lock"); } if (info->tree_conflict) SVN_ERR(svn_cl__append_tree_conflict_info_xml(sb, info->tree_conflict, pool)); /* "</entry>" */ svn_xml_make_close_tag(&sb, pool, "entry"); return svn_cl__error_checked_fputs(sb->data, stdout); }