svn_error_t * svn_fs_fs__dag_increment_mergeinfo_count(dag_node_t *node, apr_int64_t increment, apr_pool_t *pool) { node_revision_t *noderev; /* Sanity check: this node better be mutable! */ if (! svn_fs_fs__dag_check_mutable(node)) { svn_string_t *idstr = svn_fs_fs__id_unparse(node->id, pool); return svn_error_createf (SVN_ERR_FS_NOT_MUTABLE, NULL, "Can't increment mergeinfo count on *immutable* node-revision %s", idstr->data); } if (increment == 0) return SVN_NO_ERROR; /* Go get a fresh NODE-REVISION for this node. */ SVN_ERR(get_node_revision(&noderev, node, pool)); noderev->mergeinfo_count += increment; if (noderev->mergeinfo_count < 0) { svn_string_t *idstr = svn_fs_fs__id_unparse(node->id, pool); return svn_error_createf (SVN_ERR_FS_CORRUPT, NULL, apr_psprintf(pool, _("Can't increment mergeinfo count on node-revision %%s " "to negative value %%%s"), APR_INT64_T_FMT), idstr->data, noderev->mergeinfo_count); } if (noderev->mergeinfo_count > 1 && noderev->kind == svn_node_file) { svn_string_t *idstr = svn_fs_fs__id_unparse(node->id, pool); return svn_error_createf (SVN_ERR_FS_CORRUPT, NULL, apr_psprintf(pool, _("Can't increment mergeinfo count on *file* " "node-revision %%s to %%%s (> 1)"), APR_INT64_T_FMT), idstr->data, noderev->mergeinfo_count); } /* Flush it out. */ return svn_fs_fs__put_node_revision(node->fs, noderev->id, noderev, FALSE, pool); }
/* Wrap svn_fs_fs__parse_representation(), extracting its TXN_ID from our NODEREV_ID, and adding an error message. */ static svn_error_t * read_rep_offsets(representation_t **rep_p, char *string, const svn_fs_id_t *noderev_id, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { svn_error_t *err = svn_fs_fs__parse_representation(rep_p, svn_stringbuf_create_wrap(string, scratch_pool), result_pool, scratch_pool); if (err) { const svn_string_t *id_unparsed; const char *where; id_unparsed = svn_fs_fs__id_unparse(noderev_id, scratch_pool); where = apr_psprintf(scratch_pool, _("While reading representation offsets " "for node-revision '%s':"), noderev_id ? id_unparsed->data : "(null)"); return svn_error_quick_wrap(err, where); } if ((*rep_p)->revision == SVN_INVALID_REVNUM) if (noderev_id) (*rep_p)->txn_id = *svn_fs_fs__id_txn_id(noderev_id); return SVN_NO_ERROR; }
svn_error_t * svn_fs_fs__dag_set_has_mergeinfo(dag_node_t *node, svn_boolean_t has_mergeinfo, apr_pool_t *pool) { node_revision_t *noderev; /* Sanity check: this node better be mutable! */ if (! svn_fs_fs__dag_check_mutable(node)) { svn_string_t *idstr = svn_fs_fs__id_unparse(node->id, pool); return svn_error_createf (SVN_ERR_FS_NOT_MUTABLE, NULL, "Can't set mergeinfo flag on *immutable* node-revision %s", idstr->data); } /* Go get a fresh NODE-REVISION for this node. */ SVN_ERR(get_node_revision(&noderev, node, pool)); noderev->has_mergeinfo = has_mergeinfo; /* Flush it out. */ return svn_fs_fs__put_node_revision(node->fs, noderev->id, noderev, FALSE, pool); }
svn_error_t * svn_fs_fs__dag_serialize(char **data, apr_size_t *data_len, void *in, apr_pool_t *pool) { dag_node_t *node = in; svn_stringbuf_t *buf = svn_stringbuf_create("", pool); if (svn_fs_fs__dag_check_mutable(node)) { svn_stringbuf_appendcstr(buf, "M"); svn_stringbuf_appendcstr(buf, (node->kind == svn_node_file ? "F" : "D")); svn_stringbuf_appendcstr(buf, svn_fs_fs__id_unparse(node->id, pool)->data); svn_stringbuf_appendcstr(buf, "\n"); svn_stringbuf_appendcstr(buf, node->created_path); } else { fs_fs_data_t *ffd = node->fs->fsap_data; svn_stringbuf_appendcstr(buf, "I"); SVN_ERR(svn_fs_fs__write_noderev(svn_stream_from_stringbuf(buf, pool), node->node_revision, ffd->format, TRUE, pool)); } *data = buf->data; *data_len = buf->len; return SVN_NO_ERROR; }
svn_error_t * svn_fs_fs__err_dangling_id(svn_fs_t *fs, const svn_fs_id_t *id) { svn_string_t *id_str = svn_fs_fs__id_unparse(id, fs->pool); return svn_error_createf (SVN_ERR_FS_ID_NOT_FOUND, 0, _("Reference to non-existent node '%s' in filesystem '%s'"), id_str->data, fs->path); }
/* Implements svn_cache__serialize_func_t */ static svn_error_t * serialize_id(char **data, apr_size_t *data_len, void *in, apr_pool_t *pool) { svn_fs_id_t *id = in; svn_string_t *id_str = svn_fs_fs__id_unparse(id, pool); *data = (char *) id_str->data; *data_len = id_str->len; return SVN_NO_ERROR; }
svn_error_t * svn_fs_fs__dag_set_proplist(dag_node_t *node, apr_hash_t *proplist, apr_pool_t *pool) { node_revision_t *noderev; /* Sanity check: this node better be mutable! */ if (! svn_fs_fs__dag_check_mutable(node)) { svn_string_t *idstr = svn_fs_fs__id_unparse(node->id, pool); return svn_error_createf (SVN_ERR_FS_NOT_MUTABLE, NULL, "Can't set proplist on *immutable* node-revision %s", idstr->data); } /* Go get a fresh NODE-REVISION for this node. */ SVN_ERR(get_node_revision(&noderev, node, pool)); /* Set the new proplist. */ return svn_fs_fs__set_proplist(node->fs, noderev, proplist, pool); }
/* Write a single change entry, path PATH, change CHANGE, to STREAM. Only include the node kind field if INCLUDE_NODE_KIND is true. Only include the mergeinfo-mod field if INCLUDE_MERGEINFO_MODS is true. All temporary allocations are in SCRATCH_POOL. */ static svn_error_t * write_change_entry(svn_stream_t *stream, const char *path, svn_fs_path_change2_t *change, svn_boolean_t include_node_kind, svn_boolean_t include_mergeinfo_mods, apr_pool_t *scratch_pool) { const char *idstr; const char *change_string = NULL; const char *kind_string = ""; const char *mergeinfo_string = ""; svn_stringbuf_t *buf; apr_size_t len; switch (change->change_kind) { case svn_fs_path_change_modify: change_string = ACTION_MODIFY; break; case svn_fs_path_change_add: change_string = ACTION_ADD; break; case svn_fs_path_change_delete: change_string = ACTION_DELETE; break; case svn_fs_path_change_replace: change_string = ACTION_REPLACE; break; case svn_fs_path_change_reset: change_string = ACTION_RESET; break; default: return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL, _("Invalid change type %d"), change->change_kind); } if (change->node_rev_id) idstr = svn_fs_fs__id_unparse(change->node_rev_id, scratch_pool)->data; else idstr = ACTION_RESET; if (include_node_kind) { SVN_ERR_ASSERT(change->node_kind == svn_node_dir || change->node_kind == svn_node_file); kind_string = apr_psprintf(scratch_pool, "-%s", change->node_kind == svn_node_dir ? SVN_FS_FS__KIND_DIR : SVN_FS_FS__KIND_FILE); } if (include_mergeinfo_mods && change->mergeinfo_mod != svn_tristate_unknown) mergeinfo_string = apr_psprintf(scratch_pool, " %s", change->mergeinfo_mod == svn_tristate_true ? FLAG_TRUE : FLAG_FALSE); buf = svn_stringbuf_createf(scratch_pool, "%s %s%s %s %s%s %s\n", idstr, change_string, kind_string, change->text_mod ? FLAG_TRUE : FLAG_FALSE, change->prop_mod ? FLAG_TRUE : FLAG_FALSE, mergeinfo_string, path); if (SVN_IS_VALID_REVNUM(change->copyfrom_rev)) { svn_stringbuf_appendcstr(buf, apr_psprintf(scratch_pool, "%ld %s", change->copyfrom_rev, change->copyfrom_path)); } svn_stringbuf_appendbyte(buf, '\n'); /* Write all change info in one write call. */ len = buf->len; return svn_error_trace(svn_stream_write(stream, buf->data, &len)); }
svn_error_t * svn_fs_fs__write_noderev(svn_stream_t *outfile, node_revision_t *noderev, int format, svn_boolean_t include_mergeinfo, apr_pool_t *scratch_pool) { SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_ID ": %s\n", svn_fs_fs__id_unparse(noderev->id, scratch_pool)->data)); SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_TYPE ": %s\n", (noderev->kind == svn_node_file) ? SVN_FS_FS__KIND_FILE : SVN_FS_FS__KIND_DIR)); if (noderev->predecessor_id) SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_PRED ": %s\n", svn_fs_fs__id_unparse(noderev->predecessor_id, scratch_pool)->data)); SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_COUNT ": %d\n", noderev->predecessor_count)); if (noderev->data_rep) SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_TEXT ": %s\n", svn_fs_fs__unparse_representation (noderev->data_rep, format, noderev->kind == svn_node_dir, scratch_pool, scratch_pool)->data)); if (noderev->prop_rep) SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_PROPS ": %s\n", svn_fs_fs__unparse_representation (noderev->prop_rep, format, TRUE, scratch_pool, scratch_pool)->data)); SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_CPATH ": %s\n", noderev->created_path)); if (noderev->copyfrom_path) SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_COPYFROM ": %ld" " %s\n", noderev->copyfrom_rev, noderev->copyfrom_path)); if ((noderev->copyroot_rev != svn_fs_fs__id_rev(noderev->id)) || (strcmp(noderev->copyroot_path, noderev->created_path) != 0)) SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_COPYROOT ": %ld" " %s\n", noderev->copyroot_rev, noderev->copyroot_path)); if (noderev->is_fresh_txn_root) SVN_ERR(svn_stream_puts(outfile, HEADER_FRESHTXNRT ": y\n")); if (include_mergeinfo) { if (noderev->mergeinfo_count > 0) SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_MINFO_CNT ": %" APR_INT64_T_FMT "\n", noderev->mergeinfo_count)); if (noderev->has_mergeinfo) SVN_ERR(svn_stream_puts(outfile, HEADER_MINFO_HERE ": y\n")); } return svn_stream_puts(outfile, "\n"); }