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 2014/12/16 11:57:45 UTC
svn commit: r1645907 - in
/subversion/branches/fsx-id/subversion/libsvn_fs_x: fs.h fs_x.c low_level.c
noderevs.c transaction.c
Author: stefan2
Date: Tue Dec 16 10:57:45 2014
New Revision: 1645907
URL: http://svn.apache.org/r1645907
Log:
In the fsx-id branch:
Store the ID all 3 separate parts in the noderev struct as well as on disk.
Keep the 'svn_fs_t *id' in the struct for now until we replaced most code
that accesses it. Be sure to write the parts whenever we write the full ID.
* subversion/libsvn_fs_x/fs.h
(node_revision_t): Add the 3 ID parts as separate members.
* subversion/libsvn_fs_x/low_level.c
(HEADER_NODE,
HEADER_COPY): New on-disk element markers for the respective ID parts;
HEADER_ID will be reused for the noderev ID.
(read_id_part): New parser utility.
(svn_fs_x__read_noderev): Read separate ID parts; combine them to a full
ID afterwards.
(svn_fs_x__write_noderev): Write the separate ID parts, derived from the
full ID.
* subversion/libsvn_fs_x/fs_x.c
(write_revision_zero): Update r0 template, particularly the root node.
* subversion/libsvn_fs_x/noderevs.c
(svn_fs_x__noderevs_get): Initialize the ID parts as well.
* subversion/libsvn_fs_x/transaction.c
(create_new_txn_noderev_from_rev): Only the noderev ID changed.
(svn_fs_x__create_node,
svn_fs_x__create_successor): Initialize the ID parts as well.
(write_final_rev): Set and work with the ID parts in the noderev struct
instead of using local variables.
Modified:
subversion/branches/fsx-id/subversion/libsvn_fs_x/fs.h
subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_x.c
subversion/branches/fsx-id/subversion/libsvn_fs_x/low_level.c
subversion/branches/fsx-id/subversion/libsvn_fs_x/noderevs.c
subversion/branches/fsx-id/subversion/libsvn_fs_x/transaction.c
Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/fs.h?rev=1645907&r1=1645906&r2=1645907&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/fs.h (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/fs.h Tue Dec 16 10:57:45 2014
@@ -493,6 +493,15 @@ typedef struct node_revision_t
for this node revision */
const svn_fs_id_t *predecessor_id;
+ /* The ID of this noderev */
+ svn_fs_x__noderev_id_t noderev_id;
+
+ /* Identifier of the node that this noderev belongs to. */
+ svn_fs_x__id_part_t node_id;
+
+ /* Copy identifier of this line of history. */
+ svn_fs_x__id_part_t copy_id;
+
/* If this node-rev is a copy, where was it copied from? */
const char *copyfrom_path;
svn_revnum_t copyfrom_rev;
Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_x.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_x.c?rev=1645907&r1=1645906&r2=1645907&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_x.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/fs_x.c Tue Dec 16 10:57:45 2014
@@ -854,14 +854,16 @@ write_revision_zero(svn_fs_t *fs,
"\1\x84" /* 1 instr byte, new 4 bytes */
"\4END\n" /* 4 new bytes, E, N, D, \n */
"ENDREP\n"
- "id: 0+0.0+0.2+0\n"
+ "id: 2+0\n"
+ "node: 0+0\n"
+ "copy: 0+0\n"
"type: dir\n"
"count: 0\n"
"text: 0 3 16 4 "
"2d2977d1c96f487abe4a1e202dd03b4e\n"
"cpath: /\n"
"\n\n",
- 0x7b, subpool));
+ 0x8b, subpool));
/* Construct the index P2L contents: describe the 3 items we have.
Be sure to create them in on-disk order. */
@@ -879,7 +881,7 @@ write_revision_zero(svn_fs_t *fs,
entry = apr_pcalloc(subpool, sizeof(*entry));
entry->offset = 0x1d;
- entry->size = 0x5d;
+ entry->size = 0x6d;
entry->type = SVN_FS_X__ITEM_TYPE_NODEREV;
entry->item_count = 1;
entry->items = apr_pcalloc(subpool, sizeof(*entry->items));
@@ -888,7 +890,7 @@ write_revision_zero(svn_fs_t *fs,
APR_ARRAY_PUSH(index_entries, svn_fs_x__p2l_entry_t *) = entry;
entry = apr_pcalloc(subpool, sizeof(*entry));
- entry->offset = 0x1d + 0x5d;
+ entry->offset = 0x1d + 0x6d;
entry->size = 1;
entry->type = SVN_FS_X__ITEM_TYPE_CHANGES;
entry->item_count = 1;
Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/low_level.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/low_level.c?rev=1645907&r1=1645906&r2=1645907&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/low_level.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/low_level.c Tue Dec 16 10:57:45 2014
@@ -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"
@@ -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_part_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_part_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,20 @@ 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"));
+ /* for error messages later */
+ noderev_id = svn_hash_gets(headers, HEADER_ID);
- SVN_ERR(svn_stream_close(stream));
+ /* 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));
- SVN_ERR(svn_fs_x__id_parse(&noderev->id, value, result_pool));
- noderev_id = value; /* for error messages later */
+ noderev->id = svn_fs_x__id_create(&noderev->node_id, &noderev->copy_id,
+ &noderev->noderev_id, result_pool);
/* Read the type. */
value = svn_hash_gets(headers, HEADER_TYPE);
@@ -609,9 +627,20 @@ 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_part_unparse(svn_fs_x__id_noderev_id(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_part_unparse(svn_fs_x__id_node_id(noderev->id),
+ scratch_pool);
+ SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_NODE ": %s\n",
+ str_id->data));
+ str_id = svn_fs_x__id_part_unparse(svn_fs_x__id_copy_id(noderev->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) ?
Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/noderevs.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/noderevs.c?rev=1645907&r1=1645906&r2=1645907&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/noderevs.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/noderevs.c Tue Dec 16 10:57:45 2014
@@ -450,6 +450,10 @@ svn_fs_x__noderevs_get(node_revision_t *
SVN_ERR(get_id(&noderev->predecessor_id, container->ids,
binary_noderev->predecessor_id, pool));
+ noderev->noderev_id = *svn_fs_x__id_noderev_id(noderev->id);
+ noderev->node_id = *svn_fs_x__id_node_id(noderev->id);
+ noderev->copy_id = *svn_fs_x__id_copy_id(noderev->id);
+
if (binary_noderev->flags & NODEREV_HAS_COPYFROM)
{
noderev->copyfrom_path
Modified: subversion/branches/fsx-id/subversion/libsvn_fs_x/transaction.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-id/subversion/libsvn_fs_x/transaction.c?rev=1645907&r1=1645906&r2=1645907&view=diff
==============================================================================
--- subversion/branches/fsx-id/subversion/libsvn_fs_x/transaction.c (original)
+++ subversion/branches/fsx-id/subversion/libsvn_fs_x/transaction.c Tue Dec 16 10:57:45 2014
@@ -1176,6 +1176,7 @@ create_new_txn_noderev_from_rev(svn_fs_t
/* For the transaction root, the copyroot never changes. */
noderev->id = svn_fs_x__id_txn_create_root(txn_id, pool);
+ noderev->noderev_id = *svn_fs_x__id_noderev_id(noderev->id);
return svn_fs_x__put_node_revision(fs, noderev->id, noderev, TRUE, pool);
}
@@ -1643,6 +1644,9 @@ svn_fs_x__create_node(const svn_fs_id_t
/* Construct the ID object from all the above parts. */
id = svn_fs_x__id_txn_create(&node_id, copy_id, txn_id, number, pool);
noderev->id = id;
+ noderev->copy_id = *copy_id;
+ noderev->node_id = node_id;
+ noderev->noderev_id = *svn_fs_x__id_noderev_id(id);
SVN_ERR(svn_fs_x__put_node_revision(fs, noderev->id, noderev, FALSE, pool));
@@ -2474,6 +2478,9 @@ svn_fs_x__create_successor(const svn_fs_
id = svn_fs_x__id_txn_create(node_id, copy_id, txn_id, number, pool);
new_noderev->id = id;
+ new_noderev->noderev_id = *svn_fs_x__id_noderev_id(id);
+ new_noderev->node_id = *node_id;
+ new_noderev->copy_id = *copy_id;
if (! new_noderev->copyroot_path)
{
@@ -2850,7 +2857,7 @@ write_final_rev(const svn_fs_id_t **new_
node_revision_t *noderev;
apr_off_t my_offset;
const svn_fs_id_t *new_id;
- svn_fs_x__id_part_t node_id, copy_id, noderev_id;
+ svn_fs_x__id_part_t noderev_id;
fs_x_data_t *ffd = fs->fsap_data;
svn_fs_x__txn_id_t txn_id = svn_fs_x__id_txn_id(id);
svn_fs_x__p2l_entry_t entry;
@@ -2938,21 +2945,22 @@ write_final_rev(const svn_fs_id_t **new_
}
/* Convert our temporary ID into a permanent revision one. */
- node_id = *svn_fs_x__id_node_id(noderev->id);
- get_final_id(&node_id, rev);
- copy_id = *svn_fs_x__id_copy_id(noderev->id);
- get_final_id(©_id, rev);
- noderev_id = *svn_fs_x__id_noderev_id(noderev->id);
- get_final_id(&noderev_id, rev);
+ noderev->node_id = *svn_fs_x__id_node_id(noderev->id);
+ get_final_id(&noderev->node_id, rev);
+ noderev->copy_id = *svn_fs_x__id_copy_id(noderev->id);
+ get_final_id(&noderev->copy_id, rev);
+ noderev->noderev_id = *svn_fs_x__id_noderev_id(noderev->id);
+ get_final_id(&noderev->noderev_id, rev);
if (noderev->copyroot_rev == SVN_INVALID_REVNUM)
noderev->copyroot_rev = rev;
SVN_ERR(svn_fs_x__get_file_offset(&my_offset, file, pool));
- SVN_ERR(store_l2p_index_entry(fs, txn_id, my_offset, noderev_id.number,
- pool));
- new_id = svn_fs_x__id_create(&node_id, ©_id, &noderev_id, pool);
+ SVN_ERR(store_l2p_index_entry(fs, txn_id, my_offset,
+ noderev->noderev_id.number, pool));
+ new_id = svn_fs_x__id_create(&noderev->node_id, &noderev->copy_id,
+ &noderev->noderev_id, pool);
noderev->id = new_id;
if (ffd->rep_sharing_allowed)
@@ -3006,6 +3014,7 @@ write_final_rev(const svn_fs_id_t **new_
SVN_ERR(svn_stream_close(file_stream));
/* reference the root noderev from the log-to-phys index */
+ noderev_id = noderev->noderev_id;
noderev_id.change_set = SVN_FS_X__INVALID_CHANGE_SET;
entry.offset = my_offset;