export.c
来自「subversion-1.4.3-1.tar.gz 配置svn的源码」· C语言 代码 · 共 958 行 · 第 1/3 页
C
958 行
else if (entry->kind == svn_node_file) { const char *new_from = svn_path_join(from, item, iterpool); const char *new_to = svn_path_join(to, item, iterpool); SVN_ERR(copy_one_versioned_file(new_from, new_to, adm_access, revision, native_eol, iterpool)); } } svn_pool_destroy(iterpool); } else if (entry->kind == svn_node_file) { SVN_ERR(copy_one_versioned_file(from, to, adm_access, revision, native_eol, pool)); } SVN_ERR(svn_wc_adm_close(adm_access)); return SVN_NO_ERROR;}/* Abstraction of open_root. * * Create PATH if it does not exist and is not obstructed, and invoke * NOTIFY_FUNC with NOTIFY_BATON on PATH. * * If PATH exists but is a file, then error with SVN_ERR_WC_NOT_DIRECTORY. * * If PATH is a already a directory, then error with * SVN_ERR_WC_OBSTRUCTED_UPDATE, unless FORCE, in which case just * export into PATH with no error. */static svn_error_t *open_root_internal(const char *path, svn_boolean_t force, svn_wc_notify_func2_t notify_func, void *notify_baton, apr_pool_t *pool){ svn_node_kind_t kind; SVN_ERR(svn_io_check_path(path, &kind, pool)); if (kind == svn_node_none) SVN_ERR(svn_io_make_dir_recursively(path, pool)); else if (kind == svn_node_file) return svn_error_createf(SVN_ERR_WC_NOT_DIRECTORY, NULL, _("'%s' exists and is not a directory"), svn_path_local_style(path, pool)); else if ((kind != svn_node_dir) || (! force)) return svn_error_createf(SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL, _("'%s' already exists"), svn_path_local_style(path, pool)); if (notify_func) { svn_wc_notify_t *notify = svn_wc_create_notify(path, svn_wc_notify_update_add, pool); notify->kind = svn_node_dir; (*notify_func)(notify_baton, notify, pool); } return SVN_NO_ERROR;}/* ---------------------------------------------------------------------- *//*** A dedicated 'export' editor, which does no .svn/ accounting. ***/struct edit_baton{ const char *root_path; const char *root_url; svn_boolean_t force; svn_revnum_t *target_revision; apr_hash_t *externals; const char *native_eol; svn_wc_notify_func2_t notify_func; void *notify_baton;};struct dir_baton{ struct edit_baton *edit_baton; const char *path;};struct file_baton{ struct edit_baton *edit_baton; const char *path; const char *tmppath; /* We need to keep this around so we can explicitly close it in close_file, thus flushing its output to disk so we can copy and translate it. */ apr_file_t *tmp_file; /* The MD5 digest of the file's fulltext. This is all zeros until the last textdelta window handler call returns. */ unsigned char text_digest[APR_MD5_DIGESTSIZE]; /* The three svn: properties we might actually care about. */ const svn_string_t *eol_style_val; const svn_string_t *keywords_val; const svn_string_t *executable_val; svn_boolean_t special; /* Any keyword vals to be substituted */ const char *revision; const char *url; const char *author; apr_time_t date; /* Pool associated with this baton. */ apr_pool_t *pool;};struct handler_baton{ svn_txdelta_window_handler_t apply_handler; void *apply_baton; apr_pool_t *pool; const char *tmppath;};static svn_error_t *set_target_revision(void *edit_baton, svn_revnum_t target_revision, apr_pool_t *pool){ struct edit_baton *eb = edit_baton; /* Stashing a target_revision in the baton */ *(eb->target_revision) = target_revision; return SVN_NO_ERROR;}/* Just ensure that the main export directory exists. */static svn_error_t *open_root(void *edit_baton, svn_revnum_t base_revision, apr_pool_t *pool, void **root_baton){ struct edit_baton *eb = edit_baton; struct dir_baton *db = apr_pcalloc(pool, sizeof(*db)); SVN_ERR(open_root_internal(eb->root_path, eb->force, eb->notify_func, eb->notify_baton, pool)); /* Build our dir baton. */ db->path = eb->root_path; db->edit_baton = eb; *root_baton = db; return SVN_NO_ERROR;}/* Ensure the directory exists, and send feedback. */static svn_error_t *add_directory(const char *path, void *parent_baton, const char *copyfrom_path, svn_revnum_t copyfrom_revision, apr_pool_t *pool, void **baton){ struct dir_baton *pb = parent_baton; struct dir_baton *db = apr_pcalloc(pool, sizeof(*db)); struct edit_baton *eb = pb->edit_baton; const char *full_path = svn_path_join(eb->root_path, path, pool); svn_node_kind_t kind; SVN_ERR(svn_io_check_path(full_path, &kind, pool)); if (kind == svn_node_none) SVN_ERR(svn_io_dir_make(full_path, APR_OS_DEFAULT, pool)); else if (kind == svn_node_file) return svn_error_createf(SVN_ERR_WC_NOT_DIRECTORY, NULL, _("'%s' exists and is not a directory"), svn_path_local_style(full_path, pool)); else if (! (kind == svn_node_dir && eb->force)) return svn_error_createf(SVN_ERR_WC_OBSTRUCTED_UPDATE, NULL, _("'%s' already exists"), svn_path_local_style(full_path, pool)); if (eb->notify_func) { svn_wc_notify_t *notify = svn_wc_create_notify(full_path, svn_wc_notify_update_add, pool); notify->kind = svn_node_dir; (*eb->notify_func)(eb->notify_baton, notify, pool); } /* Build our dir baton. */ db->path = full_path; db->edit_baton = eb; *baton = db; return SVN_NO_ERROR;}/* Build a file baton. */static svn_error_t *add_file(const char *path, void *parent_baton, const char *copyfrom_path, svn_revnum_t copyfrom_revision, apr_pool_t *pool, void **baton){ struct dir_baton *pb = parent_baton; struct edit_baton *eb = pb->edit_baton; struct file_baton *fb = apr_pcalloc(pool, sizeof(*fb)); const char *full_path = svn_path_join(eb->root_path, path, pool); const char *full_url = svn_path_join(eb->root_url, path, pool); fb->edit_baton = eb; fb->path = full_path; fb->url = full_url; fb->pool = pool; *baton = fb; return SVN_NO_ERROR;}static svn_error_t *window_handler(svn_txdelta_window_t *window, void *baton){ struct handler_baton *hb = baton; svn_error_t *err; err = hb->apply_handler(window, hb->apply_baton); if (err) { /* We failed to apply the patch; clean up the temporary file. */ apr_file_remove(hb->tmppath, hb->pool); } return err;}/* Write incoming data into the tmpfile stream */static svn_error_t *apply_textdelta(void *file_baton, const char *base_checksum, apr_pool_t *pool, svn_txdelta_window_handler_t *handler, void **handler_baton){ struct file_baton *fb = file_baton; struct handler_baton *hb = apr_palloc(pool, sizeof(*hb)); SVN_ERR(svn_io_open_unique_file2(&fb->tmp_file, &(fb->tmppath), fb->path, ".tmp", svn_io_file_del_none, fb->pool)); hb->pool = pool; hb->tmppath = fb->tmppath; svn_txdelta_apply(svn_stream_empty(pool), svn_stream_from_aprfile(fb->tmp_file, pool), fb->text_digest, NULL, pool, &hb->apply_handler, &hb->apply_baton); *handler_baton = hb; *handler = window_handler; return SVN_NO_ERROR;}static svn_error_t *change_file_prop(void *file_baton, const char *name, const svn_string_t *value, apr_pool_t *pool){ struct file_baton *fb = file_baton; if (! value) return SVN_NO_ERROR; /* Store only the magic three properties. */ if (strcmp(name, SVN_PROP_EOL_STYLE) == 0) fb->eol_style_val = svn_string_dup(value, fb->pool); else if (strcmp(name, SVN_PROP_KEYWORDS) == 0) fb->keywords_val = svn_string_dup(value, fb->pool); else if (strcmp(name, SVN_PROP_EXECUTABLE) == 0) fb->executable_val = svn_string_dup(value, fb->pool); /* Try to fill out the baton's keywords-structure too. */ else if (strcmp(name, SVN_PROP_ENTRY_COMMITTED_REV) == 0) fb->revision = apr_pstrdup(fb->pool, value->data); else if (strcmp(name, SVN_PROP_ENTRY_COMMITTED_DATE) == 0) SVN_ERR(svn_time_from_cstring(&fb->date, value->data, fb->pool)); else if (strcmp(name, SVN_PROP_ENTRY_LAST_AUTHOR) == 0) fb->author = apr_pstrdup(fb->pool, value->data); else if (strcmp(name, SVN_PROP_SPECIAL) == 0)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?