📄 questions.c
字号:
if (verify_checksum) { /* Need checksum verification, so read checksum from entries file * and setup checksummed stream for base file. */ SVN_ERR(svn_wc_entry(&entry, versioned_file, adm_access, TRUE, pool)); if (! entry) return svn_error_createf (SVN_ERR_UNVERSIONED_RESOURCE, NULL, _("'%s' is not under version control"), svn_path_local_style(versioned_file, pool)); if (entry->checksum) b_stream = svn_stream_checksummed(b_stream, &digest, NULL, TRUE, pool); } if (compare_textbases && need_translation) { /* Create stream for detranslate versioned file to normal form. */ SVN_ERR(svn_subst_stream_detranslated(&v_stream, versioned_file, eol_style, eol_str, TRUE, keywords, special, pool)); } else { SVN_ERR(svn_io_file_open(&v_file_h, versioned_file, APR_READ, APR_OS_DEFAULT, pool)); v_stream = svn_stream_from_aprfile2(v_file_h, FALSE, pool); if (need_translation) { /* Translate text-base to working copy form. */ b_stream = svn_subst_stream_translated(b_stream, eol_str, FALSE, keywords, TRUE, pool); } } SVN_ERR(svn_stream_contents_same(&same, b_stream, v_stream, pool)); SVN_ERR(svn_stream_close(v_stream)); SVN_ERR(svn_stream_close(b_stream)); if (verify_checksum && entry->checksum) { const char *checksum; checksum = svn_md5_digest_to_cstring_display(digest, pool); if (strcmp(checksum, entry->checksum) != 0) { return svn_error_createf (SVN_ERR_WC_CORRUPT_TEXT_BASE, NULL, _("Checksum mismatch indicates corrupt text base: '%s'\n" " expected: %s\n" " actual: %s\n"), svn_path_local_style(base_file, pool), entry->checksum, checksum); } } } else { /* Translation would be a no-op, so compare the original file. */ SVN_ERR(svn_io_files_contents_same_p(&same, base_file, versioned_file, pool)); } *modified_p = (! same); return SVN_NO_ERROR;}svn_error_t *svn_wc__versioned_file_modcheck(svn_boolean_t *modified_p, const char *versioned_file, svn_wc_adm_access_t *adm_access, const char *base_file, svn_boolean_t compare_textbases, apr_pool_t *pool){ return compare_and_verify(modified_p, versioned_file, adm_access, base_file, compare_textbases, FALSE, pool);}svn_error_t *svn_wc__text_modified_internal_p(svn_boolean_t *modified_p, const char *filename, svn_boolean_t force_comparison, svn_wc_adm_access_t *adm_access, svn_boolean_t compare_textbases, apr_pool_t *pool){ const char *textbase_filename; svn_boolean_t equal_timestamps; apr_pool_t *subpool = svn_pool_create(pool); svn_node_kind_t kind; svn_error_t *err; if (! force_comparison) { /* See if the local file's timestamp is the same as the one recorded in the administrative directory. This could, theoretically, be wrong in certain rare cases, but with the addition of a forced delay after commits (see revision 419 and issue #542) it's highly unlikely to be a problem. */ err = svn_wc__timestamps_equal_p(&equal_timestamps, filename, adm_access, svn_wc__text_time, subpool); /* We only care whether there was an error or not, so make sure it is cleared. */ svn_error_clear(err); /* If we have an error, we fall back on the slower code path below. It might be tempting to optimize this further, for example by detecting when the file didn't exists. But we have to be careful with what error codes we return. If the file doesn't exist, we should return no error. But, *if* it exists, but it is unversioned, we have to return SVN_ERR_ENTRY_NOT_FOUND. */ if (! err && equal_timestamps) { *modified_p = FALSE; goto cleanup; } } /* Make sure the file exists before proceeding. */ SVN_ERR(svn_io_check_path(filename, &kind, pool)); if (kind != svn_node_file) { /* If the file doesn't exist, consider it non-modified. */ *modified_p = FALSE; goto cleanup; } /* If there's no text-base file, we have to assume the working file is modified. For example, a file scheduled for addition but not yet committed. */ textbase_filename = svn_wc__text_base_path(filename, 0, subpool); SVN_ERR(svn_io_check_path(textbase_filename, &kind, subpool)); if (kind != svn_node_file) { *modified_p = TRUE; goto cleanup; } /* Check all bytes, and verify checksum if requested. */ SVN_ERR(compare_and_verify(modified_p, filename, adm_access, textbase_filename, compare_textbases, force_comparison, subpool)); /* It is quite legitimate for modifications to the working copy to produce a timestamp variation with no text variation. If it turns out that there are no differences then we might be able to "repair" the text-time in the entries file and so avoid the expensive file contents comparison in the future. */ if (! *modified_p && svn_wc_adm_locked(adm_access)) { svn_wc_entry_t tmp; SVN_ERR(svn_io_file_affected_time(&tmp.text_time, filename, pool)); SVN_ERR(svn_wc__entry_modify(adm_access, svn_path_basename(filename, pool), &tmp, SVN_WC__ENTRY_MODIFY_TEXT_TIME, TRUE, pool)); } cleanup: svn_pool_destroy(subpool); return SVN_NO_ERROR;}svn_error_t *svn_wc_text_modified_p(svn_boolean_t *modified_p, const char *filename, svn_boolean_t force_comparison, svn_wc_adm_access_t *adm_access, apr_pool_t *pool){ return svn_wc__text_modified_internal_p(modified_p, filename, force_comparison, adm_access, TRUE, pool);}svn_error_t *svn_wc_conflicted_p(svn_boolean_t *text_conflicted_p, svn_boolean_t *prop_conflicted_p, const char *dir_path, const svn_wc_entry_t *entry, apr_pool_t *pool){ const char *path; svn_node_kind_t kind; apr_pool_t *subpool = svn_pool_create(pool); /* ### Why? */ *text_conflicted_p = FALSE; *prop_conflicted_p = FALSE; /* Look for any text conflict, exercising only as much effort as necessary to obtain a definitive answer. This only applies to files, but we don't have to explicitly check that entry is a file, since these attributes would never be set on a directory anyway. A conflict file entry notation only counts if the conflict file still exists on disk. */ if (entry->conflict_old) { path = svn_path_join(dir_path, entry->conflict_old, subpool); SVN_ERR(svn_io_check_path(path, &kind, subpool)); if (kind == svn_node_file) *text_conflicted_p = TRUE; } if ((! *text_conflicted_p) && (entry->conflict_new)) { path = svn_path_join(dir_path, entry->conflict_new, subpool); SVN_ERR(svn_io_check_path(path, &kind, subpool)); if (kind == svn_node_file) *text_conflicted_p = TRUE; } if ((! *text_conflicted_p) && (entry->conflict_wrk)) { path = svn_path_join(dir_path, entry->conflict_wrk, subpool); SVN_ERR(svn_io_check_path(path, &kind, subpool)); if (kind == svn_node_file) *text_conflicted_p = TRUE; } /* What about prop conflicts? */ if (entry->prejfile) { path = svn_path_join(dir_path, entry->prejfile, subpool); SVN_ERR(svn_io_check_path(path, &kind, subpool)); if (kind == svn_node_file) *prop_conflicted_p = TRUE; } svn_pool_destroy(subpool); return SVN_NO_ERROR;}svn_error_t *svn_wc_has_binary_prop(svn_boolean_t *has_binary_prop, const char *path, svn_wc_adm_access_t *adm_access, apr_pool_t *pool){ const svn_string_t *value; apr_pool_t *subpool = svn_pool_create(pool); SVN_ERR(svn_wc_prop_get(&value, SVN_PROP_MIME_TYPE, path, adm_access, subpool)); if (value && (svn_mime_type_is_binary(value->data))) *has_binary_prop = TRUE; else *has_binary_prop = FALSE; svn_pool_destroy(subpool); return SVN_NO_ERROR;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -