svn_error_t * svn_cl__propset_print_binary_mime_type_warning(apr_array_header_t *targets, const char *propname, const svn_string_t *propval, apr_pool_t *scratch_pool) { if (strcmp(propname, SVN_PROP_MIME_TYPE) == 0) { apr_pool_t *iterpool = svn_pool_create(scratch_pool); int i; for (i = 0; i < targets->nelts; i++) { const char *detected_mimetype; const char *target = APR_ARRAY_IDX(targets, i, const char *); const char *local_abspath; const svn_string_t *canon_propval; svn_node_kind_t node_kind; svn_pool_clear(iterpool); SVN_ERR(svn_dirent_get_absolute(&local_abspath, target, iterpool)); SVN_ERR(svn_io_check_path(local_abspath, &node_kind, iterpool)); if (node_kind != svn_node_file) continue; SVN_ERR(svn_wc_canonicalize_svn_prop(&canon_propval, propname, propval, local_abspath, svn_node_file, FALSE, NULL, NULL, iterpool)); if (svn_mime_type_is_binary(canon_propval->data)) { SVN_ERR(svn_io_detect_mimetype2(&detected_mimetype, local_abspath, NULL, iterpool)); if (detected_mimetype == NULL || !svn_mime_type_is_binary(detected_mimetype)) svn_error_clear(svn_cmdline_fprintf(stderr, iterpool, _("svn: warning: '%s' is a binary mime-type but file '%s' " "looks like text; diff, merge, blame, and other " "operations will stop working on this file\n"), canon_propval->data, svn_dirent_local_style(local_abspath, iterpool))); } } svn_pool_destroy(iterpool); }
static svn_error_t * propset_on_url(const char *propname, const svn_string_t *propval, const char *target, svn_boolean_t skip_checks, svn_revnum_t base_revision_for_url, const apr_hash_t *revprop_table, svn_commit_callback2_t commit_callback, void *commit_baton, svn_client_ctx_t *ctx, apr_pool_t *pool) { enum svn_prop_kind prop_kind = svn_property_kind(NULL, propname); svn_ra_session_t *ra_session; svn_node_kind_t node_kind; const char *message; const svn_delta_editor_t *editor; void *edit_baton; apr_hash_t *commit_revprops; svn_error_t *err; if (prop_kind != svn_prop_regular_kind) return svn_error_createf (SVN_ERR_BAD_PROP_KIND, NULL, _("Property '%s' is not a regular property"), propname); /* Open an RA session for the URL. Note that we don't have a local directory, nor a place to put temp files. */ SVN_ERR(svn_client__open_ra_session_internal(&ra_session, NULL, target, NULL, NULL, FALSE, TRUE, ctx, pool)); SVN_ERR(svn_ra_check_path(ra_session, "", base_revision_for_url, &node_kind, pool)); if (node_kind == svn_node_none) return svn_error_createf (SVN_ERR_FS_NOT_FOUND, NULL, _("Path '%s' does not exist in revision %ld"), target, base_revision_for_url); /* Setting an inappropriate property is not allowed (unless overridden by 'skip_checks', in some circumstances). Deleting an inappropriate property is allowed, however, since older clients allowed (and other clients possibly still allow) setting it in the first place. */ if (propval && svn_prop_is_svn_prop(propname)) { const svn_string_t *new_value; struct getter_baton gb; gb.ra_session = ra_session; gb.base_revision_for_url = base_revision_for_url; SVN_ERR(svn_wc_canonicalize_svn_prop(&new_value, propname, propval, target, node_kind, skip_checks, get_file_for_validation, &gb, pool)); propval = new_value; } /* Create a new commit item and add it to the array. */ if (SVN_CLIENT__HAS_LOG_MSG_FUNC(ctx)) { svn_client_commit_item3_t *item; const char *tmp_file; apr_array_header_t *commit_items = apr_array_make(pool, 1, sizeof(item)); item = svn_client_commit_item3_create(pool); item->url = target; item->state_flags = SVN_CLIENT_COMMIT_ITEM_PROP_MODS; APR_ARRAY_PUSH(commit_items, svn_client_commit_item3_t *) = item; SVN_ERR(svn_client__get_log_msg(&message, &tmp_file, commit_items, ctx, pool)); if (! message) return SVN_NO_ERROR; } else message = ""; SVN_ERR(svn_client__ensure_revprop_table(&commit_revprops, revprop_table, message, ctx, pool)); /* Fetch RA commit editor. */ SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton, commit_revprops, commit_callback, commit_baton, NULL, TRUE, /* No lock tokens */ pool)); err = do_url_propset(propname, propval, node_kind, base_revision_for_url, editor, edit_baton, pool); if (err) { /* At least try to abort the edit (and fs txn) before throwing err. */ svn_error_clear(editor->abort_edit(edit_baton, pool)); return svn_error_trace(err); } /* Close the edit. */ return editor->close_edit(edit_baton, pool); }