/* Working copy lock callback for svn_client_propset4 */ static svn_error_t * set_props_cb(void *baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { struct set_props_baton *bt = baton; SVN_ERR(svn_wc_prop_set4(bt->ctx->wc_ctx, bt->local_abspath, bt->propname, bt->propval, bt->depth, bt->skip_checks, bt->changelist_filter, bt->ctx->cancel_func, bt->ctx->cancel_baton, bt->ctx->notify_func2, bt->ctx->notify_baton2, scratch_pool)); return SVN_NO_ERROR; }
static svn_error_t * dir_change_prop(void *dir_baton, const char *name, const svn_string_t *value, apr_pool_t *scratch_pool) { struct dir_baton_t *db = dir_baton; struct edit_baton_t *eb = db->eb; svn_prop_kind_t prop_kind; prop_kind = svn_property_kind2(name); if (prop_kind != svn_prop_regular_kind || ! strcmp(name, SVN_PROP_MERGEINFO)) { /* We can't handle DAV, ENTRY and merge specific props here */ return SVN_NO_ERROR; } if (! db->created) { /* We can still store them in the hash for immediate addition with the svn_wc_add_from_disk3() call */ if (! db->properties) db->properties = apr_hash_make(db->pool); if (value != NULL) svn_hash_sets(db->properties, apr_pstrdup(db->pool, name), svn_string_dup(value, db->pool)); } else { /* We have already notified for this directory, so don't do that again */ SVN_ERR(svn_wc_prop_set4(eb->wc_ctx, db->local_abspath, name, value, svn_depth_empty, FALSE, NULL, NULL, NULL, /* Cancellation */ NULL, NULL, /* Notification */ scratch_pool)); } return SVN_NO_ERROR; }
static svn_error_t * file_change_prop(void *file_baton, const char *name, const svn_string_t *value, apr_pool_t *scratch_pool) { struct file_baton_t *fb = file_baton; struct edit_baton_t *eb = fb->eb; svn_prop_kind_t prop_kind; prop_kind = svn_property_kind2(name); if (prop_kind != svn_prop_regular_kind || (eb->ignore_mergeinfo_changes && ! strcmp(name, SVN_PROP_MERGEINFO))) { /* We can't handle DAV, ENTRY and merge specific props here */ return SVN_NO_ERROR; } if (! fb->created) { /* Store properties to be added later in svn_wc_add_from_disk3() */ if (! fb->properties) fb->properties = apr_hash_make(fb->pool); if (value != NULL) svn_hash_sets(fb->properties, apr_pstrdup(fb->pool, name), svn_string_dup(value, fb->pool)); } else { SVN_ERR(svn_wc_prop_set4(eb->wc_ctx, fb->local_abspath, name, value, svn_depth_empty, FALSE, NULL, NULL, NULL, /* Cancellation */ NULL, NULL, /* Notification */ scratch_pool)); } return SVN_NO_ERROR; }
/* Only call this if the on-disk node kind is a file. */ static svn_error_t * add_file(const char *local_abspath, svn_magic__cookie_t *magic_cookie, svn_client_ctx_t *ctx, apr_pool_t *pool) { apr_hash_t* properties; apr_hash_index_t *hi; const char *mimetype; svn_node_kind_t kind; svn_boolean_t is_special; /* Check to see if this is a special file. */ SVN_ERR(svn_io_check_special_path(local_abspath, &kind, &is_special, pool)); if (is_special) mimetype = NULL; else /* Get automatic properties */ /* This may fail on write-only files: we open them to estimate file type. That's why we postpone the add until after this step. */ SVN_ERR(svn_client__get_auto_props(&properties, &mimetype, local_abspath, magic_cookie, ctx, pool)); /* Add the file */ SVN_ERR(svn_wc_add_from_disk(ctx->wc_ctx, local_abspath, NULL, NULL, pool)); if (is_special) /* This must be a special file. */ SVN_ERR(svn_wc_prop_set4(ctx->wc_ctx, local_abspath, SVN_PROP_SPECIAL, svn_string_create(SVN_PROP_BOOLEAN_TRUE, pool), svn_depth_empty, FALSE, NULL, NULL, NULL /* cancellation */, NULL, NULL /* notification */, pool)); else if (properties) { /* loop through the hashtable and add the properties */ for (hi = apr_hash_first(pool, properties); hi != NULL; hi = apr_hash_next(hi)) { const char *pname = svn__apr_hash_index_key(hi); const svn_string_t *pval = svn__apr_hash_index_val(hi); svn_error_t *err; /* It's probably best to pass 0 for force, so that if the autoprops say to set some weird combination, we just error and let the user sort it out. */ err = svn_wc_prop_set4(ctx->wc_ctx, local_abspath, pname, pval, svn_depth_empty, FALSE, NULL, NULL, NULL /* cancellation */, NULL, NULL /* notification */, pool); if (err) { /* Don't leave the job half-done. If we fail to set a property, * (try to) un-add the file. */ svn_error_clear(svn_wc_revert4(ctx->wc_ctx, local_abspath, svn_depth_empty, FALSE /* use_commit_times */, NULL /* changelists */, NULL, NULL, NULL, NULL, pool)); return svn_error_trace(err); } } } /* Report the addition to the caller. */ if (ctx->notify_func2 != NULL) { svn_wc_notify_t *notify = svn_wc_create_notify(local_abspath, svn_wc_notify_add, pool); notify->kind = svn_node_file; notify->mime_type = mimetype; (*ctx->notify_func2)(ctx->notify_baton2, notify, pool); } return SVN_NO_ERROR; }