svn_error_t * svn_client_add4(const char *path, svn_depth_t depth, svn_boolean_t force, svn_boolean_t no_ignore, svn_boolean_t add_parents, svn_client_ctx_t *ctx, apr_pool_t *pool) { svn_error_t *err, *err2; svn_wc_adm_access_t *adm_access; const char *parent_dir; if (add_parents) { apr_pool_t *subpool; SVN_ERR(svn_path_get_absolute(&path, path, pool)); parent_dir = svn_path_dirname(path, pool); subpool = svn_pool_create(pool); SVN_ERR(add_parent_dirs(parent_dir, &adm_access, ctx, subpool)); SVN_ERR(svn_wc_adm_close(adm_access)); svn_pool_destroy(subpool); SVN_ERR(svn_wc_adm_open3(&adm_access, NULL, parent_dir, TRUE, 0, ctx->cancel_func, ctx->cancel_baton, pool)); } else { parent_dir = svn_path_dirname(path, pool); SVN_ERR(svn_wc_adm_open3(&adm_access, NULL, parent_dir, TRUE, 0, ctx->cancel_func, ctx->cancel_baton, pool)); } err = add(path, depth, force, no_ignore, adm_access, ctx, pool); err2 = svn_wc_adm_close(adm_access); if (err2) { if (err) svn_error_clear(err2); else err = err2; } return err; }
/* An svn_wc_entry_callbacks2_t callback function. Handle an error encountered by the walker. If the error is "unversioned resource" and, upon checking the parent dir's tree conflict data, we find that PATH is a tree conflict victim, cancel the error and send a minimal info struct. Otherwise re-raise the error. */ static svn_error_t * info_error_handler(const char *path, svn_error_t *err, void *walk_baton, apr_pool_t *pool) { if (err && (err->apr_err == SVN_ERR_UNVERSIONED_RESOURCE)) { struct found_entry_baton *fe_baton = walk_baton; svn_wc_adm_access_t *adm_access; svn_wc_conflict_description_t *tree_conflict; SVN_ERR(svn_wc_adm_probe_try3(&adm_access, fe_baton->adm_access, svn_path_dirname(path, pool), FALSE, 0, NULL, NULL, pool)); SVN_ERR(svn_wc__get_tree_conflict(&tree_conflict, path, adm_access, pool)); if (tree_conflict) { svn_info_t *info; svn_error_clear(err); SVN_ERR(build_info_for_unversioned(&info, pool)); info->tree_conflict = tree_conflict; SVN_ERR(fe_baton->receiver(fe_baton->receiver_baton, path, info, pool)); return SVN_NO_ERROR; } } return err; }
/* Write the format number and maximum number of files per directory to a new format file in PATH, overwriting a previously existing file. Use POOL for temporary allocation. This implementation is largely stolen from libsvn_fs_fs/fs_fs.c. */ static svn_error_t * write_format(const char *path, int format, int max_files_per_dir, apr_pool_t *pool) { const char *contents; path = svn_path_join(path, "format", pool); if (format >= SVN_FS_FS__MIN_LAYOUT_FORMAT_OPTION_FORMAT) { if (max_files_per_dir) contents = apr_psprintf(pool, "%d\n" "layout sharded %d\n", format, max_files_per_dir); else contents = apr_psprintf(pool, "%d\n" "layout linear", format); } else { contents = apr_psprintf(pool, "%d\n", format); } { const char *path_tmp; SVN_ERR(svn_io_write_unique(&path_tmp, svn_path_dirname(path, pool), contents, strlen(contents), svn_io_file_del_none, pool)); #ifdef WIN32 /* make the destination writable, but only on Windows, because Windows does not let us replace read-only files. */ SVN_ERR(svn_io_set_file_read_write(path, TRUE, pool)); #endif /* WIN32 */ /* rename the temp file as the real destination */ SVN_ERR(svn_io_file_rename(path_tmp, path, pool)); } /* And set the perms to make it read only */ return svn_io_set_file_read_only(path, FALSE, pool); }
/* Go up the directory tree, looking for a versioned directory. If found, add all the intermediate directories. Otherwise, return SVN_ERR_CLIENT_NO_VERSIONED_PARENT. */ static svn_error_t * add_parent_dirs(const char *path, svn_wc_adm_access_t **parent_access, svn_client_ctx_t *ctx, apr_pool_t *pool) { svn_wc_adm_access_t *adm_access; svn_error_t *err; err = svn_wc_adm_open3(&adm_access, NULL, path, TRUE, 0, ctx->cancel_func, ctx->cancel_baton, pool); if (err && err->apr_err == SVN_ERR_WC_NOT_DIRECTORY) { if (svn_dirent_is_root(path, strlen(path))) { svn_error_clear(err); return svn_error_create (SVN_ERR_CLIENT_NO_VERSIONED_PARENT, NULL, NULL); } else { const char *parent_path = svn_path_dirname(path, pool); svn_error_clear(err); SVN_ERR(add_parent_dirs(parent_path, &adm_access, ctx, pool)); SVN_ERR(svn_wc_adm_retrieve(&adm_access, adm_access, parent_path, pool)); SVN_ERR(svn_wc_add2(path, adm_access, NULL, SVN_INVALID_REVNUM, ctx->cancel_func, ctx->cancel_baton, ctx->notify_func2, ctx->notify_baton2, pool)); } } else if (err) { return err; } if (parent_access) *parent_access = adm_access; return SVN_NO_ERROR; }
static svn_error_t * do_resources(const dav_svn_repos *repos, svn_fs_root_t *root, svn_revnum_t revision, ap_filter_t *output, apr_bucket_brigade *bb, apr_pool_t *pool) { apr_hash_t *changes; apr_hash_t *sent = apr_hash_make(pool); apr_hash_index_t *hi; apr_pool_t *subpool = svn_pool_create(pool); /* Fetch the paths changed in this revision. This will contain everything except otherwise-unchanged parent directories of added and deleted things. Also, note that deleted things don't merit responses of their own -- they are considered modifications to their parent. */ SVN_ERR(svn_fs_paths_changed2(&changes, root, pool)); for (hi = apr_hash_first(pool, changes); hi; hi = apr_hash_next(hi)) { const void *key; void *val; const char *path; svn_fs_path_change2_t *change; svn_boolean_t send_self; svn_boolean_t send_parent; svn_pool_clear(subpool); apr_hash_this(hi, &key, NULL, &val); path = key; change = val; /* Figure out who needs to get sent. */ switch (change->change_kind) { case svn_fs_path_change_delete: send_self = FALSE; send_parent = TRUE; break; case svn_fs_path_change_add: case svn_fs_path_change_replace: send_self = TRUE; send_parent = TRUE; break; case svn_fs_path_change_modify: default: send_self = TRUE; send_parent = FALSE; break; } if (send_self) { /* If we haven't already sent this path, send it (and then remember that we sent it). */ if (! apr_hash_get(sent, path, APR_HASH_KEY_STRING)) { svn_node_kind_t kind; SVN_ERR(svn_fs_check_path(&kind, root, path, subpool)); SVN_ERR(send_response(repos, root, path, kind == svn_node_dir, output, bb, subpool)); apr_hash_set(sent, path, APR_HASH_KEY_STRING, (void *)1); } } if (send_parent) { /* If it hasn't already been sent, send the parent directory (and then remember that you sent it). Allocate parent in pool, not subpool, because it stays in the sent hash afterwards. */ const char *parent = svn_path_dirname(path, pool); if (! apr_hash_get(sent, parent, APR_HASH_KEY_STRING)) { SVN_ERR(send_response(repos, root, parent, TRUE, output, bb, subpool)); apr_hash_set(sent, parent, APR_HASH_KEY_STRING, (void *)1); } } } svn_pool_destroy(subpool); return SVN_NO_ERROR; }
svn_error_t * svn_nls_init(void) { svn_error_t *err = SVN_NO_ERROR; #ifdef ENABLE_NLS #ifdef WIN32 { WCHAR ucs2_path[MAX_PATH]; char* utf8_path; const char* internal_path; apr_pool_t* pool; apr_status_t apr_err; apr_size_t inwords, outbytes, outlength; apr_pool_create(&pool, 0); /* get exe name - our locale info will be in '../share/locale' */ inwords = GetModuleFileNameW(0, ucs2_path, sizeof(ucs2_path) / sizeof(ucs2_path[0])); if (! inwords) { /* We must be on a Win9x machine, so attempt to get an ANSI path, and convert it to Unicode. */ CHAR ansi_path[MAX_PATH]; if (GetModuleFileNameA(0, ansi_path, sizeof(ansi_path))) { inwords = MultiByteToWideChar(CP_ACP, 0, ansi_path, -1, ucs2_path, sizeof(ucs2_path) / sizeof(ucs2_path[0])); if (! inwords) { err = svn_error_createf(APR_EINVAL, NULL, _("Can't convert string to UCS-2: '%s'"), ansi_path); } } else { err = svn_error_create(APR_EINVAL, NULL, _("Can't get module file name")); } } if (! err) { outbytes = outlength = 3 * (inwords + 1); utf8_path = apr_palloc(pool, outlength); apr_err = apr_conv_ucs2_to_utf8(ucs2_path, &inwords, utf8_path, &outbytes); if (!apr_err && (inwords > 0 || outbytes == 0)) apr_err = APR_INCOMPLETE; if (apr_err) { err = svn_error_createf(apr_err, NULL, _("Can't convert module path " "to UTF-8 from UCS-2: '%s'"), ucs2_path); } else { utf8_path[outlength - outbytes] = '\0'; internal_path = svn_path_internal_style(utf8_path, pool); /* get base path name */ internal_path = svn_path_dirname(internal_path, pool); internal_path = svn_path_join(internal_path, SVN_LOCALE_RELATIVE_PATH, pool); bindtextdomain(PACKAGE_NAME, internal_path); } } svn_pool_destroy(pool); } #else bindtextdomain(PACKAGE_NAME, SVN_LOCALE_DIR); #ifdef HAVE_BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"); #endif #endif #endif return err; }