You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2015/01/02 13:43:43 UTC
svn commit: r1649012 [2/3] - in /subversion/trunk: ./ subversion/libsvn_fs_x/
Modified: subversion/trunk/subversion/libsvn_fs_x/id.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/id.h?rev=1649012&r1=1649011&r2=1649012&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/id.h (original)
+++ subversion/trunk/subversion/libsvn_fs_x/id.h Fri Jan 2 12:43:42 2015
@@ -1,4 +1,4 @@
-/* id.h : interface to node ID functions, private to libsvn_fs_x
+/* id.h : interface to FSX-internal ID functions
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@@ -57,137 +57,65 @@ svn_revnum_t svn_fs_x__get_revnum(svn_fs
/* Return the transaction ID that corresponds to CHANGE_SET.
Will SVN_FS_X__INVALID_TXN_ID for revisions. */
-apr_int64_t svn_fs_x__get_txn_id(svn_fs_x__change_set_t change_set);
+svn_fs_x__txn_id_t svn_fs_x__get_txn_id(svn_fs_x__change_set_t change_set);
/* Convert REVNUM into a change set number */
svn_fs_x__change_set_t svn_fs_x__change_set_by_rev(svn_revnum_t revnum);
/* Convert TXN_ID into a change set number */
-svn_fs_x__change_set_t svn_fs_x__change_set_by_txn(apr_int64_t txn_id);
+svn_fs_x__change_set_t svn_fs_x__change_set_by_txn(svn_fs_x__txn_id_t txn_id);
-/* A rev node ID in FSX consists of a 3 of sub-IDs ("parts") that consist
- * of a creation CHANGE_SET number and some revision-local counter value
- * (NUMBER).
+/* An ID in FSX consists of a creation CHANGE_SET number and some changeset-
+ * local counter value (NUMBER).
*/
-typedef struct svn_fs_x__id_part_t
+typedef struct svn_fs_x__id_t
{
svn_fs_x__change_set_t change_set;
apr_uint64_t number;
-} svn_fs_x__id_part_t;
+} svn_fs_x__id_t;
/*** Operations on ID parts. ***/
/* Return TRUE, if both elements of the PART is 0, i.e. this is the default
* value if e.g. no copies were made of this node. */
-svn_boolean_t svn_fs_x__id_part_is_root(const svn_fs_x__id_part_t *part);
+svn_boolean_t svn_fs_x__id_is_root(const svn_fs_x__id_t *part);
/* Return TRUE, if all element values of *LHS and *RHS match. */
-svn_boolean_t svn_fs_x__id_part_eq(const svn_fs_x__id_part_t *lhs,
- const svn_fs_x__id_part_t *rhs);
+svn_boolean_t svn_fs_x__id_eq(const svn_fs_x__id_t *lhs,
+ const svn_fs_x__id_t *rhs);
-
-/*** ID accessor functions. ***/
-
-/* Get the "node id" portion of ID. */
-const svn_fs_x__id_part_t *svn_fs_x__id_node_id(const svn_fs_id_t *id);
-
-/* Get the "copy id" portion of ID. */
-const svn_fs_x__id_part_t *svn_fs_x__id_copy_id(const svn_fs_id_t *id);
-
-/* Get the "txn id" portion of ID,
- * or SVN_FS_X__INVALID_TXN_ID if it is a permanent ID. */
-svn_fs_x__txn_id_t svn_fs_x__id_txn_id(const svn_fs_id_t *id);
-
-/* Get the "noderev id" portion of ID. */
-const svn_fs_x__id_part_t *svn_fs_x__id_noderev_id(const svn_fs_id_t *id);
-
-/* Get the "rev" portion of ID, or SVN_INVALID_REVNUM if it is a
- transaction ID. */
-svn_revnum_t svn_fs_x__id_rev(const svn_fs_id_t *id);
-
-/* Access the "item" portion of the ID, or 0 if it is a transaction
- ID. */
-apr_uint64_t svn_fs_x__id_item(const svn_fs_id_t *id);
-
-/* Return TRUE, if this is a transaction ID. */
-svn_boolean_t svn_fs_x__id_is_txn(const svn_fs_id_t *id);
+/* Parse the NUL-terminated ID part at DATA and write the result into *PART.
+ */
+svn_error_t *
+svn_fs_x__id_parse(svn_fs_x__id_t *part,
+ const char *data);
/* Convert ID into string form, allocated in POOL. */
-svn_string_t *svn_fs_x__id_unparse(const svn_fs_id_t *id,
- apr_pool_t *pool);
-
-/* Return true if A and B are equal. */
-svn_boolean_t svn_fs_x__id_eq(const svn_fs_id_t *a,
- const svn_fs_id_t *b);
-
-/* Return true if A and B are related. */
-svn_boolean_t svn_fs_x__id_check_related(const svn_fs_id_t *a,
- const svn_fs_id_t *b);
-
-/* Return the noderev relationship between A and B. */
-svn_fs_node_relation_t svn_fs_x__id_compare(const svn_fs_id_t *a,
- const svn_fs_id_t *b);
+svn_string_t *
+svn_fs_x__id_unparse(const svn_fs_x__id_t*id,
+ apr_pool_t *pool);
-/* Return 0 if A and B are equal, 1 if A is "greater than" B, -1 otherwise. */
-int svn_fs_x__id_part_compare(const svn_fs_x__id_part_t *a,
- const svn_fs_x__id_part_t *b);
-
-/* Create the txn root ID for transaction TXN_ID. Allocate it in POOL. */
-svn_fs_id_t *svn_fs_x__id_txn_create_root(svn_fs_x__txn_id_t txnnum,
- apr_pool_t *pool);
-
-/* Create the root ID for REVISION. Allocate it in POOL. */
-svn_fs_id_t *svn_fs_x__id_create_root(const svn_revnum_t revision,
- apr_pool_t *pool);
-
-/* Create an ID within a transaction based on NODE_ID, COPY_ID, TXN_ID
- and ITEM number, allocated in POOL. */
-svn_fs_id_t *svn_fs_x__id_txn_create(const svn_fs_x__id_part_t *node_id,
- const svn_fs_x__id_part_t *copy_id,
- svn_fs_x__txn_id_t txn_id,
- apr_uint64_t item,
- apr_pool_t *pool);
-
-/* Create a permanent ID based on NODE_ID, COPY_ID and NODEREV_ID,
- allocated in POOL. */
-svn_fs_id_t *svn_fs_x__id_create(const svn_fs_x__id_part_t *node_id,
- const svn_fs_x__id_part_t *copy_id,
- const svn_fs_x__id_part_t *noderev_id,
- apr_pool_t *pool);
-
-/* Return a copy of ID, allocated from POOL. */
-svn_fs_id_t *svn_fs_x__id_copy(const svn_fs_id_t *id,
- apr_pool_t *pool);
-
-/* Return an ID in *ID_P resulting from parsing the string DATA, or an error
- if DATA is an invalid ID string. *DATA will be modified / invalidated by
- this call. */
-svn_error_t *
-svn_fs_x__id_parse(const svn_fs_id_t **id_p,
- char *data,
- apr_pool_t *pool);
+/* Set *PART to "unused". */
+void svn_fs_x__id_reset(svn_fs_x__id_t *part);
+/* Return TRUE if *PART is belongs to either a revision or transaction. */
+svn_boolean_t svn_fs_x__id_used(const svn_fs_x__id_t *part);
-/* (de-)serialization support*/
-
-struct svn_temp_serializer__context_t;
+/* Return 0 if A and B are equal, 1 if A is "greater than" B, -1 otherwise. */
+int svn_fs_x__id_compare(const svn_fs_x__id_t *a,
+ const svn_fs_x__id_t *b);
-/**
- * Serialize an @a id within the serialization @a context.
- */
+/* Set *NODEREV_ID to the root node ID of transaction TXN_ID. */
void
-svn_fs_x__id_serialize(struct svn_temp_serializer__context_t *context,
- const svn_fs_id_t * const *id);
+svn_fs_x__init_txn_root(svn_fs_x__id_t *noderev_id,
+ svn_fs_x__txn_id_t txn_id);
-/**
- * Deserialize an @a id within the @a buffer and associate it with @a pool.
- */
+/* Set *NODEREV_ID to the root node ID of revision REV. */
void
-svn_fs_x__id_deserialize(void *buffer,
- svn_fs_id_t **id,
- apr_pool_t *pool);
+svn_fs_x__init_rev_root(svn_fs_x__id_t *noderev_id,
+ svn_revnum_t rev);
#ifdef __cplusplus
}
Modified: subversion/trunk/subversion/libsvn_fs_x/index.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/index.c?rev=1649012&r1=1649011&r2=1649012&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/index.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/index.c Fri Jan 2 12:43:42 2015
@@ -2063,7 +2063,7 @@ svn_fs_x__p2l_proto_index_add_entry(apr_
/* Add sub-items. */
for (i = 0; i < entry->item_count; ++i)
{
- const svn_fs_x__id_part_t *sub_item = &entry->items[i];
+ const svn_fs_x__id_t *sub_item = &entry->items[i];
/* Make sure all signed elements of ENTRY have non-negative values.
*
@@ -2128,7 +2128,7 @@ read_p2l_sub_items_from_proto_index(apr_
for (i = 0; i < entry->item_count; ++i)
{
apr_uint64_t revision;
- svn_fs_x__id_part_t *sub_item = &entry->items[i];
+ svn_fs_x__id_t *sub_item = &entry->items[i];
SVN_ERR(read_uint64_from_proto_index(proto_index, &revision,
eof, scratch_pool));
@@ -2954,7 +2954,7 @@ append_p2l_entries(apr_array_header_t *e
/* Copy the items of that entries. */
if (entry->item_count)
{
- const svn_fs_x__id_part_t *items
+ const svn_fs_x__id_t *items
= resolve_ptr
? svn_temp_deserializer__ptr(page_entries->elts,
(const void * const *)&entry->items)
@@ -3241,7 +3241,7 @@ get_p2l_entry_from_cached_page(const voi
svn_fs_x__p2l_entry_t *result
= apr_pmemdup(result_pool, entry, sizeof(*result));
result->items
- = (svn_fs_x__id_part_t *)svn_temp_deserializer__ptr(entries->elts,
+ = (svn_fs_x__id_t *)svn_temp_deserializer__ptr(entries->elts,
(const void *const *)&entry->items);
return result;
}
@@ -3338,7 +3338,7 @@ typedef struct p2l_item_lookup_baton_t
} p2l_item_lookup_baton_t;
/* Implements svn_cache__partial_getter_func_t for P2L index pages, copying
- * the svn_fs_x__id_part_t for the item described 2l_item_lookup_baton_t
+ * the svn_fs_x__id_t for the item described 2l_item_lookup_baton_t
* *BATON. *OUT will be NULL if there is no matching index entry or the
* sub-item is out of range.
*/
@@ -3366,7 +3366,7 @@ p2l_item_lookup_func(void **out,
}
svn_error_t *
-svn_fs_x__p2l_item_lookup(svn_fs_x__id_part_t **item,
+svn_fs_x__p2l_item_lookup(svn_fs_x__id_t **item,
svn_fs_t *fs,
svn_fs_x__revision_file_t *rev_file,
svn_revnum_t revision,
@@ -3464,7 +3464,7 @@ svn_fs_x__item_offset(apr_off_t *absolut
apr_uint32_t *sub_item,
svn_fs_t *fs,
svn_fs_x__revision_file_t *rev_file,
- const svn_fs_x__id_part_t *item_id,
+ const svn_fs_x__id_t *item_id,
apr_pool_t *scratch_pool)
{
if (svn_fs_x__is_txn(item_id->change_set))
@@ -3583,15 +3583,15 @@ typedef struct sub_item_ordered_t
/* Array of pointers into ENTRY->ITEMS, sorted by their revision member
* _descending_ order. May be NULL if ENTRY->ITEM_COUNT < 2. */
- svn_fs_x__id_part_t **order;
+ svn_fs_x__id_t **order;
} sub_item_ordered_t;
/* implements compare_fn_t. Place LHS before RHS, if the latter is younger.
* Used to sort sub_item_ordered_t::order
*/
static int
-compare_sub_items(const svn_fs_x__id_part_t * const * lhs,
- const svn_fs_x__id_part_t * const * rhs)
+compare_sub_items(const svn_fs_x__id_t * const * lhs,
+ const svn_fs_x__id_t * const * rhs)
{
return (*lhs)->change_set < (*rhs)->change_set
? 1
@@ -3605,8 +3605,8 @@ static int
compare_p2l_info_rev(const sub_item_ordered_t * lhs,
const sub_item_ordered_t * rhs)
{
- svn_fs_x__id_part_t *lhs_part;
- svn_fs_x__id_part_t *rhs_part;
+ svn_fs_x__id_t *lhs_part;
+ svn_fs_x__id_t *rhs_part;
assert(lhs != rhs);
if (lhs->entry->item_count == 0)
@@ -3697,7 +3697,7 @@ svn_fs_x__l2p_index_from_p2l_entries(con
/* write index entries */
for (i = 0; i < count; ++i)
{
- svn_fs_x__id_part_t *sub_item;
+ svn_fs_x__id_t *sub_item;
sub_item_ordered_t *ordered = svn_priority_queue__peek(queue);
if (ordered->entry->item_count > 0)
Modified: subversion/trunk/subversion/libsvn_fs_x/index.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/index.h?rev=1649012&r1=1649011&r2=1649012&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/index.h (original)
+++ subversion/trunk/subversion/libsvn_fs_x/index.h Fri Jan 2 12:43:42 2015
@@ -77,7 +77,7 @@ typedef struct svn_fs_x__p2l_entry_t
apr_uint32_t item_count;
/* List of items in that block / container */
- svn_fs_x__id_part_t *items;
+ svn_fs_x__id_t *items;
} svn_fs_x__p2l_entry_t;
/* Return a (deep) copy of ENTRY, allocated in POOL.
@@ -220,7 +220,7 @@ svn_fs_x__p2l_entry_lookup(svn_fs_x__p2l
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
-/* Use the phys-to-log mapping files in FS to return the svn_fs_x__id_part_t
+/* Use the phys-to-log mapping files in FS to return the svn_fs_x__id_t
* for the SUB_ITEM of the container starting at global OFFSET in the rep /
* pack file containing REVISION in *ITEM, allocated in RESULT_POOL. Sets
* *ITEM to NULL if no element starts at exactly that offset or if it
@@ -229,7 +229,7 @@ svn_fs_x__p2l_entry_lookup(svn_fs_x__p2l
* Use SCRATCH_POOL for temporary allocations.
*/
svn_error_t *
-svn_fs_x__p2l_item_lookup(svn_fs_x__id_part_t **item,
+svn_fs_x__p2l_item_lookup(svn_fs_x__id_t **item,
svn_fs_t *fs,
svn_fs_x__revision_file_t *rev_file,
svn_revnum_t revision,
@@ -254,7 +254,7 @@ svn_fs_x__item_offset(apr_off_t *absolut
apr_uint32_t *sub_item,
svn_fs_t *fs,
svn_fs_x__revision_file_t *rev_file,
- const svn_fs_x__id_part_t *item_id,
+ const svn_fs_x__id_t *item_id,
apr_pool_t *scratch_pool);
/* Use the log-to-phys indexes in FS to determine the maximum item indexes
Modified: subversion/trunk/subversion/libsvn_fs_x/low_level.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/low_level.c?rev=1649012&r1=1649011&r2=1649012&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/low_level.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/low_level.c Fri Jan 2 12:43:42 2015
@@ -38,6 +38,8 @@
/* Headers used to describe node-revision in the revision file. */
#define HEADER_ID "id"
+#define HEADER_NODE "node"
+#define HEADER_COPY "copy"
#define HEADER_TYPE "type"
#define HEADER_COUNT "count"
#define HEADER_PROPS "props"
@@ -325,7 +327,7 @@ svn_fs_x__parse_representation(represent
static svn_error_t *
read_rep_offsets(representation_t **rep_p,
char *string,
- const svn_fs_id_t *noderev_id,
+ const svn_fs_x__id_t *noderev_id,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
@@ -344,7 +346,7 @@ read_rep_offsets(representation_t **rep_
where = apr_psprintf(scratch_pool,
_("While reading representation offsets "
"for node-revision '%s':"),
- noderev_id ? id_unparsed->data : "(null)");
+ id_unparsed->data);
return svn_error_quick_wrap(err, where);
}
@@ -404,6 +406,22 @@ auto_unescape_path(const char *path,
return path;
}
+/* Find entry HEADER_NAME in HEADERS and parse its value into *ID. */
+static svn_error_t *
+read_id_part(svn_fs_x__id_t *id,
+ apr_hash_t *headers,
+ const char *header_name)
+{
+ const char *value = svn_hash_gets(headers, header_name);
+ if (value == NULL)
+ return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
+ _("Missing %s field in node-rev"),
+ header_name);
+
+ SVN_ERR(svn_fs_x__id_parse(id, value));
+ return SVN_NO_ERROR;
+}
+
svn_error_t *
svn_fs_x__read_noderev(node_revision_t **noderev_p,
svn_stream_t *stream,
@@ -416,20 +434,17 @@ svn_fs_x__read_noderev(node_revision_t *
const char *noderev_id;
SVN_ERR(read_header_block(&headers, stream, scratch_pool));
+ SVN_ERR(svn_stream_close(stream));
noderev = apr_pcalloc(result_pool, sizeof(*noderev));
- /* Read the node-rev id. */
- value = svn_hash_gets(headers, HEADER_ID);
- if (value == NULL)
- /* ### More information: filename/offset coordinates */
- return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
- _("Missing id field in node-rev"));
-
- SVN_ERR(svn_stream_close(stream));
+ /* for error messages later */
+ noderev_id = svn_hash_gets(headers, HEADER_ID);
- SVN_ERR(svn_fs_x__id_parse(&noderev->id, value, result_pool));
- noderev_id = value; /* for error messages later */
+ /* Read the node-rev id. */
+ SVN_ERR(read_id_part(&noderev->noderev_id, headers, HEADER_ID));
+ SVN_ERR(read_id_part(&noderev->node_id, headers, HEADER_NODE));
+ SVN_ERR(read_id_part(&noderev->copy_id, headers, HEADER_COPY));
/* Read the type. */
value = svn_hash_gets(headers, HEADER_TYPE);
@@ -458,7 +473,8 @@ svn_fs_x__read_noderev(node_revision_t *
if (value)
{
SVN_ERR(read_rep_offsets(&noderev->prop_rep, value,
- noderev->id, result_pool, scratch_pool));
+ &noderev->noderev_id, result_pool,
+ scratch_pool));
}
/* Get the data location. */
@@ -466,7 +482,8 @@ svn_fs_x__read_noderev(node_revision_t *
if (value)
{
SVN_ERR(read_rep_offsets(&noderev->data_rep, value,
- noderev->id, result_pool, scratch_pool));
+ &noderev->noderev_id, result_pool,
+ scratch_pool));
}
/* Get the created path. */
@@ -492,15 +509,17 @@ svn_fs_x__read_noderev(node_revision_t *
/* Get the predecessor ID. */
value = svn_hash_gets(headers, HEADER_PRED);
if (value)
- SVN_ERR(svn_fs_x__id_parse(&noderev->predecessor_id, value,
- result_pool));
+ SVN_ERR(svn_fs_x__id_parse(&noderev->predecessor_id, value));
+ else
+ svn_fs_x__id_reset(&noderev->predecessor_id);
/* Get the copyroot. */
value = svn_hash_gets(headers, HEADER_COPYROOT);
if (value == NULL)
{
noderev->copyroot_path = noderev->created_path;
- noderev->copyroot_rev = svn_fs_x__id_rev(noderev->id);
+ noderev->copyroot_rev
+ = svn_fs_x__get_revnum(noderev->noderev_id.change_set);
}
else
{
@@ -609,17 +628,25 @@ svn_fs_x__write_noderev(svn_stream_t *ou
node_revision_t *noderev,
apr_pool_t *scratch_pool)
{
+ svn_string_t *str_id;
+
+ str_id = svn_fs_x__id_unparse(&noderev->noderev_id, scratch_pool);
SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_ID ": %s\n",
- svn_fs_x__id_unparse(noderev->id,
- scratch_pool)->data));
+ str_id->data));
+ str_id = svn_fs_x__id_unparse(&noderev->node_id, scratch_pool);
+ SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_NODE ": %s\n",
+ str_id->data));
+ str_id = svn_fs_x__id_unparse(&noderev->copy_id, scratch_pool);
+ SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_COPY ": %s\n",
+ str_id->data));
SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_TYPE ": %s\n",
(noderev->kind == svn_node_file) ?
SVN_FS_X__KIND_FILE : SVN_FS_X__KIND_DIR));
- if (noderev->predecessor_id)
+ if (svn_fs_x__id_used(&noderev->predecessor_id))
SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_PRED ": %s\n",
- svn_fs_x__id_unparse(noderev->predecessor_id,
+ svn_fs_x__id_unparse(&noderev->predecessor_id,
scratch_pool)->data));
SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_COUNT ": %d\n",
@@ -649,8 +676,9 @@ svn_fs_x__write_noderev(svn_stream_t *ou
auto_escape_path(noderev->copyfrom_path,
scratch_pool)));
- if ((noderev->copyroot_rev != svn_fs_x__id_rev(noderev->id)) ||
- (strcmp(noderev->copyroot_path, noderev->created_path) != 0))
+ if ( ( noderev->copyroot_rev
+ != svn_fs_x__get_revnum(noderev->noderev_id.change_set))
+ || (strcmp(noderev->copyroot_path, noderev->created_path) != 0))
SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_COPYROOT ": %ld"
" %s\n",
noderev->copyroot_rev,
@@ -758,7 +786,6 @@ read_change(change_t **change_p,
svn_boolean_t eof = TRUE;
change_t *change;
char *str, *last_str, *kind_str;
- svn_fs_path_change2_t *info;
/* Default return value. */
*change_p = NULL;
@@ -770,7 +797,6 @@ read_change(change_t **change_p,
return SVN_NO_ERROR;
change = apr_pcalloc(result_pool, sizeof(*change));
- info = &change->info;
last_str = line->data;
/* Get the node-id of the change. */
@@ -779,10 +805,7 @@ read_change(change_t **change_p,
return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
_("Invalid changes line in rev-file"));
- SVN_ERR(svn_fs_x__id_parse(&info->node_rev_id, str, result_pool));
- if (info->node_rev_id == NULL)
- return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
- _("Invalid changes line in rev-file"));
+ SVN_ERR(svn_fs_x__id_parse(&change->noderev_id, str));
/* Get the change type. */
str = svn_cstring_tokenize(" ", &last_str);
@@ -792,7 +815,7 @@ read_change(change_t **change_p,
/* Don't bother to check the format number before looking for
* node-kinds: just read them if you find them. */
- info->node_kind = svn_node_unknown;
+ change->node_kind = svn_node_unknown;
kind_str = strchr(str, '-');
if (kind_str)
{
@@ -800,9 +823,9 @@ read_change(change_t **change_p,
*kind_str = '\0';
kind_str++;
if (strcmp(kind_str, SVN_FS_X__KIND_FILE) == 0)
- info->node_kind = svn_node_file;
+ change->node_kind = svn_node_file;
else if (strcmp(kind_str, SVN_FS_X__KIND_DIR) == 0)
- info->node_kind = svn_node_dir;
+ change->node_kind = svn_node_dir;
else
return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
_("Invalid changes line in rev-file"));
@@ -810,23 +833,23 @@ read_change(change_t **change_p,
if (strcmp(str, ACTION_MODIFY) == 0)
{
- info->change_kind = svn_fs_path_change_modify;
+ change->change_kind = svn_fs_path_change_modify;
}
else if (strcmp(str, ACTION_ADD) == 0)
{
- info->change_kind = svn_fs_path_change_add;
+ change->change_kind = svn_fs_path_change_add;
}
else if (strcmp(str, ACTION_DELETE) == 0)
{
- info->change_kind = svn_fs_path_change_delete;
+ change->change_kind = svn_fs_path_change_delete;
}
else if (strcmp(str, ACTION_REPLACE) == 0)
{
- info->change_kind = svn_fs_path_change_replace;
+ change->change_kind = svn_fs_path_change_replace;
}
else if (strcmp(str, ACTION_RESET) == 0)
{
- info->change_kind = svn_fs_path_change_reset;
+ change->change_kind = svn_fs_path_change_reset;
}
else
{
@@ -842,11 +865,11 @@ read_change(change_t **change_p,
if (strcmp(str, FLAG_TRUE) == 0)
{
- info->text_mod = TRUE;
+ change->text_mod = TRUE;
}
else if (strcmp(str, FLAG_FALSE) == 0)
{
- info->text_mod = FALSE;
+ change->text_mod = FALSE;
}
else
{
@@ -862,11 +885,11 @@ read_change(change_t **change_p,
if (strcmp(str, FLAG_TRUE) == 0)
{
- info->prop_mod = TRUE;
+ change->prop_mod = TRUE;
}
else if (strcmp(str, FLAG_FALSE) == 0)
{
- info->prop_mod = FALSE;
+ change->prop_mod = FALSE;
}
else
{
@@ -882,11 +905,11 @@ read_change(change_t **change_p,
if (strcmp(str, FLAG_TRUE) == 0)
{
- info->mergeinfo_mod = svn_tristate_true;
+ change->mergeinfo_mod = svn_tristate_true;
}
else if (strcmp(str, FLAG_FALSE) == 0)
{
- info->mergeinfo_mod = svn_tristate_false;
+ change->mergeinfo_mod = svn_tristate_false;
}
else
{
@@ -907,22 +930,22 @@ read_change(change_t **change_p,
/* Read the next line, the copyfrom line. */
SVN_ERR(svn_stream_readline(stream, &line, "\n", &eof, result_pool));
- info->copyfrom_known = TRUE;
+ change->copyfrom_known = TRUE;
if (eof || line->len == 0)
{
- info->copyfrom_rev = SVN_INVALID_REVNUM;
- info->copyfrom_path = NULL;
+ change->copyfrom_rev = SVN_INVALID_REVNUM;
+ change->copyfrom_path = NULL;
}
else
{
last_str = line->data;
- SVN_ERR(parse_revnum(&info->copyfrom_rev, (const char **)&last_str));
+ SVN_ERR(parse_revnum(&change->copyfrom_rev, (const char **)&last_str));
if (!svn_fspath__is_canonical(last_str))
return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
_("Invalid copy-from path in changes line"));
- info->copyfrom_path = auto_unescape_path(last_str, result_pool);
+ change->copyfrom_path = auto_unescape_path(last_str, result_pool);
}
*change_p = change;
@@ -992,8 +1015,7 @@ svn_fs_x__read_changes_incrementally(svn
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,
+ change_t *change,
apr_pool_t *scratch_pool)
{
const char *idstr;
@@ -1025,10 +1047,7 @@ write_change_entry(svn_stream_t *stream,
change->change_kind);
}
- if (change->node_rev_id)
- idstr = svn_fs_x__id_unparse(change->node_rev_id, scratch_pool)->data;
- else
- idstr = ACTION_RESET;
+ idstr = svn_fs_x__id_unparse(&change->noderev_id, scratch_pool)->data;
SVN_ERR_ASSERT(change->node_kind == svn_node_dir
|| change->node_kind == svn_node_file);
@@ -1043,7 +1062,7 @@ write_change_entry(svn_stream_t *stream,
change->prop_mod ? FLAG_TRUE : FLAG_FALSE,
change->mergeinfo_mod == svn_tristate_true
? FLAG_TRUE : FLAG_FALSE,
- auto_escape_path(path, scratch_pool));
+ auto_escape_path(change->path.data, scratch_pool));
if (SVN_IS_VALID_REVNUM(change->copyfrom_rev))
{
@@ -1087,16 +1106,13 @@ svn_fs_x__write_changes(svn_stream_t *st
/* Write all items to disk in the new order. */
for (i = 0; i < sorted_changed_paths->nelts; ++i)
{
- svn_fs_path_change2_t *change;
- const char *path;
+ change_t *change;
svn_pool_clear(iterpool);
-
change = APR_ARRAY_IDX(sorted_changed_paths, i, svn_sort__item_t).value;
- path = APR_ARRAY_IDX(sorted_changed_paths, i, svn_sort__item_t).key;
/* Write out the new entry into the final rev-file. */
- SVN_ERR(write_change_entry(stream, path, change, iterpool));
+ SVN_ERR(write_change_entry(stream, change, iterpool));
}
if (terminate_list)
Modified: subversion/trunk/subversion/libsvn_fs_x/noderevs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/noderevs.c?rev=1649012&r1=1649011&r2=1649012&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/noderevs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/noderevs.c Fri Jan 2 12:43:42 2015
@@ -49,16 +49,6 @@
/* the noderev has copy-root path and revision */
#define NODEREV_HAS_CPATH 0x00040
-/* Our internal representation of an id
- * (basically, strip off the txn_id and the fs-agnostic header)
- */
-typedef struct binary_id_t
-{
- svn_fs_x__id_part_t node_id;
- svn_fs_x__id_part_t copy_id;
- svn_fs_x__id_part_t noderev_id;
-} binary_id_t;
-
/* Our internal representation of an representation.
*/
typedef struct binary_representation_t
@@ -70,7 +60,7 @@ typedef struct binary_representation_t
unsigned char md5_digest[APR_MD5_DIGESTSIZE];
/* Location of this representation. */
- svn_fs_x__id_part_t id;
+ svn_fs_x__id_t id;
/* The size of the representation in bytes as seen in the revision
file. */
@@ -93,9 +83,15 @@ typedef struct binary_noderev_t
/* node type and presence indicators */
apr_uint32_t flags;
- /* Index+1 of the node-id for this node-rev. */
+ /* Index+1 of the noderev-id for this node-rev. */
int id;
+ /* Index+1 of the node-id for this node-rev. */
+ int node_id;
+
+ /* Index+1 of the copy-id for this node-rev. */
+ int copy_id;
+
/* Index+1 of the predecessor node revision id, or 0 if there is no
predecessor for this node revision */
int predecessor_id;
@@ -156,19 +152,14 @@ struct svn_fs_x__noderevs_t
apr_hash_t *ids_dict;
/* During construction, maps a full binary_representation_t to an index
- * into DATA_REPS. */
- apr_hash_t *data_reps_dict;
-
- /* During construction, maps a full binary_representation_t to an index
- * into PROP_REPS. */
- apr_hash_t *prop_reps_dict;
+ * into REPS. */
+ apr_hash_t *reps_dict;
/* array of binary_id_t */
apr_array_header_t *ids;
- /* arrays of binary_representation_t */
- apr_array_header_t *data_reps;
- apr_array_header_t *prop_reps;
+ /* array of binary_representation_t */
+ apr_array_header_t *reps;
/* array of binary_noderev_t. */
apr_array_header_t *noderevs;
@@ -182,16 +173,13 @@ svn_fs_x__noderevs_create(int initial_co
noderevs->builder = svn_fs_x__string_table_builder_create(pool);
noderevs->ids_dict = svn_hash__make(pool);
- noderevs->data_reps_dict = svn_hash__make(pool);
- noderevs->prop_reps_dict = svn_hash__make(pool);
+ noderevs->reps_dict = svn_hash__make(pool);
noderevs->paths = NULL;
noderevs->ids
- = apr_array_make(pool, initial_count, sizeof(binary_id_t));
- noderevs->data_reps
- = apr_array_make(pool, initial_count, sizeof(binary_representation_t));
- noderevs->prop_reps
- = apr_array_make(pool, initial_count, sizeof(binary_representation_t));
+ = apr_array_make(pool, 2 * initial_count, sizeof(svn_fs_x__id_t));
+ noderevs->reps
+ = apr_array_make(pool, 2 * initial_count, sizeof(binary_representation_t));
noderevs->noderevs
= apr_array_make(pool, initial_count, sizeof(binary_noderev_t));
@@ -204,24 +192,19 @@ svn_fs_x__noderevs_create(int initial_co
static int
store_id(apr_array_header_t *ids,
apr_hash_t *dict,
- const svn_fs_id_t *id)
+ const svn_fs_x__id_t *id)
{
- binary_id_t bin_id = { { 0 } };
int idx;
void *idx_void;
- if (id == NULL)
+ if (!svn_fs_x__id_used(id))
return 0;
-
- bin_id.node_id = *svn_fs_x__id_node_id(id);
- bin_id.copy_id = *svn_fs_x__id_copy_id(id);
- bin_id.noderev_id = *svn_fs_x__id_noderev_id(id);
- idx_void = apr_hash_get(dict, &bin_id, sizeof(bin_id));
+ idx_void = apr_hash_get(dict, &id, sizeof(id));
idx = (int)(apr_uintptr_t)idx_void;
if (idx == 0)
{
- APR_ARRAY_PUSH(ids, binary_id_t) = bin_id;
+ APR_ARRAY_PUSH(ids, svn_fs_x__id_t) = *id;
idx = ids->nelts;
apr_hash_set(dict, ids->elts + (idx-1) * ids->elt_size,
ids->elt_size, (void*)(apr_uintptr_t)idx);
@@ -278,9 +261,13 @@ svn_fs_x__noderevs_add(svn_fs_x__noderev
| (int)noderev->kind;
binary_noderev.id
- = store_id(container->ids, container->ids_dict, noderev->id);
+ = store_id(container->ids, container->ids_dict, &noderev->noderev_id);
+ binary_noderev.node_id
+ = store_id(container->ids, container->ids_dict, &noderev->node_id);
+ binary_noderev.copy_id
+ = store_id(container->ids, container->ids_dict, &noderev->copy_id);
binary_noderev.predecessor_id
- = store_id(container->ids, container->ids_dict, noderev->predecessor_id);
+ = store_id(container->ids, container->ids_dict, &noderev->predecessor_id);
if (noderev->copyfrom_path)
{
@@ -301,19 +288,18 @@ svn_fs_x__noderevs_add(svn_fs_x__noderev
}
binary_noderev.predecessor_count = noderev->predecessor_count;
- binary_noderev.prop_rep = store_representation(container->prop_reps,
- container->prop_reps_dict,
+ binary_noderev.prop_rep = store_representation(container->reps,
+ container->reps_dict,
noderev->prop_rep);
- if (noderev->data_rep)
- binary_noderev.data_rep = store_representation(container->data_reps,
- container->data_reps_dict,
- noderev->data_rep);
+ binary_noderev.data_rep = store_representation(container->reps,
+ container->reps_dict,
+ noderev->data_rep);
if (noderev->created_path)
binary_noderev.created_path
= svn_fs_x__string_table_builder_add(container->builder,
- noderev->created_path,
- 0);
+ noderev->created_path,
+ 0);
binary_noderev.mergeinfo_count = noderev->mergeinfo_count;
@@ -331,49 +317,39 @@ svn_fs_x__noderevs_estimate_size(const s
/* string table code makes its own prediction,
* noderevs should be < 16 bytes each,
- * ids < 10 bytes each,
+ * id parts < 4 bytes each,
* data representations < 40 bytes each,
* property representations < 30 bytes each,
* some static overhead should be assumed */
return svn_fs_x__string_table_builder_estimate_size(container->builder)
+ container->noderevs->nelts * 16
- + container->ids->nelts * 10
- + container->data_reps->nelts * 40
- + container->prop_reps->nelts * 30
+ + container->ids->nelts * 4
+ + container->reps->nelts * 40
+ 100;
}
-/* Create an svn_fs_id_t in *ID, allocated in POOL based on the id stored
- * at index IDX in IDS.
+/* Set *ID to the ID part stored at index IDX in IDS.
*/
static svn_error_t *
-get_id(const svn_fs_id_t **id,
+get_id(svn_fs_x__id_t *id,
const apr_array_header_t *ids,
- int idx,
- apr_pool_t *pool)
+ int idx)
{
- binary_id_t *binary_id;
-
/* handle NULL IDs */
if (idx == 0)
{
- *id = NULL;
+ svn_fs_x__id_reset(id);
return SVN_NO_ERROR;
}
/* check for corrupted data */
if (idx < 0 || idx > ids->nelts)
return svn_error_createf(SVN_ERR_FS_CONTAINER_INDEX, NULL,
- _("Node revision ID index %d"
- " exceeds container size %d"),
+ _("ID part index %d exceeds container size %d"),
idx, ids->nelts);
- /* create a svn_fs_id_t from stored info */
- binary_id = &APR_ARRAY_IDX(ids, idx - 1, binary_id_t);
- *id = svn_fs_x__id_create(&binary_id->node_id,
- &binary_id->copy_id,
- &binary_id->noderev_id,
- pool);
+ /* Return the requested ID. */
+ *id = APR_ARRAY_IDX(ids, idx - 1, svn_fs_x__id_t);
return SVN_NO_ERROR;
}
@@ -427,7 +403,7 @@ svn_fs_x__noderevs_get(node_revision_t *
{
node_revision_t *noderev;
binary_noderev_t *binary_noderev;
-
+
/* CONTAINER must be in 'finalized' mode */
SVN_ERR_ASSERT(container->builder == NULL);
SVN_ERR_ASSERT(container->paths);
@@ -444,11 +420,15 @@ svn_fs_x__noderevs_get(node_revision_t *
/* allocate result struct and fill it field by field */
noderev = apr_pcalloc(pool, sizeof(*noderev));
binary_noderev = &APR_ARRAY_IDX(container->noderevs, idx, binary_noderev_t);
-
+
noderev->kind = (svn_node_kind_t)(binary_noderev->flags & NODEREV_KIND_MASK);
- SVN_ERR(get_id(&noderev->id, container->ids, binary_noderev->id, pool));
+ SVN_ERR(get_id(&noderev->noderev_id, container->ids, binary_noderev->id));
+ SVN_ERR(get_id(&noderev->node_id, container->ids,
+ binary_noderev->node_id));
+ SVN_ERR(get_id(&noderev->copy_id, container->ids,
+ binary_noderev->copy_id));
SVN_ERR(get_id(&noderev->predecessor_id, container->ids,
- binary_noderev->predecessor_id, pool));
+ binary_noderev->predecessor_id));
if (binary_noderev->flags & NODEREV_HAS_COPYFROM)
{
@@ -482,9 +462,9 @@ svn_fs_x__noderevs_get(node_revision_t *
noderev->predecessor_count = binary_noderev->predecessor_count;
- SVN_ERR(get_representation(&noderev->prop_rep, container->prop_reps,
+ SVN_ERR(get_representation(&noderev->prop_rep, container->reps,
binary_noderev->prop_rep, pool));
- SVN_ERR(get_representation(&noderev->data_rep, container->data_reps,
+ SVN_ERR(get_representation(&noderev->data_rep, container->reps,
binary_noderev->data_rep, pool));
if (binary_noderev->flags & NODEREV_HAS_CPATH)
@@ -574,40 +554,34 @@ svn_fs_x__write_noderevs_container(svn_s
= svn_packed__create_int_stream(root, FALSE, FALSE);
svn_packed__int_stream_t *ids_stream
= svn_packed__create_int_substream(structs_stream, FALSE, FALSE);
- svn_packed__int_stream_t *data_reps_stream
- = create_rep_stream(structs_stream);
- svn_packed__int_stream_t *prop_reps_stream
+ svn_packed__int_stream_t *reps_stream
= create_rep_stream(structs_stream);
svn_packed__int_stream_t *noderevs_stream
= svn_packed__create_int_substream(structs_stream, FALSE, FALSE);
svn_packed__byte_stream_t *digests_stream
= svn_packed__create_bytes_stream(root);
- /* structure the CHANGES_STREAM such we can extract much of the redundancy
- * from the binary_change_t structs */
- for (i = 0; i < 3 * 2; ++i)
+ /* structure the IDS_STREAM such we can extract much of the redundancy
+ * from the svn_fs_x__ip_part_t structs */
+ for (i = 0; i < 2; ++i)
svn_packed__create_int_substream(ids_stream, TRUE, FALSE);
+ /* Same storing binary_noderev_t in the NODEREVS_STREAM */
svn_packed__create_int_substream(noderevs_stream, FALSE, FALSE);
- for (i = 0; i < 11; ++i)
+ for (i = 0; i < 13; ++i)
svn_packed__create_int_substream(noderevs_stream, TRUE, FALSE);
/* serialize ids array */
for (i = 0; i < container->ids->nelts; ++i)
{
- binary_id_t *id = &APR_ARRAY_IDX(container->ids, i, binary_id_t);
+ svn_fs_x__id_t *id = &APR_ARRAY_IDX(container->ids, i, svn_fs_x__id_t);
- svn_packed__add_int(ids_stream, id->node_id.change_set);
- svn_packed__add_uint(ids_stream, id->node_id.number);
- svn_packed__add_int(ids_stream, id->copy_id.change_set);
- svn_packed__add_uint(ids_stream, id->copy_id.number);
- svn_packed__add_int(ids_stream, id->noderev_id.change_set);
- svn_packed__add_uint(ids_stream, id->noderev_id.number);
+ svn_packed__add_int(ids_stream, id->change_set);
+ svn_packed__add_uint(ids_stream, id->number);
}
/* serialize rep arrays */
- write_reps(data_reps_stream, digests_stream, container->data_reps);
- write_reps(prop_reps_stream, digests_stream, container->prop_reps);
+ write_reps(reps_stream, digests_stream, container->reps);
/* serialize noderevs array */
for (i = 0; i < container->noderevs->nelts; ++i)
@@ -618,6 +592,8 @@ svn_fs_x__write_noderevs_container(svn_s
svn_packed__add_uint(noderevs_stream, noderev->flags);
svn_packed__add_uint(noderevs_stream, noderev->id);
+ svn_packed__add_uint(noderevs_stream, noderev->node_id);
+ svn_packed__add_uint(noderevs_stream, noderev->copy_id);
svn_packed__add_uint(noderevs_stream, noderev->predecessor_id);
svn_packed__add_uint(noderevs_stream, noderev->predecessor_count);
@@ -719,8 +695,7 @@ svn_fs_x__read_noderevs_container(svn_fs
svn_packed__data_root_t *root;
svn_packed__int_stream_t *structs_stream;
svn_packed__int_stream_t *ids_stream;
- svn_packed__int_stream_t *data_reps_stream;
- svn_packed__int_stream_t *prop_reps_stream;
+ svn_packed__int_stream_t *reps_stream;
svn_packed__int_stream_t *noderevs_stream;
svn_packed__byte_stream_t *digests_stream;
@@ -732,34 +707,27 @@ svn_fs_x__read_noderevs_container(svn_fs
/* get streams */
structs_stream = svn_packed__first_int_stream(root);
ids_stream = svn_packed__first_int_substream(structs_stream);
- data_reps_stream = svn_packed__next_int_stream(ids_stream);
- prop_reps_stream = svn_packed__next_int_stream(data_reps_stream);
- noderevs_stream = svn_packed__next_int_stream(prop_reps_stream);
+ reps_stream = svn_packed__next_int_stream(ids_stream);
+ noderevs_stream = svn_packed__next_int_stream(reps_stream);
digests_stream = svn_packed__first_byte_stream(root);
/* read ids array */
count
= svn_packed__int_count(svn_packed__first_int_substream(ids_stream));
noderevs->ids
- = apr_array_make(result_pool, (int)count, sizeof(binary_id_t));
+ = apr_array_make(result_pool, (int)count, sizeof(svn_fs_x__id_t));
for (i = 0; i < count; ++i)
{
- binary_id_t id;
+ svn_fs_x__id_t id;
- id.node_id.change_set = (svn_revnum_t)svn_packed__get_int(ids_stream);
- id.node_id.number = svn_packed__get_uint(ids_stream);
- id.copy_id.change_set = (svn_revnum_t)svn_packed__get_int(ids_stream);
- id.copy_id.number = svn_packed__get_uint(ids_stream);
- id.noderev_id.change_set = (svn_revnum_t)svn_packed__get_int(ids_stream);
- id.noderev_id.number = svn_packed__get_uint(ids_stream);
+ id.change_set = (svn_revnum_t)svn_packed__get_int(ids_stream);
+ id.number = svn_packed__get_uint(ids_stream);
- APR_ARRAY_PUSH(noderevs->ids, binary_id_t) = id;
+ APR_ARRAY_PUSH(noderevs->ids, svn_fs_x__id_t) = id;
}
/* read rep arrays */
- SVN_ERR(read_reps(&noderevs->data_reps, data_reps_stream, digests_stream,
- result_pool));
- SVN_ERR(read_reps(&noderevs->prop_reps, prop_reps_stream, digests_stream,
+ SVN_ERR(read_reps(&noderevs->reps, reps_stream, digests_stream,
result_pool));
/* read noderevs array */
@@ -774,6 +742,8 @@ svn_fs_x__read_noderevs_container(svn_fs
noderev.flags = (apr_uint32_t)svn_packed__get_uint(noderevs_stream);
noderev.id = (int)svn_packed__get_uint(noderevs_stream);
+ noderev.node_id = (int)svn_packed__get_uint(noderevs_stream);
+ noderev.copy_id = (int)svn_packed__get_uint(noderevs_stream);
noderev.predecessor_id = (int)svn_packed__get_uint(noderevs_stream);
noderev.predecessor_count = (int)svn_packed__get_uint(noderevs_stream);
@@ -806,8 +776,7 @@ svn_fs_x__serialize_noderevs_container(v
svn_stringbuf_t *serialized;
apr_size_t size
= noderevs->ids->elt_size * noderevs->ids->nelts
- + noderevs->data_reps->elt_size * noderevs->data_reps->nelts
- + noderevs->prop_reps->elt_size * noderevs->prop_reps->nelts
+ + noderevs->reps->elt_size * noderevs->reps->nelts
+ noderevs->noderevs->elt_size * noderevs->noderevs->nelts
+ 10 * noderevs->noderevs->elt_size
+ 100;
@@ -819,8 +788,7 @@ svn_fs_x__serialize_noderevs_container(v
/* serialize sub-structures */
svn_fs_x__serialize_string_table(context, &noderevs->paths);
svn_fs_x__serialize_apr_array(context, &noderevs->ids);
- svn_fs_x__serialize_apr_array(context, &noderevs->data_reps);
- svn_fs_x__serialize_apr_array(context, &noderevs->prop_reps);
+ svn_fs_x__serialize_apr_array(context, &noderevs->reps);
svn_fs_x__serialize_apr_array(context, &noderevs->noderevs);
/* return the serialized result */
@@ -843,8 +811,7 @@ svn_fs_x__deserialize_noderevs_container
/* de-serialize sub-structures */
svn_fs_x__deserialize_string_table(noderevs, &noderevs->paths);
svn_fs_x__deserialize_apr_array(noderevs, &noderevs->ids, pool);
- svn_fs_x__deserialize_apr_array(noderevs, &noderevs->data_reps, pool);
- svn_fs_x__deserialize_apr_array(noderevs, &noderevs->prop_reps, pool);
+ svn_fs_x__deserialize_apr_array(noderevs, &noderevs->reps, pool);
svn_fs_x__deserialize_apr_array(noderevs, &noderevs->noderevs, pool);
/* done */
@@ -880,10 +847,9 @@ svn_fs_x__noderevs_get_func(void **out,
{
node_revision_t *noderev;
binary_noderev_t *binary_noderev;
-
+
apr_array_header_t ids;
- apr_array_header_t data_reps;
- apr_array_header_t prop_reps;
+ apr_array_header_t reps;
apr_array_header_t noderevs;
apr_uint32_t idx = *(apr_uint32_t *)baton;
@@ -895,18 +861,19 @@ svn_fs_x__noderevs_get_func(void **out,
(const void *const *)&container->paths);
resolve_apr_array_header(&ids, container, &container->ids);
- resolve_apr_array_header(&data_reps, container, &container->data_reps);
- resolve_apr_array_header(&prop_reps, container, &container->prop_reps);
+ resolve_apr_array_header(&reps, container, &container->reps);
resolve_apr_array_header(&noderevs, container, &container->noderevs);
-
+
/* allocate result struct and fill it field by field */
noderev = apr_pcalloc(pool, sizeof(*noderev));
binary_noderev = &APR_ARRAY_IDX(&noderevs, idx, binary_noderev_t);
-
+
noderev->kind = (svn_node_kind_t)(binary_noderev->flags & NODEREV_KIND_MASK);
- SVN_ERR(get_id(&noderev->id, &ids, binary_noderev->id, pool));
+ SVN_ERR(get_id(&noderev->noderev_id, &ids, binary_noderev->id));
+ SVN_ERR(get_id(&noderev->node_id, &ids, binary_noderev->node_id));
+ SVN_ERR(get_id(&noderev->copy_id, &ids, binary_noderev->copy_id));
SVN_ERR(get_id(&noderev->predecessor_id, &ids,
- binary_noderev->predecessor_id, pool));
+ binary_noderev->predecessor_id));
if (binary_noderev->flags & NODEREV_HAS_COPYFROM)
{
@@ -940,9 +907,9 @@ svn_fs_x__noderevs_get_func(void **out,
noderev->predecessor_count = binary_noderev->predecessor_count;
- SVN_ERR(get_representation(&noderev->prop_rep, &prop_reps,
+ SVN_ERR(get_representation(&noderev->prop_rep, &reps,
binary_noderev->prop_rep, pool));
- SVN_ERR(get_representation(&noderev->data_rep, &data_reps,
+ SVN_ERR(get_representation(&noderev->data_rep, &reps,
binary_noderev->data_rep, pool));
if (binary_noderev->flags & NODEREV_HAS_CPATH)
Modified: subversion/trunk/subversion/libsvn_fs_x/pack.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/pack.c?rev=1649012&r1=1649011&r2=1649012&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/pack.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/pack.c Fri Jan 2 12:43:42 2015
@@ -101,7 +101,7 @@ typedef struct path_order_t
svn_prefix_string__t *path;
/* node ID for this PATH in REVISION */
- svn_fs_x__id_part_t node_id;
+ svn_fs_x__id_t node_id;
/* when this change happened */
svn_revnum_t revision;
@@ -113,10 +113,10 @@ typedef struct path_order_t
apr_int64_t expanded_size;
/* item ID of the noderev linked to the change. May be (0, 0). */
- svn_fs_x__id_part_t noderev_id;
+ svn_fs_x__id_t noderev_id;
/* item ID of the representation containing the new data. May be (0, 0). */
- svn_fs_x__id_part_t rep_id;
+ svn_fs_x__id_t rep_id;
} path_order_t;
/* Represents a reference from item FROM to item TO. FROM may be a noderev
@@ -125,8 +125,8 @@ typedef struct path_order_t
*/
typedef struct reference_t
{
- svn_fs_x__id_part_t to;
- svn_fs_x__id_part_t from;
+ svn_fs_x__id_t to;
+ svn_fs_x__id_t from;
} reference_t;
/* This structure keeps track of all the temporary data and status that
@@ -530,7 +530,7 @@ add_item_rep_mapping(pack_context_t *con
*/
static svn_fs_x__p2l_entry_t *
get_item(pack_context_t *context,
- const svn_fs_x__id_part_t *id,
+ const svn_fs_x__id_t *id,
svn_boolean_t reset)
{
svn_fs_x__p2l_entry_t *result = NULL;
@@ -717,10 +717,10 @@ copy_node_to_temp(pack_context_t *contex
* It will not be stored in the final pack file. */
sort_path = tweak_path_for_ordering(noderev->created_path, pool);
path_order->path = svn_prefix_string__create(context->paths, sort_path);
- path_order->node_id = *svn_fs_x__id_node_id(noderev->id);
- path_order->revision = svn_fs_x__id_rev(noderev->id);
+ path_order->node_id = noderev->node_id;
+ path_order->revision = svn_fs_x__get_revnum(noderev->noderev_id.change_set);
path_order->is_dir = noderev->kind == svn_node_dir;
- path_order->noderev_id = *svn_fs_x__id_noderev_id(noderev->id);
+ path_order->noderev_id = noderev->noderev_id;
APR_ARRAY_PUSH(context->path_order, path_order_t *) = path_order;
return SVN_NO_ERROR;
@@ -774,7 +774,7 @@ compare_path_order(const path_order_t *
return diff;
/* reverse order on node (i.e. latest first) */
- diff = svn_fs_x__id_part_compare(&rhs->node_id, &lhs->node_id);
+ diff = svn_fs_x__id_compare(&rhs->node_id, &lhs->node_id);
if (diff)
return diff;
@@ -794,8 +794,8 @@ compare_references(const reference_t * c
const reference_t * lhs = *lhs_p;
const reference_t * rhs = *rhs_p;
- int diff = svn_fs_x__id_part_compare(&lhs->to, &rhs->to);
- return diff ? diff : svn_fs_x__id_part_compare(&lhs->from, &rhs->from);
+ int diff = svn_fs_x__id_compare(&lhs->to, &rhs->to);
+ return diff ? diff : svn_fs_x__id_compare(&lhs->from, &rhs->from);
}
/* Order the data collected in CONTEXT such that we can place them in the
@@ -878,7 +878,7 @@ find_first_reference(pack_context_t *con
reference_t *reference
= APR_ARRAY_IDX(context->references, current, reference_t *);
- if (svn_fs_x__id_part_compare(&reference->to, item->items) < 0)
+ if (svn_fs_x__id_compare(&reference->to, item->items) < 0)
lower = current + 1;
else
upper = current - 1;
@@ -899,7 +899,7 @@ is_reference_match(pack_context_t *conte
return FALSE;
reference = APR_ARRAY_IDX(context->references, idx, reference_t *);
- return svn_fs_x__id_part_eq(&reference->to, item->items);
+ return svn_fs_x__id_eq(&reference->to, item->items);
}
/* Starting at IDX in CONTEXT->PATH_ORDER, select all representations and
@@ -936,8 +936,7 @@ select_reps(pack_context_t *context,
path_order_t *current_path
= APR_ARRAY_IDX(path_order, idx, path_order_t *);
- if (!svn_fs_x__id_part_eq(&start_path->node_id,
- ¤t_path->node_id))
+ if (!svn_fs_x__id_eq(&start_path->node_id, ¤t_path->node_id))
break;
APR_ARRAY_IDX(path_order, idx, path_order_t *) = NULL;
@@ -1036,7 +1035,7 @@ write_nodes_container(pack_context_t *co
container_entry->type = SVN_FS_X__ITEM_TYPE_NODEREVS_CONT;
container_entry->item_count = items->nelts;
container_entry->items = apr_palloc(context->info_pool,
- sizeof(svn_fs_x__id_part_t) * container_entry->item_count);
+ sizeof(svn_fs_x__id_t) * container_entry->item_count);
for (i = 0; i < items->nelts; ++i)
container_entry->items[i]
@@ -1185,7 +1184,7 @@ write_reps_container(pack_context_t *con
container_entry.size = offset - container_entry.offset;
container_entry.type = SVN_FS_X__ITEM_TYPE_REPS_CONT;
container_entry.item_count = sub_items->nelts;
- container_entry.items = (svn_fs_x__id_part_t *)sub_items->elts;
+ container_entry.items = (svn_fs_x__id_t *)sub_items->elts;
context->pack_offset = offset;
APR_ARRAY_PUSH(new_entries, svn_fs_x__p2l_entry_t *)
@@ -1217,7 +1216,7 @@ write_reps_containers(pack_context_t *co
svn_fs_x__reps_builder_t *container
= svn_fs_x__reps_builder_create(context->fs, container_pool);
apr_array_header_t *sub_items
- = apr_array_make(pool, 64, sizeof(svn_fs_x__id_part_t));
+ = apr_array_make(pool, 64, sizeof(svn_fs_x__id_t));
svn_fs_x__revision_file_t *file;
SVN_ERR(svn_fs_x__wrap_temp_rev_file(&file, context->fs, temp_file, pool));
@@ -1283,7 +1282,7 @@ write_reps_containers(pack_context_t *co
SVN_ERR_ASSERT(list_index == sub_items->nelts);
block_left -= entry->size;
- APR_ARRAY_PUSH(sub_items, svn_fs_x__id_part_t) = entry->items[0];
+ APR_ARRAY_PUSH(sub_items, svn_fs_x__id_t) = entry->items[0];
svn_pool_clear(iterpool);
}
@@ -1499,7 +1498,7 @@ write_changes_container(pack_context_t *
container_entry.size = offset - container_entry.offset;
container_entry.type = SVN_FS_X__ITEM_TYPE_CHANGES_CONT;
container_entry.item_count = sub_items->nelts;
- container_entry.items = (svn_fs_x__id_part_t *)sub_items->elts;
+ container_entry.items = (svn_fs_x__id_t *)sub_items->elts;
context->pack_offset = offset;
APR_ARRAY_PUSH(new_entries, svn_fs_x__p2l_entry_t *)
@@ -1531,7 +1530,7 @@ write_changes_containers(pack_context_t
svn_fs_x__changes_t *container
= svn_fs_x__changes_create(1000, container_pool);
apr_array_header_t *sub_items
- = apr_array_make(pool, 64, sizeof(svn_fs_x__id_part_t));
+ = apr_array_make(pool, 64, sizeof(svn_fs_x__id_t));
apr_array_header_t *new_entries
= apr_array_make(context->info_pool, 16, entries->elt_size);
svn_stream_t *temp_stream
@@ -1597,7 +1596,7 @@ write_changes_containers(pack_context_t
block_left -= estimated_size;
estimated_addition += estimated_size;
- APR_ARRAY_PUSH(sub_items, svn_fs_x__id_part_t) = entry->items[0];
+ APR_ARRAY_PUSH(sub_items, svn_fs_x__id_t) = entry->items[0];
svn_pool_clear(iterpool);
}
Modified: subversion/trunk/subversion/libsvn_fs_x/temp_serializer.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/temp_serializer.c?rev=1649012&r1=1649011&r2=1649012&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/temp_serializer.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/temp_serializer.c Fri Jan 2 12:43:42 2015
@@ -203,7 +203,7 @@ typedef struct dir_data_t
apr_size_t len;
/* reference to the entries */
- svn_fs_dirent_t **entries;
+ dirent_t **entries;
/* size of the serialized entries and don't be too wasteful
* (needed since the entries are no longer in sequence) */
@@ -216,17 +216,16 @@ typedef struct dir_data_t
*/
static void
serialize_dir_entry(svn_temp_serializer__context_t *context,
- svn_fs_dirent_t **entry_p,
+ dirent_t **entry_p,
apr_uint32_t *length)
{
- svn_fs_dirent_t *entry = *entry_p;
+ dirent_t *entry = *entry_p;
apr_size_t initial_length = svn_temp_serializer__get_length(context);
svn_temp_serializer__push(context,
(const void * const *)entry_p,
- sizeof(svn_fs_dirent_t));
+ sizeof(dirent_t));
- svn_fs_x__id_serialize(context, &entry->id);
svn_temp_serializer__add_string(context, &entry->name);
*length = (apr_uint32_t)( svn_temp_serializer__get_length(context)
@@ -248,7 +247,7 @@ serialize_dir(apr_array_header_t *entrie
/* calculate sizes */
int count = entries->nelts;
apr_size_t over_provision = 2 + count / 4;
- apr_size_t entries_len = (count + over_provision) * sizeof(svn_fs_dirent_t*);
+ apr_size_t entries_len = (count + over_provision) * sizeof(dirent_t*);
apr_size_t lengths_len = (count + over_provision) * sizeof(apr_uint32_t);
/* copy the hash entries to an auxiliary struct of known layout */
@@ -259,7 +258,7 @@ serialize_dir(apr_array_header_t *entrie
dir_data.lengths = apr_palloc(pool, lengths_len);
for (i = 0; i < count; ++i)
- dir_data.entries[i] = APR_ARRAY_IDX(entries, i, svn_fs_dirent_t *);
+ dir_data.entries[i] = APR_ARRAY_IDX(entries, i, dirent_t *);
/* Serialize that aux. structure into a new one. Also, provide a good
* estimate for the size of the buffer that we will need. */
@@ -296,11 +295,11 @@ static apr_array_header_t *
deserialize_dir(void *buffer, dir_data_t *dir_data, apr_pool_t *pool)
{
apr_array_header_t *result
- = apr_array_make(pool, dir_data->count, sizeof(svn_fs_dirent_t *));
+ = apr_array_make(pool, dir_data->count, sizeof(dirent_t *));
apr_size_t i;
apr_size_t count;
- svn_fs_dirent_t *entry;
- svn_fs_dirent_t **entries;
+ dirent_t *entry;
+ dirent_t **entries;
/* resolve the reference to the entries array */
svn_temp_deserializer__resolve(buffer, (void **)&dir_data->entries);
@@ -314,10 +313,9 @@ deserialize_dir(void *buffer, dir_data_t
/* pointer fixup */
svn_temp_deserializer__resolve(entry, (void **)&entry->name);
- svn_fs_x__id_deserialize(entry, (svn_fs_id_t **)&entry->id, pool);
/* add the entry to the hash */
- APR_ARRAY_PUSH(result, svn_fs_dirent_t *) = entry;
+ APR_ARRAY_PUSH(result, dirent_t *) = entry;
}
/* return the now complete hash */
@@ -338,8 +336,6 @@ svn_fs_x__noderev_serialize(svn_temp_ser
sizeof(*noderev));
/* serialize sub-structures */
- svn_fs_x__id_serialize(context, &noderev->id);
- svn_fs_x__id_serialize(context, &noderev->predecessor_id);
serialize_representation(context, &noderev->prop_rep);
serialize_representation(context, &noderev->data_rep);
@@ -369,10 +365,6 @@ svn_fs_x__noderev_deserialize(void *buff
return;
/* fixup of sub-structures */
- svn_fs_x__id_deserialize(noderev, (svn_fs_id_t **)&noderev->id, pool);
- svn_fs_x__id_deserialize(noderev,
- (svn_fs_id_t **)&noderev->predecessor_id,
- pool);
svn_temp_deserializer__resolve(noderev, (void **)&noderev->prop_rep);
svn_temp_deserializer__resolve(noderev, (void **)&noderev->data_rep);
@@ -646,47 +638,6 @@ svn_fs_x__deserialize_properties(void **
return SVN_NO_ERROR;
}
-svn_error_t *
-svn_fs_x__serialize_id(void **data,
- apr_size_t *data_len,
- void *in,
- apr_pool_t *pool)
-{
- const svn_fs_id_t *id = in;
- svn_stringbuf_t *serialized;
-
- /* create an (empty) serialization context with plenty of buffer space */
- svn_temp_serializer__context_t *context =
- svn_temp_serializer__init(NULL, 0, 250, pool);
-
- /* serialize the id */
- svn_fs_x__id_serialize(context, &id);
-
- /* return serialized data */
- serialized = svn_temp_serializer__get(context);
- *data = serialized->data;
- *data_len = serialized->len;
-
- return SVN_NO_ERROR;
-}
-
-svn_error_t *
-svn_fs_x__deserialize_id(void **out,
- void *data,
- apr_size_t data_len,
- apr_pool_t *pool)
-{
- /* Copy the _full_ buffer as it also contains the sub-structures. */
- svn_fs_id_t *id = (svn_fs_id_t *)data;
-
- /* fixup of all pointers etc. */
- svn_fs_x__id_deserialize(id, &id, pool);
-
- /* done */
- *out = id;
- return SVN_NO_ERROR;
-}
-
/** Caching node_revision_t objects. **/
svn_error_t *
@@ -800,7 +751,7 @@ svn_fs_x__get_sharded_offset(void **out,
* the number of valid entries in ENTRIES.
*/
static apr_size_t
-find_entry(svn_fs_dirent_t **entries,
+find_entry(dirent_t **entries,
const char *name,
apr_size_t count,
svn_boolean_t *found)
@@ -812,7 +763,7 @@ find_entry(svn_fs_dirent_t **entries,
for (middle = upper / 2; lower < upper; middle = (upper + lower) / 2)
{
- const svn_fs_dirent_t *entry =
+ const dirent_t *entry =
svn_temp_deserializer__ptr(entries, (const void *const *)&entries[middle]);
const char* entry_name =
svn_temp_deserializer__ptr(entry, (const void *const *)&entry->name);
@@ -828,7 +779,7 @@ find_entry(svn_fs_dirent_t **entries,
*found = FALSE;
if (lower < count)
{
- const svn_fs_dirent_t *entry =
+ const dirent_t *entry =
svn_temp_deserializer__ptr(entries, (const void *const *)&entries[lower]);
const char* entry_name =
svn_temp_deserializer__ptr(entry, (const void *const *)&entry->name);
@@ -852,7 +803,7 @@ svn_fs_x__extract_dir_entry(void **out,
svn_boolean_t found;
/* resolve the reference to the entries array */
- const svn_fs_dirent_t * const *entries =
+ const dirent_t * const *entries =
svn_temp_deserializer__ptr(data, (const void *const *)&dir_data->entries);
/* resolve the reference to the lengths array */
@@ -860,7 +811,7 @@ svn_fs_x__extract_dir_entry(void **out,
svn_temp_deserializer__ptr(data, (const void *const *)&dir_data->lengths);
/* binary search for the desired entry by name */
- apr_size_t pos = find_entry((svn_fs_dirent_t **)entries,
+ apr_size_t pos = find_entry((dirent_t **)entries,
name,
dir_data->count,
&found);
@@ -869,7 +820,7 @@ svn_fs_x__extract_dir_entry(void **out,
*out = NULL;
if (found)
{
- const svn_fs_dirent_t *source =
+ const dirent_t *source =
svn_temp_deserializer__ptr(entries, (const void *const *)&entries[pos]);
/* Entries have been serialized one-by-one, each time including all
@@ -880,13 +831,11 @@ svn_fs_x__extract_dir_entry(void **out,
apr_size_t size = lengths[pos];
/* copy & deserialize the entry */
- svn_fs_dirent_t *new_entry = apr_palloc(pool, size);
+ dirent_t *new_entry = apr_palloc(pool, size);
memcpy(new_entry, source, size);
svn_temp_deserializer__resolve(new_entry, (void **)&new_entry->name);
- svn_fs_x__id_deserialize(new_entry, (svn_fs_id_t **)&new_entry->id,
- pool);
- *(svn_fs_dirent_t **)out = new_entry;
+ *(dirent_t **)out = new_entry;
}
return SVN_NO_ERROR;
@@ -905,7 +854,7 @@ slowly_replace_dir_entry(void **data,
dir_data_t *dir_data = (dir_data_t *)*data;
apr_array_header_t *dir;
int idx = -1;
- svn_fs_dirent_t *entry;
+ dirent_t *entry;
SVN_ERR(svn_fs_x__deserialize_dir_entries((void **)&dir,
*data,
@@ -919,7 +868,7 @@ slowly_replace_dir_entry(void **data,
{
/* Replace ENTRY with / insert the NEW_ENTRY */
if (entry)
- APR_ARRAY_IDX(dir, idx, svn_fs_dirent_t *) = replace_baton->new_entry;
+ APR_ARRAY_IDX(dir, idx, dirent_t *) = replace_baton->new_entry;
else
svn_sort__array_insert(dir, &replace_baton->new_entry, idx);
}
@@ -942,7 +891,7 @@ svn_fs_x__replace_dir_entry(void **data,
replace_baton_t *replace_baton = (replace_baton_t *)baton;
dir_data_t *dir_data = (dir_data_t *)*data;
svn_boolean_t found;
- svn_fs_dirent_t **entries;
+ dirent_t **entries;
apr_uint32_t *lengths;
apr_uint32_t length;
apr_size_t pos;
@@ -956,7 +905,7 @@ svn_fs_x__replace_dir_entry(void **data,
return slowly_replace_dir_entry(data, data_len, baton, pool);
/* resolve the reference to the entries array */
- entries = (svn_fs_dirent_t **)
+ entries = (dirent_t **)
svn_temp_deserializer__ptr((const char *)dir_data,
(const void *const *)&dir_data->entries);
@@ -1085,10 +1034,8 @@ serialize_change(svn_temp_serializer__co
sizeof(*change));
/* serialize sub-structures */
- svn_fs_x__id_serialize(context, &change->info.node_rev_id);
-
svn_temp_serializer__add_string(context, &change->path.data);
- svn_temp_serializer__add_string(context, &change->info.copyfrom_path);
+ svn_temp_serializer__add_string(context, &change->copyfrom_path);
/* return to the caller's nesting level */
svn_temp_serializer__pop(context);
@@ -1112,12 +1059,8 @@ deserialize_change(void *buffer,
return;
/* fix-up of sub-structures */
- svn_fs_x__id_deserialize(change,
- (svn_fs_id_t **)&change->info.node_rev_id,
- pool);
-
svn_temp_deserializer__resolve(change, (void **)&change->path.data);
- svn_temp_deserializer__resolve(change, (void **)&change->info.copyfrom_path);
+ svn_temp_deserializer__resolve(change, (void **)&change->copyfrom_path);
}
/* Auxiliary structure representing the content of a change_t array.
Modified: subversion/trunk/subversion/libsvn_fs_x/temp_serializer.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/temp_serializer.h?rev=1649012&r1=1649011&r2=1649012&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/temp_serializer.h (original)
+++ subversion/trunk/subversion/libsvn_fs_x/temp_serializer.h Fri Jan 2 12:43:42 2015
@@ -23,6 +23,7 @@
#ifndef SVN_LIBSVN_FS__TEMP_SERIALIZER_H
#define SVN_LIBSVN_FS__TEMP_SERIALIZER_H
+#include "private/svn_temp_serializer.h"
#include "fs.h"
/**
@@ -146,24 +147,6 @@ svn_fs_x__deserialize_properties(void **
apr_pool_t *pool);
/**
- * Implements #svn_cache__serialize_func_t for #svn_fs_id_t
- */
-svn_error_t *
-svn_fs_x__serialize_id(void **data,
- apr_size_t *data_len,
- void *in,
- apr_pool_t *pool);
-
-/**
- * Implements #svn_cache__deserialize_func_t for #svn_fs_id_t
- */
-svn_error_t *
-svn_fs_x__deserialize_id(void **out,
- void *data,
- apr_size_t data_len,
- apr_pool_t *pool);
-
-/**
* Implements #svn_cache__serialize_func_t for #node_revision_t
*/
svn_error_t *
@@ -212,7 +195,7 @@ svn_fs_x__get_sharded_offset(void **out,
/**
* Implements #svn_cache__partial_getter_func_t for a single
- * #svn_fs_dirent_t within a serialized directory contents hash,
+ * #dirent_t within a serialized directory contents hash,
* identified by its name (const char @a *baton).
*/
svn_error_t *
@@ -234,12 +217,12 @@ typedef struct replace_baton_t
const char *name;
/** directory entry to insert instead */
- svn_fs_dirent_t *new_entry;
+ dirent_t *new_entry;
} replace_baton_t;
/**
* Implements #svn_cache__partial_setter_func_t for a single
- * #svn_fs_dirent_t within a serialized directory contents hash,
+ * #dirent_t within a serialized directory contents hash,
* identified by its name in the #replace_baton_t in @a baton.
*/
svn_error_t *