📄 dag.c
字号:
svn_fs_fs__dag_make_file(dag_node_t **child_p, dag_node_t *parent, const char *parent_path, const char *name, const char *txn_id, apr_pool_t *pool){ /* Call our little helper function */ return make_entry(child_p, parent, parent_path, name, FALSE, txn_id, pool);}svn_error_t *svn_fs_fs__dag_make_dir(dag_node_t **child_p, dag_node_t *parent, const char *parent_path, const char *name, const char *txn_id, apr_pool_t *pool){ /* Call our little helper function */ return make_entry(child_p, parent, parent_path, name, TRUE, txn_id, pool);}svn_error_t *svn_fs_fs__dag_get_contents(svn_stream_t **contents_p, dag_node_t *file, apr_pool_t *pool){ node_revision_t *noderev; svn_stream_t *contents; /* Make sure our node is a file. */ if (file->kind != svn_node_file) return svn_error_createf (SVN_ERR_FS_NOT_FILE, NULL, "Attempted to get textual contents of a *non*-file node"); /* Go get a fresh node-revision for FILE. */ SVN_ERR(get_node_revision(&noderev, file, pool)); /* Get a stream to the contents. */ SVN_ERR(svn_fs_fs__get_contents(&contents, file->fs, noderev, pool)); *contents_p = contents; return SVN_NO_ERROR;}svn_error_t *svn_fs_fs__dag_get_file_delta_stream(svn_txdelta_stream_t **stream_p, dag_node_t *source, dag_node_t *target, apr_pool_t *pool){ node_revision_t *src_noderev; node_revision_t *tgt_noderev; /* Make sure our nodes are files. */ if ((source && source->kind != svn_node_file) || target->kind != svn_node_file) return svn_error_createf (SVN_ERR_FS_NOT_FILE, NULL, "Attempted to get textual contents of a *non*-file node"); /* Go get fresh node-revisions for the nodes. */ if (source) SVN_ERR(get_node_revision(&src_noderev, source, pool)); else src_noderev = NULL; SVN_ERR(get_node_revision(&tgt_noderev, target, pool)); /* Get the delta stream. */ SVN_ERR(svn_fs_fs__get_file_delta_stream(stream_p, target->fs, src_noderev, tgt_noderev, pool)); return SVN_NO_ERROR;}svn_error_t *svn_fs_fs__dag_file_length(svn_filesize_t *length, dag_node_t *file, apr_pool_t *pool){ node_revision_t *noderev; /* Make sure our node is a file. */ if (file->kind != svn_node_file) return svn_error_createf (SVN_ERR_FS_NOT_FILE, NULL, "Attempted to get length of a *non*-file node"); /* Go get a fresh node-revision for FILE, and . */ SVN_ERR(get_node_revision(&noderev, file, pool)); SVN_ERR(svn_fs_fs__file_length(length, noderev, pool)); return SVN_NO_ERROR;}svn_error_t *svn_fs_fs__dag_file_checksum(unsigned char digest[], dag_node_t *file, apr_pool_t *pool){ node_revision_t *noderev; if (file->kind != svn_node_file) return svn_error_createf (SVN_ERR_FS_NOT_FILE, NULL, "Attempted to get checksum of a *non*-file node"); SVN_ERR(get_node_revision(&noderev, file, pool)); SVN_ERR(svn_fs_fs__file_checksum(digest, noderev, pool)); return SVN_NO_ERROR;}svn_error_t *svn_fs_fs__dag_get_edit_stream(svn_stream_t **contents, dag_node_t *file, const char *txn_id, apr_pool_t *pool){ node_revision_t *noderev; svn_stream_t *ws; /* Make sure our node is a file. */ if (file->kind != svn_node_file) return svn_error_createf (SVN_ERR_FS_NOT_FILE, NULL, "Attempted to set textual contents of a *non*-file node"); /* Make sure our node is mutable. */ if (! svn_fs_fs__dag_check_mutable(file, txn_id)) return svn_error_createf (SVN_ERR_FS_NOT_MUTABLE, NULL, "Attempted to set textual contents of an immutable node"); /* Get the node revision. */ SVN_ERR(get_node_revision(&noderev, file, pool)); SVN_ERR(svn_fs_fs__set_contents(&ws, file->fs, noderev, pool)); *contents = ws; return SVN_NO_ERROR;}svn_error_t *svn_fs_fs__dag_finalize_edits(dag_node_t *file, const char *checksum, const char *txn_id, apr_pool_t *pool){ unsigned char digest[APR_MD5_DIGESTSIZE]; const char *hex; if (checksum) { SVN_ERR(svn_fs_fs__dag_file_checksum(digest, file, pool)); hex = svn_md5_digest_to_cstring(digest, pool); if (hex && strcmp(checksum, hex) != 0) return svn_error_createf(SVN_ERR_CHECKSUM_MISMATCH, NULL, _("Checksum mismatch, file '%s':\n" " expected: %s\n" " actual: %s\n"), file->created_path, checksum, hex); } return SVN_NO_ERROR;}dag_node_t *svn_fs_fs__dag_dup(dag_node_t *node, apr_pool_t *pool){ /* Allocate our new node. */ dag_node_t *new_node = apr_pcalloc(pool, sizeof(*new_node)); new_node->fs = node->fs; new_node->pool = pool; new_node->id = svn_fs_fs__id_copy(node->id, pool); new_node->kind = node->kind; new_node->created_path = apr_pstrdup(pool, node->created_path); /* Leave new_node->node_revision zero for now, so it'll get read in. We can get fancy and duplicate node's cache later. */ return new_node;}svn_error_t *svn_fs_fs__dag_open(dag_node_t **child_p, dag_node_t *parent, const char *name, apr_pool_t *pool){ const svn_fs_id_t *node_id; /* Ensure that NAME exists in PARENT's entry list. */ SVN_ERR(dir_entry_id_from_node(&node_id, parent, name, pool)); if (! node_id) return svn_error_createf (SVN_ERR_FS_NOT_FOUND, NULL, "Attempted to open non-existent child node '%s'", name); /* Make sure that NAME is a single path component. */ if (! svn_path_is_single_path_component(name)) return svn_error_createf (SVN_ERR_FS_NOT_SINGLE_PATH_COMPONENT, NULL, "Attempted to open node with an illegal name '%s'", name); /* Now get the node that was requested. */ return svn_fs_fs__dag_get_node(child_p, svn_fs_fs__dag_get_fs(parent), node_id, pool);}svn_error_t *svn_fs_fs__dag_copy(dag_node_t *to_node, const char *entry, dag_node_t *from_node, svn_boolean_t preserve_history, svn_revnum_t from_rev, const char *from_path, const char *txn_id, apr_pool_t *pool){ const svn_fs_id_t *id; if (preserve_history) { node_revision_t *from_noderev, *to_noderev; const char *copy_id; const svn_fs_id_t *src_id = svn_fs_fs__dag_get_id(from_node); svn_fs_t *fs = svn_fs_fs__dag_get_fs(from_node); /* Make a copy of the original node revision. */ SVN_ERR(get_node_revision(&from_noderev, from_node, pool)); to_noderev = copy_node_revision(from_noderev, pool); /* Reserve a copy ID for this new copy. */ SVN_ERR(svn_fs_fs__reserve_copy_id(©_id, fs, txn_id, pool)); /* Create a successor with its predecessor pointing at the copy source. */ to_noderev->predecessor_id = svn_fs_fs__id_copy(src_id, pool); if (to_noderev->predecessor_count != -1) to_noderev->predecessor_count++; to_noderev->created_path = svn_path_join(svn_fs_fs__dag_get_created_path(to_node), entry, pool); to_noderev->copyfrom_path = apr_pstrdup(pool, from_path); to_noderev->copyfrom_rev = from_rev; /* Set the copyroot equal to our own id. */ to_noderev->copyroot_path = NULL; SVN_ERR(svn_fs_fs__create_successor(&id, fs, src_id, to_noderev, copy_id, txn_id, pool)); } else /* don't preserve history */ { id = svn_fs_fs__dag_get_id(from_node); } /* Set the entry in to_node to the new id. */ SVN_ERR(svn_fs_fs__dag_set_entry(to_node, entry, id, from_node->kind, txn_id, pool)); return SVN_NO_ERROR;}/*** Comparison. ***/svn_error_t *svn_fs_fs__things_different(svn_boolean_t *props_changed, svn_boolean_t *contents_changed, dag_node_t *node1, dag_node_t *node2, apr_pool_t *pool){ node_revision_t *noderev1, *noderev2; /* If we have no place to store our results, don't bother doing anything. */ if (! props_changed && ! contents_changed) return SVN_NO_ERROR; /* The node revision skels for these two nodes. */ SVN_ERR(get_node_revision(&noderev1, node1, pool)); SVN_ERR(get_node_revision(&noderev2, node2, pool)); /* Compare property keys. */ if (props_changed != NULL) *props_changed = (! svn_fs_fs__noderev_same_rep_key(noderev1->prop_rep, noderev2->prop_rep)); /* Compare contents keys. */ if (contents_changed != NULL) *contents_changed = (! svn_fs_fs__noderev_same_rep_key(noderev1->data_rep, noderev2->data_rep)); return SVN_NO_ERROR;}svn_error_t *svn_fs_fs__dag_get_copyroot(svn_revnum_t *rev, const char **path, dag_node_t *node, apr_pool_t *pool){ node_revision_t *noderev; /* Go get a fresh node-revision for FILE. */ SVN_ERR(get_node_revision(&noderev, node, pool)); *rev = noderev->copyroot_rev; *path = noderev->copyroot_path; return SVN_NO_ERROR;}svn_error_t *svn_fs_fs__dag_get_copyfrom_rev(svn_revnum_t *rev, dag_node_t *node, apr_pool_t *pool){ node_revision_t *noderev; /* Go get a fresh node-revision for FILE. */ SVN_ERR(get_node_revision(&noderev, node, pool)); *rev = noderev->copyfrom_rev; return SVN_NO_ERROR;}svn_error_t *svn_fs_fs__dag_get_copyfrom_path(const char **path, dag_node_t *node, apr_pool_t *pool){ node_revision_t *noderev; /* Go get a fresh node-revision for FILE. */ SVN_ERR(get_node_revision(&noderev, node, pool)); *path = noderev->copyfrom_path; return SVN_NO_ERROR;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -