📄 entries.c
字号:
for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi)) { const void *key; const char *name; void *val; svn_wc_entry_t *this_entry; /* Get the entry */ apr_hash_this(hi, &key, NULL, &val); this_entry = val; name = key; /* We've already checked the "this dir" entry */ if (! strcmp(name, SVN_WC_ENTRY_THIS_DIR )) continue; /* Validate THIS_ENTRY's current schedule. */ switch (this_entry->schedule) { case svn_wc_schedule_normal: case svn_wc_schedule_add: case svn_wc_schedule_delete: case svn_wc_schedule_replace: /* These are all valid states */ break; default: /* This is an invalid state */ return svn_error_createf (SVN_ERR_WC_CORRUPT, NULL, _("Corrupt working copy: " "'%s' in directory '%s' has an invalid schedule"), name, svn_path_local_style(path, pool)); } if ((default_entry->schedule == svn_wc_schedule_add) && (this_entry->schedule != svn_wc_schedule_add)) return svn_error_createf (SVN_ERR_WC_CORRUPT, NULL, _("Corrupt working copy: '%s' in directory '%s' (which is " "scheduled for addition) is not itself scheduled for addition"), name, svn_path_local_style(path, pool)); if ((default_entry->schedule == svn_wc_schedule_delete) && (this_entry->schedule != svn_wc_schedule_delete)) return svn_error_createf (SVN_ERR_WC_CORRUPT, NULL, _("Corrupt working copy: '%s' in directory '%s' (which is " "scheduled for deletion) is not itself scheduled for deletion"), name, svn_path_local_style(path, pool)); if ((default_entry->schedule == svn_wc_schedule_replace) && (this_entry->schedule == svn_wc_schedule_normal)) return svn_error_createf (SVN_ERR_WC_CORRUPT, NULL, _("Corrupt working copy: '%s' in directory '%s' (which is " "scheduled for replacement) has an invalid schedule"), name, svn_path_local_style(path, pool)); } return SVN_NO_ERROR;}#endif /* 0 */svn_error_t *svn_wc_entries_read(apr_hash_t **entries, svn_wc_adm_access_t *adm_access, svn_boolean_t show_hidden, apr_pool_t *pool){ apr_hash_t *new_entries; new_entries = svn_wc__adm_access_entries(adm_access, show_hidden, pool); if (! new_entries) { /* Ask for the deleted entries because most operations request them at some stage, getting them now avoids a second file parse. */ SVN_ERR(read_entries(adm_access, TRUE, pool)); new_entries = svn_wc__adm_access_entries(adm_access, show_hidden, pool); } *entries = new_entries; return SVN_NO_ERROR;}/* Append STR to BUF, terminating it with a newline. Escape bytes that needs escaping. Use POOL for temporary allocations. */static voidwrite_str(svn_stringbuf_t *buf, const char *str, apr_pool_t *pool){ const char *start = str; if (str) { while (*str) { /* Escape control characters and | and \. */ if (svn_ctype_iscntrl(*str) || *str == '\\') { svn_stringbuf_appendbytes(buf, start, str - start); svn_stringbuf_appendcstr(buf, apr_psprintf(pool, "\\x%02x", *str)); start = str + 1; } ++str; } svn_stringbuf_appendbytes(buf, start, str - start); } svn_stringbuf_appendbytes(buf, "\n", 1);}/* Append the string VAL of length LEN to BUF, without escaping any bytes. */static voidwrite_val(svn_stringbuf_t *buf, const char *val, apr_size_t len){ if (val) svn_stringbuf_appendbytes(buf, val, len); svn_stringbuf_appendbytes(buf, "\n", 1);}/* If VAL is true, append FIELD_NAME followede by a terminator to BUF. Else, just append the terminator. */static voidwrite_bool(svn_stringbuf_t *buf, const char *field_name, svn_boolean_t val){ write_val(buf, val ? field_name : NULL, val ? strlen(field_name) : 0);}/* Append the representation of REVNUM to BUF and a terminator, using POOL for temporary allocations. */static voidwrite_revnum(svn_stringbuf_t *buf, svn_revnum_t revnum, apr_pool_t *pool){ if (SVN_IS_VALID_REVNUM(revnum)) svn_stringbuf_appendcstr(buf, apr_ltoa(pool, revnum)); svn_stringbuf_appendbytes(buf, "\n", 1);}/* Append the timestamp VAL to BUF (or the empty string if VAL is 0), followed by a terminator. Use POOL for temporary allocations. */static voidwrite_time(svn_stringbuf_t *buf, apr_time_t val, apr_pool_t *pool){ if (val) svn_stringbuf_appendcstr(buf, svn_time_to_cstring(val, pool)); svn_stringbuf_appendbytes(buf, "\n", 1);}/* Append a single entry ENTRY to the string OUTPUT, using the entry for "this dir" THIS_DIR for comparison/optimization. Allocations are done in POOL. */static voidwrite_entry(svn_stringbuf_t *buf, svn_wc_entry_t *entry, const char *name, svn_wc_entry_t *this_dir, apr_pool_t *pool){ const char *valuestr; svn_revnum_t valuerev; svn_boolean_t is_this_dir = strcmp(name, SVN_WC_ENTRY_THIS_DIR) == 0; svn_boolean_t is_subdir = ! is_this_dir && (entry->kind == svn_node_dir); assert(name); /* Name. */ write_str(buf, name, pool); /* Kind. */ switch (entry->kind) { case svn_node_dir: write_val(buf, SVN_WC__ENTRIES_ATTR_DIR_STR, sizeof(SVN_WC__ENTRIES_ATTR_DIR_STR) - 1); break; case svn_node_none: write_val(buf, NULL, 0); break; case svn_node_file: case svn_node_unknown: default: write_val(buf, SVN_WC__ENTRIES_ATTR_FILE_STR, sizeof(SVN_WC__ENTRIES_ATTR_FILE_STR) - 1); break; } /* Revision. */ if (is_this_dir || (! is_subdir && entry->revision != this_dir->revision)) valuerev = entry->revision; else valuerev = SVN_INVALID_REVNUM; write_revnum(buf, valuerev, pool); /* URL. */ if (is_this_dir || (! is_subdir && strcmp(svn_path_url_add_component(this_dir->url, name, pool), entry->url) != 0)) valuestr = entry->url; else valuestr = NULL; write_str(buf, valuestr, pool); /* Repository root. */ if (! is_subdir && (is_this_dir || (this_dir->repos == NULL || (entry->repos && strcmp(this_dir->repos, entry->repos) != 0)))) valuestr = entry->repos; else valuestr = NULL; write_str(buf, valuestr, pool); /* Schedule. */ switch (entry->schedule) { case svn_wc_schedule_add: write_val(buf, SVN_WC__ENTRY_VALUE_ADD, sizeof(SVN_WC__ENTRY_VALUE_ADD) - 1); break; case svn_wc_schedule_delete: write_val(buf, SVN_WC__ENTRY_VALUE_DELETE, sizeof(SVN_WC__ENTRY_VALUE_DELETE) - 1); break; case svn_wc_schedule_replace: write_val(buf, SVN_WC__ENTRY_VALUE_REPLACE, sizeof(SVN_WC__ENTRY_VALUE_REPLACE) - 1); break; case svn_wc_schedule_normal: default: write_val(buf, NULL, 0); break; } /* Text time. */ write_time(buf, entry->text_time, pool); /* Checksum. */ write_val(buf, entry->checksum, entry->checksum ? strlen(entry->checksum) : 0); /* Last-commit stuff */ write_time(buf, entry->cmt_date, pool); write_revnum(buf, entry->cmt_rev, pool); write_str(buf, entry->cmt_author, pool); /* has-props flag. */ write_bool(buf, SVN_WC__ENTRY_ATTR_HAS_PROPS, entry->has_props); /* has-prop-mods flag. */ write_bool(buf, SVN_WC__ENTRY_ATTR_HAS_PROP_MODS, entry->has_prop_mods); /* cachable-props string. */ if (is_this_dir || ! this_dir->cachable_props || ! entry->cachable_props || strcmp(this_dir->cachable_props, entry->cachable_props) != 0) valuestr = entry->cachable_props; else valuestr = NULL; write_val(buf, valuestr, valuestr ? strlen(valuestr) : 0); /* present-props string. */ write_val(buf, entry->present_props, entry->present_props ? strlen(entry->present_props) : 0); /* Conflict. */ write_str(buf, entry->prejfile, pool); write_str(buf, entry->conflict_old, pool); write_str(buf, entry->conflict_new, pool); write_str(buf, entry->conflict_wrk, pool); write_bool(buf, SVN_WC__ENTRY_ATTR_COPIED, entry->copied); /* Copy-related Stuff */ write_str(buf, entry->copyfrom_url, pool); write_revnum(buf, entry->copyfrom_rev, pool); /* Deleted state */ write_bool(buf, SVN_WC__ENTRY_ATTR_DELETED, entry->deleted); /* Absent state */ write_bool(buf, SVN_WC__ENTRY_ATTR_ABSENT, entry->absent); /* Incomplete state */ write_bool(buf, SVN_WC__ENTRY_ATTR_INCOMPLETE, entry->incomplete); /* UUID. */ if (is_this_dir || ! this_dir->uuid || ! entry->uuid || strcmp(this_dir->uuid, entry->uuid) != 0) valuestr = entry->uuid; else valuestr = NULL; write_val(buf, valuestr, valuestr ? strlen(valuestr) : 0); /* Lock token. */ write_str(buf, entry->lock_token, pool); /* Lock owner. */ write_str(buf, entry->lock_owner, pool); /* Lock comment. */ write_str(buf, entry->lock_comment, pool); /* Lock creation date. */ write_time(buf, entry->lock_creation_date, pool); /* Remove redundant separators at the end of the entry. */ while (buf->len > 1 && buf->data[buf->len - 2] == '\n') buf->len--; svn_stringbuf_appendbytes(buf, "\f\n", 2);}/* Append a single entry ENTRY as an XML element to the string OUTPUT, using the entry for "this dir" THIS_DIR for comparison/optimization. Allocations are done in POOL. */static voidwrite_entry_xml(svn_stringbuf_t **output, svn_wc_entry_t *entry, const char *name, svn_wc_entry_t *this_dir, apr_pool_t *pool){ apr_hash_t *atts = apr_hash_make(pool); const char *valuestr; /*** Create a hash that represents an entry. ***/ assert(name); /* Name */ apr_hash_set(atts, SVN_WC__ENTRY_ATTR_NAME, APR_HASH_KEY_STRING, entry->name); /* Revision */ if (SVN_IS_VALID_REVNUM(entry->revision)) apr_hash_set(atts, SVN_WC__ENTRY_ATTR_REVISION, APR_HASH_KEY_STRING, apr_psprintf(pool, "%ld", entry->revision)); /* URL */ if (entry->url) apr_hash_set(atts, SVN_WC__ENTRY_ATTR_URL, APR_HASH_KEY_STRING, entry->url); /* Repository root */ if (entry->repos) apr_hash_set(atts, SVN_WC__ENTRY_ATTR_REPOS, APR_HASH_KEY_STRING, entry->repos); /* Kind */ switch (entry->kind) { case svn_node_dir: valuestr = SVN_WC__ENTRIES_ATTR_DIR_STR; break; case svn_node_none: valuestr = NULL; break; case svn_node_file: case svn_node_unknown: default: valuestr = SVN_WC__ENTRIES_ATTR_FILE_STR; break; } apr_hash_set(atts, SVN_WC__ENTRY_ATTR_KIND, APR_HASH_KEY_STRING, valuestr); /* Schedule */ switch (entry->schedule) { case svn_wc_schedule_add: valuestr = SVN_WC__ENTRY_VALUE_ADD; break; case svn_wc_schedule_delete: valuestr = SVN_WC__ENTRY_VALUE_DELETE; break; case svn_wc_schedule_replace: valuestr = SVN_WC__ENTRY_VALUE_REPLACE; break; case svn_wc_schedule_normal: default: valuestr = NULL; break; } apr_hash_set(atts, SVN_WC__ENTRY_ATTR_SCHEDULE, APR_HASH_KEY_STRING, valuestr); /* Conflicts */ if (entry->conflict_old) apr_hash_set(atts, SVN_WC__ENTRY_ATTR_CONFLICT_OLD, APR_HASH_KEY_STRING, entry->conflict_old);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -