diff.c
来自「subversion-1.4.3-1.tar.gz 配置svn的源码」· C语言 代码 · 共 1,827 行 · 第 1/4 页
C
1,827 行
repos_mimetype = get_prop_mimetype(repos_props); /* The repository version of the file is in the temp file we applied the BASE->repos delta to. If we haven't seen any changes, it's the same as BASE. */ temp_file_path = b->temp_file_path; if (!temp_file_path) temp_file_path = svn_wc__text_base_path(b->path, FALSE, b->pool); /* If the file isn't in the working copy (either because it was added in the BASE->repos diff or because we're diffing against WORKING and it was marked as schedule-deleted), we show either an addition or a deletion of the complete contents of the repository file, depending upon the direction of the diff. */ if (b->added || (!eb->use_text_base && entry->schedule == svn_wc_schedule_delete)) { if (eb->reverse_order) return b->edit_baton->callbacks->file_added (NULL, NULL, NULL, b->path, empty_file, temp_file_path, 0, eb->revnum, NULL, repos_mimetype, b->propchanges, apr_hash_make(pool), b->edit_baton->callback_baton); else return b->edit_baton->callbacks->file_deleted (NULL, NULL, b->path, temp_file_path, empty_file, repos_mimetype, NULL, repos_props, b->edit_baton->callback_baton); } /* If we didn't see any content changes between the BASE and repository versions (i.e. we only saw property changes), then, if we're diffing against WORKING, we also need to check whether there are any local (BASE:WORKING) modifications. */ modified = (b->temp_file_path != NULL); if (!modified && !eb->use_text_base) SVN_ERR(svn_wc_text_modified_p(&modified, b->path, FALSE, adm_access, pool)); if (modified) { if (eb->use_text_base) localfile = svn_wc__text_base_path(b->path, FALSE, b->pool); else /* a detranslated version of the working file */ SVN_ERR(svn_wc_translated_file2 (&localfile, b->path, b->path, adm_access, SVN_WC_TRANSLATE_TO_NF | SVN_WC_TRANSLATE_USE_GLOBAL_TMP, pool)); } else localfile = temp_file_path = NULL; if (eb->use_text_base) { originalprops = base_props; } else { SVN_ERR(svn_wc_prop_list(&originalprops, b->path, adm_access, pool)); /* We have the repository properties in repos_props, and the WORKING properties in originalprops. Recalculate b->propchanges as the change between WORKING and repos. */ SVN_ERR(svn_prop_diffs(&b->propchanges, repos_props, originalprops, b->pool)); } if (localfile || b->propchanges->nelts > 0) { const char *original_mimetype = get_prop_mimetype(originalprops); if (b->propchanges->nelts > 0 && ! eb->reverse_order) reverse_propchanges(originalprops, b->propchanges, b->pool); SVN_ERR(b->edit_baton->callbacks->file_changed (NULL, NULL, NULL, b->path, eb->reverse_order ? localfile : temp_file_path, eb->reverse_order ? temp_file_path : localfile, eb->reverse_order ? SVN_INVALID_REVNUM : b->edit_baton->revnum, eb->reverse_order ? b->edit_baton->revnum : SVN_INVALID_REVNUM, eb->reverse_order ? original_mimetype : repos_mimetype, eb->reverse_order ? repos_mimetype : original_mimetype, b->propchanges, originalprops, b->edit_baton->callback_baton)); } return SVN_NO_ERROR;}/* An editor function. */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 *b = file_baton; svn_prop_t *propchange; propchange = apr_array_push(b->propchanges); propchange->name = apr_pstrdup(b->pool, name); propchange->value = value ? svn_string_dup(value, b->pool) : NULL; return SVN_NO_ERROR;}/* An editor function. */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; svn_prop_t *propchange; propchange = apr_array_push(db->propchanges); propchange->name = apr_pstrdup(db->pool, name); propchange->value = value ? svn_string_dup(value, db->pool) : NULL; return SVN_NO_ERROR;}/* An editor function. */static svn_error_t *close_edit(void *edit_baton, apr_pool_t *pool){ struct edit_baton *eb = edit_baton; if (!eb->root_opened) { struct dir_baton *b; b = make_dir_baton(eb->anchor_path, NULL, eb, FALSE, eb->pool); SVN_ERR(directory_elements_diff(b)); } return SVN_NO_ERROR;}/* An svn_wc_diff_callbacks2_t function. */static svn_error_t *file_changed(svn_wc_adm_access_t *adm_access, svn_wc_notify_state_t *contentstate, svn_wc_notify_state_t *propstate, const char *path, const char *tmpfile1, const char *tmpfile2, svn_revnum_t rev1, svn_revnum_t rev2, const char *mimetype1, const char *mimetype2, const apr_array_header_t *propchanges, apr_hash_t *originalprops, void *diff_baton){ struct callbacks_wrapper_baton *b = diff_baton; if (tmpfile2 != NULL) SVN_ERR(b->callbacks->file_changed(adm_access, contentstate, path, tmpfile1, tmpfile2, rev1, rev2, mimetype1, mimetype2, b->baton)); if (propchanges->nelts > 0) SVN_ERR(b->callbacks->props_changed(adm_access, propstate, path, propchanges, originalprops, b->baton)); return SVN_NO_ERROR;}/* An svn_wc_diff_callbacks2_t function. */static svn_error_t *file_added(svn_wc_adm_access_t *adm_access, svn_wc_notify_state_t *contentstate, svn_wc_notify_state_t *propstate, const char *path, const char *tmpfile1, const char *tmpfile2, svn_revnum_t rev1, svn_revnum_t rev2, const char *mimetype1, const char *mimetype2, const apr_array_header_t *propchanges, apr_hash_t *originalprops, void *diff_baton){ struct callbacks_wrapper_baton *b = diff_baton; SVN_ERR(b->callbacks->file_added(adm_access, contentstate, path, tmpfile1, tmpfile2, rev1, rev2, mimetype1, mimetype2, b->baton)); if (propchanges->nelts > 0) SVN_ERR(b->callbacks->props_changed(adm_access, propstate, path, propchanges, originalprops, b->baton)); return SVN_NO_ERROR;}/* An svn_wc_diff_callbacks2_t function. */static svn_error_t *file_deleted(svn_wc_adm_access_t *adm_access, svn_wc_notify_state_t *state, const char *path, const char *tmpfile1, const char *tmpfile2, const char *mimetype1, const char *mimetype2, apr_hash_t *originalprops, void *diff_baton){ struct callbacks_wrapper_baton *b = diff_baton; assert(originalprops); return b->callbacks->file_deleted(adm_access, state, path, tmpfile1, tmpfile2, mimetype1, mimetype2, b->baton);} /* An svn_wc_diff_callbacks2_t function. */static svn_error_t *dir_added(svn_wc_adm_access_t *adm_access, svn_wc_notify_state_t *state, const char *path, svn_revnum_t rev, void *diff_baton){ struct callbacks_wrapper_baton *b = diff_baton; return b->callbacks->dir_added(adm_access, state, path, rev, b->baton);} /* An svn_wc_diff_callbacks2_t function. */static svn_error_t *dir_deleted(svn_wc_adm_access_t *adm_access, svn_wc_notify_state_t *state, const char *path, void *diff_baton){ struct callbacks_wrapper_baton *b = diff_baton; return b->callbacks->dir_deleted(adm_access, state, path, b->baton);} /* An svn_wc_diff_callbacks2_t function. */static svn_error_t *dir_props_changed(svn_wc_adm_access_t *adm_access, svn_wc_notify_state_t *state, const char *path, const apr_array_header_t *propchanges, apr_hash_t *originalprops, void *diff_baton){ struct callbacks_wrapper_baton *b = diff_baton; return b->callbacks->props_changed(adm_access, state, path, propchanges, originalprops, b->baton);}/* Used to wrap svn_diff_callbacks_t as an svn_wc_diff_callbacks_2t. */static struct svn_wc_diff_callbacks2_t callbacks_wrapper = { file_changed, file_added, file_deleted, dir_added, dir_deleted, dir_props_changed};/* Public Interface *//* Create a diff editor and baton. */svn_error_t *svn_wc_get_diff_editor3(svn_wc_adm_access_t *anchor, const char *target, const svn_wc_diff_callbacks2_t *callbacks, void *callback_baton, svn_boolean_t recurse, svn_boolean_t ignore_ancestry, svn_boolean_t use_text_base, svn_boolean_t reverse_order, svn_cancel_func_t cancel_func, void *cancel_baton, const svn_delta_editor_t **editor, void **edit_baton, apr_pool_t *pool){ struct edit_baton *eb; svn_delta_editor_t *tree_editor; eb = make_editor_baton(anchor, target, callbacks, callback_baton, recurse, ignore_ancestry, use_text_base, reverse_order, pool); tree_editor = svn_delta_default_editor(eb->pool); tree_editor->set_target_revision = set_target_revision; tree_editor->open_root = open_root; tree_editor->delete_entry = delete_entry; tree_editor->add_directory = add_directory; tree_editor->open_directory = open_directory; tree_editor->close_directory = close_directory; tree_editor->add_file = add_file; tree_editor->open_file = open_file; tree_editor->apply_textdelta = apply_textdelta; tree_editor->change_file_prop = change_file_prop; tree_editor->change_dir_prop = change_dir_prop; tree_editor->close_file = close_file; tree_editor->close_edit = close_edit; SVN_ERR(svn_delta_get_cancellation_editor(cancel_func, cancel_baton, tree_editor, eb, editor, edit_baton, pool)); return SVN_NO_ERROR;}svn_error_t *svn_wc_get_diff_editor2(svn_wc_adm_access_t *anchor, const char *target, const svn_wc_diff_callbacks_t *callbacks, void *callback_baton, svn_boolean_t recurse, svn_boolean_t ignore_ancestry, svn_boolean_t use_text_base, svn_boolean_t reverse_order, svn_cancel_func_t cancel_func, void *cancel_baton, const svn_delta_editor_t **editor, void **edit_baton, apr_pool_t *pool){ struct callbacks_wrapper_baton *b = apr_pcalloc(pool, sizeof(*b)); b->callbacks = callbacks; b->baton = callback_baton; return svn_wc_get_diff_editor3(anchor, target, &callbacks_wrapper, b, recurse, ignore_ancestry, use_text_base, reverse_order, cancel_func, cancel_baton, editor, edit_baton, pool);}svn_error_t *svn_wc_get_diff_editor(svn_wc_adm_access_t *anchor, const char *target, const svn_wc_diff_callbacks_t *callbacks, void *callback_baton, svn_boolean_t recurse, svn_boolean_t use_text_base, svn_boolean_t reverse_order, svn_cancel_func_t cancel_func, void *cancel_baton, const svn_delta_editor_t **editor, void **edit_baton, apr_pool_t *pool){ return svn_wc_get_diff_editor2(anchor, target, callbacks, callback_baton, recurse, FALSE, use_text_base, reverse_order, cancel_func, cancel_baton, editor, edit_baton, pool);}/* Compare working copy against the text-base. */svn_error_t *svn_wc_diff3(svn_wc_adm_access_t *anchor, const char *target, const svn_wc_diff_callbacks2_t *callbacks, void *callback_baton, svn_boolean_t recurse, svn_boolean_t ignore_ancestry, apr_pool_t *pool){ struct edit_baton *eb; struct dir_baton *b; const svn_wc_entry_t *entry; const char *target_path; svn_wc_adm_access_t *adm_access; eb = make_editor_baton(anchor, target, callbacks, callback_baton, recurse, ignore_ancestry, FALSE, FALSE, pool); target_path = svn_path_join(svn_wc_adm_access_path(anchor), target, eb->pool); SVN_ERR(svn_wc_adm_probe_retrieve(&adm_access, anchor, target_path, eb->pool)); SVN_ERR(svn_wc_entry(&entry, target_path, adm_access, FALSE, eb->pool)); if (! entry) return svn_error_createf(SVN_ERR_UNVERSIONED_RESOURCE, NULL, _("'%s' is not under version control"), svn_path_local_style(target_path, pool)); if (entry->kind == svn_node_dir) b = make_dir_baton(target_path, NULL, eb, FALSE, eb->pool); else b = make_dir_baton(eb->anchor_path, NULL, eb, FALSE, eb->pool); SVN_ERR(directory_elements_diff(b)); return SVN_NO_ERROR;}svn_error_t *svn_wc_diff2(svn_wc_adm_access_t *anchor, const char *target, const svn_wc_diff_callbacks_t *callbacks, void *callback_baton, svn_boolean_t recurse, svn_boolean_t ignore_ancestry, apr_pool_t *pool){ struct callbacks_wrapper_baton *b = apr_pcalloc(pool, sizeof(*b)); b->callbacks = callbacks; b->baton = callback_baton; return svn_wc_diff3(anchor, target, &callbacks_wrapper, b, recurse, ignore_ancestry, pool);}svn_error_t *svn_wc_diff(svn_wc_adm_access_t *anchor, const char *target, const svn_wc_diff_callbacks_t *callbacks, void *callback_baton, svn_boolean_t recurse, apr_pool_t *pool){ return svn_wc_diff2(anchor, target, callbacks, callback_baton, recurse, FALSE, pool);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?