export.c
来自「subversion-1.4.3-1.tar.gz 配置svn的源码」· C语言 代码 · 共 958 行 · 第 1/3 页
C
958 行
fb->special = TRUE; return SVN_NO_ERROR;}static svn_error_t *change_dir_prop(void *dir_baton, const char *name, const svn_string_t *value, apr_pool_t *pool){ struct dir_baton *db = dir_baton; struct edit_baton *eb = db->edit_baton; if (value && (strcmp(name, SVN_PROP_EXTERNALS) == 0)) add_externals(eb->externals, db->path, value); return SVN_NO_ERROR;}/* Move the tmpfile to file, and send feedback. */static svn_error_t *close_file(void *file_baton, const char *text_checksum, apr_pool_t *pool){ struct file_baton *fb = file_baton; struct edit_baton *eb = fb->edit_baton; /* Was a txdelta even sent? */ if (! fb->tmppath) return SVN_NO_ERROR; SVN_ERR(svn_io_file_close(fb->tmp_file, fb->pool)); if (text_checksum) { const char *actual_checksum = svn_md5_digest_to_cstring(fb->text_digest, pool); if (actual_checksum && (strcmp(text_checksum, actual_checksum) != 0)) { return svn_error_createf (SVN_ERR_CHECKSUM_MISMATCH, NULL, _("Checksum mismatch for '%s'; expected: '%s', actual: '%s'"), svn_path_local_style(fb->path, pool), text_checksum, actual_checksum); } } if ((! fb->eol_style_val) && (! fb->keywords_val) && (! fb->special)) { SVN_ERR(svn_io_file_rename(fb->tmppath, fb->path, pool)); } else { svn_subst_eol_style_t style; const char *eol; apr_hash_t *final_kw; if (fb->eol_style_val) SVN_ERR(get_eol_style(&style, &eol, fb->eol_style_val->data, eb->native_eol)); if (fb->keywords_val) SVN_ERR(svn_subst_build_keywords2(&final_kw, fb->keywords_val->data, fb->revision, fb->url, fb->date, fb->author, pool)); SVN_ERR(svn_subst_copy_and_translate3 (fb->tmppath, fb->path, fb->eol_style_val ? eol : NULL, fb->eol_style_val ? TRUE : FALSE, /* repair */ fb->keywords_val ? final_kw : NULL, TRUE, /* expand */ fb->special, pool)); SVN_ERR(svn_io_remove_file(fb->tmppath, pool)); } if (fb->executable_val) SVN_ERR(svn_io_set_file_executable(fb->path, TRUE, FALSE, pool)); if (fb->date && (! fb->special)) SVN_ERR(svn_io_set_file_affected_time(fb->date, fb->path, pool)); if (fb->edit_baton->notify_func) { svn_wc_notify_t *notify = svn_wc_create_notify(fb->path, svn_wc_notify_update_add, pool); notify->kind = svn_node_file; (*fb->edit_baton->notify_func)(fb->edit_baton->notify_baton, notify, pool); } return SVN_NO_ERROR;}/*** Public Interfaces ***/svn_error_t *svn_client_export3(svn_revnum_t *result_rev, const char *from, const char *to, const svn_opt_revision_t *peg_revision, const svn_opt_revision_t *revision, svn_boolean_t overwrite, svn_boolean_t ignore_externals, svn_boolean_t recurse, const char *native_eol, svn_client_ctx_t *ctx, apr_pool_t *pool){ svn_revnum_t edit_revision = SVN_INVALID_REVNUM; const char *url; if (svn_path_is_url(from) || ! (revision->kind == svn_opt_revision_base || revision->kind == svn_opt_revision_committed || revision->kind == svn_opt_revision_working || revision->kind == svn_opt_revision_unspecified)) { svn_revnum_t revnum; svn_ra_session_t *ra_session; svn_node_kind_t kind; struct edit_baton *eb = apr_pcalloc(pool, sizeof(*eb)); /* Get the RA connection. */ SVN_ERR(svn_client__ra_session_from_path(&ra_session, &revnum, &url, from, peg_revision, revision, ctx, pool)); eb->root_path = to; eb->root_url = url; eb->force = overwrite; eb->target_revision = &edit_revision; eb->notify_func = ctx->notify_func2; eb->notify_baton = ctx->notify_baton2; eb->externals = apr_hash_make(pool); eb->native_eol = native_eol; SVN_ERR(svn_ra_check_path(ra_session, "", revnum, &kind, pool)); if (kind == svn_node_file) { apr_hash_t *props; apr_hash_index_t *hi; struct file_baton *fb = apr_pcalloc(pool, sizeof(*fb)); /* Since you cannot actually root an editor at a file, we * manually drive a few functions of our editor. */ /* This is the equivalent of a parentless add_file(). */ fb->edit_baton = eb; fb->path = eb->root_path; fb->url = eb->root_url; fb->pool = pool; /* Copied from apply_textdelta(). */ SVN_ERR(svn_io_open_unique_file2(&fb->tmp_file, &(fb->tmppath), fb->path, ".tmp", svn_io_file_del_none, fb->pool)); /* Step outside the editor-likeness for a moment, to actually talk * to the repository. */ SVN_ERR(svn_ra_get_file(ra_session, "", revnum, svn_stream_from_aprfile(fb->tmp_file, pool), NULL, &props, pool)); /* Push the props into change_file_prop(), to update the file_baton * with information. */ for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi)) { const void *key; void *val; apr_hash_this(hi, &key, NULL, &val); SVN_ERR(change_file_prop(fb, key, val, pool)); } /* And now just use close_file() to do all the keyword and EOL * work, and put the file into place. */ SVN_ERR(close_file(fb, NULL, pool)); } else if (kind == svn_node_dir) { void *edit_baton; const svn_delta_editor_t *export_editor; const svn_ra_reporter2_t *reporter; void *report_baton; svn_delta_editor_t *editor = svn_delta_default_editor(pool); svn_boolean_t use_sleep = FALSE; editor->set_target_revision = set_target_revision; editor->open_root = open_root; editor->add_directory = add_directory; editor->add_file = add_file; editor->apply_textdelta = apply_textdelta; editor->close_file = close_file; editor->change_file_prop = change_file_prop; editor->change_dir_prop = change_dir_prop; SVN_ERR(svn_delta_get_cancellation_editor(ctx->cancel_func, ctx->cancel_baton, editor, eb, &export_editor, &edit_baton, pool)); /* Manufacture a basic 'report' to the update reporter. */ SVN_ERR(svn_ra_do_update(ra_session, &reporter, &report_baton, revnum, "", /* no sub-target */ recurse, export_editor, edit_baton, pool)); SVN_ERR(reporter->set_path(report_baton, "", revnum, TRUE, /* "help, my dir is empty!" */ NULL, pool)); SVN_ERR(reporter->finish_report(report_baton, pool)); /* Special case: Due to our sly export/checkout method of * updating an empty directory, no target will have been created * if the exported item is itself an empty directory * (export_editor->open_root never gets called, because there * are no "changes" to make to the empty dir we reported to the * repository). * * So we just create the empty dir manually; but we do it via * open_root_internal(), in order to get proper notification. */ SVN_ERR(svn_io_check_path(to, &kind, pool)); if (kind == svn_node_none) SVN_ERR(open_root_internal (to, overwrite, ctx->notify_func2, ctx->notify_baton2, pool)); if (! ignore_externals && recurse) SVN_ERR(svn_client__fetch_externals(eb->externals, TRUE, &use_sleep, ctx, pool)); } } else { svn_opt_revision_t working_revision = *revision; /* This is a working copy export. */ if (working_revision.kind == svn_opt_revision_unspecified) { /* Default to WORKING in the case that we have been given a working copy path */ working_revision.kind = svn_opt_revision_working; } /* just copy the contents of the working copy into the target path. */ SVN_ERR(copy_versioned_files(from, to, &working_revision, overwrite, recurse, native_eol, ctx, pool)); } if (ctx->notify_func2) { svn_wc_notify_t *notify = svn_wc_create_notify(to, svn_wc_notify_update_completed, pool); notify->revision = edit_revision; (*ctx->notify_func2)(ctx->notify_baton2, notify, pool); } if (result_rev) *result_rev = edit_revision; return SVN_NO_ERROR;}svn_error_t *svn_client_export2(svn_revnum_t *result_rev, const char *from, const char *to, svn_opt_revision_t *revision, svn_boolean_t force, const char *native_eol, svn_client_ctx_t *ctx, apr_pool_t *pool){ svn_opt_revision_t peg_revision; peg_revision.kind = svn_opt_revision_unspecified; return svn_client_export3(result_rev, from, to, &peg_revision, revision, force, FALSE, TRUE, native_eol, ctx, pool);} svn_error_t *svn_client_export(svn_revnum_t *result_rev, const char *from, const char *to, svn_opt_revision_t *revision, svn_boolean_t force, svn_client_ctx_t *ctx, apr_pool_t *pool){ return svn_client_export2(result_rev, from, to, revision, force, NULL, ctx, pool);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?