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 2013/07/23 22:23:26 UTC
svn commit: r1506257 - in
/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs:
cached_data.c fs.h id.c id.h low_level.c rep-cache.c transaction.c tree.c
Author: stefan2
Date: Tue Jul 23 20:23:26 2013
New Revision: 1506257
URL: http://svn.apache.org/r1506257
Log:
On the fsfs-improvements branch: Introduce preliminary versions
of a few more FSFS ID API functions that can be used as an almost
perfect syntactically stand-in for the final interfaces. Use them
wherever possible to minimize the code churn once we switch to
the final API.
* subversion/libsvn_fs_fs/id.h
(svn_fs_fs__id_part_is_root,
svn_fs_fs__id_part_eq,
svn_fs_fs__id_txn_used,
svn_fs_fs__id_txn_reset): declare ID API functions with a
preliminary signature
* subversion/libsvn_fs_fs/id.c
(svn_fs_fs__id_part_is_root,
svn_fs_fs__id_part_eq,
svn_fs_fs__id_txn_used,
svn_fs_fs__id_txn_reset): implement them
* subversion/libsvn_fs_fs/fs.h
(): add #include to make the ID API available throughout FSFS
* subversion/libsvn_fs_fs/cached_data.c
(open_and_seek_representation,
svn_fs_fs__rep_chain_length,
build_rep_list,
get_dir_contents,
svn_fs_fs__get_proplist): call new API functions
* subversion/libsvn_fs_fs/low_level.c
(svn_fs_fs__parse_representation,
svn_fs_fs__unparse_representation): ditto
* subversion/libsvn_fs_fs/rep-cache.c
(svn_fs_fs__walk_rep_reference,
svn_fs_fs__get_rep_reference): same
* subversion/libsvn_fs_fs/transaction.c
(get_shared_txn,
free_shared_txn,
get_txn_proplist,
is_txn_rep,
reset_txn_in_rep): and here
* subversion/libsvn_fs_fs/tree.c
(get_copy_inheritance,
make_path_mutable,
merge): and finally here
(make_txn_root): reformat signature w/o functional change
Modified:
subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/cached_data.c
subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs.h
subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/id.c
subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/id.h
subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/low_level.c
subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/rep-cache.c
subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/transaction.c
subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/tree.c
Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/cached_data.c?rev=1506257&r1=1506256&r2=1506257&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/cached_data.c Tue Jul 23 20:23:26 2013
@@ -222,7 +222,7 @@ open_and_seek_representation(apr_file_t
representation_t *rep,
apr_pool_t *pool)
{
- if (! rep->txn_id)
+ if (! svn_fs_fs__id_txn_used(&rep->txn_id))
return open_and_seek_revision(file_p, fs, rep->revision, rep->offset,
pool);
else
@@ -758,7 +758,7 @@ svn_fs_fs__rep_chain_length(int *chain_l
base_rep.revision = header->base_revision;
base_rep.offset = header->base_offset;
base_rep.size = header->base_length;
- base_rep.txn_id = NULL;
+ svn_fs_fs__id_txn_reset(&base_rep.txn_id);
is_delta = header->type == svn_fs_fs__rep_delta;
++count;
@@ -1085,7 +1085,7 @@ build_rep_list(apr_array_header_t **list
rep.revision = rep_header->base_revision;
rep.offset = rep_header->base_offset;
rep.size = rep_header->base_length;
- rep.txn_id = NULL;
+ svn_fs_fs__id_txn_reset(&rep.txn_id);
rs = NULL;
}
@@ -1711,7 +1711,7 @@ get_dir_contents(apr_hash_t *entries,
{
svn_stream_t *contents;
- if (noderev->data_rep && noderev->data_rep->txn_id)
+ if (noderev->data_rep && svn_fs_fs__id_txn_used(&noderev->data_rep->txn_id))
{
const char *filename
= svn_fs_fs__path_txn_node_children(fs, noderev->id, pool);
@@ -1925,7 +1925,7 @@ svn_fs_fs__get_proplist(apr_hash_t **pro
apr_hash_t *proplist;
svn_stream_t *stream;
- if (noderev->prop_rep && noderev->prop_rep->txn_id)
+ if (noderev->prop_rep && svn_fs_fs__id_txn_used(&noderev->prop_rep->txn_id))
{
const char *filename
= svn_fs_fs__path_txn_node_props(fs, noderev->id, pool);
Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs.h?rev=1506257&r1=1506256&r2=1506257&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs.h (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/fs.h Tue Jul 23 20:23:26 2013
@@ -36,6 +36,8 @@
#include "private/svn_mutex.h"
#include "private/svn_named_atomic.h"
+#include "id.h"
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/id.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/id.c?rev=1506257&r1=1506256&r2=1506257&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/id.c (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/id.c Tue Jul 23 20:23:26 2013
@@ -38,6 +38,34 @@ typedef struct id_private_t {
} id_private_t;
+
+/* Operations on ID parts */
+
+svn_boolean_t
+svn_fs_fs__id_part_is_root(const char * const* part)
+{
+ return strcmp(*part, "0") == 0;
+}
+
+svn_boolean_t
+svn_fs_fs__id_part_eq(const char *lhs,
+ const char *rhs)
+{
+ return strcmp(lhs, rhs) == 0;
+}
+
+svn_boolean_t
+svn_fs_fs__id_txn_used(const char * const *txn_id)
+{
+ return *txn_id != NULL;
+}
+
+void
+svn_fs_fs__id_txn_reset(const char **txn_id)
+{
+ *txn_id = NULL;
+}
+
const char *
svn_fs_fs__id_txn_unparse(const char * const *txn_id,
apr_pool_t *pool)
Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/id.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/id.h?rev=1506257&r1=1506256&r2=1506257&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/id.h (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/id.h Tue Jul 23 20:23:26 2013
@@ -29,6 +29,22 @@
extern "C" {
#endif /* __cplusplus */
+/*** 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_fs__id_part_is_root(const char * const *part);
+
+/* Return TRUE, if all element values of *LHS and *RHS match. */
+svn_boolean_t svn_fs_fs__id_part_eq(const char * lhs,
+ const char * rhs);
+
+/* Return TRUE, if TXN_ID is used, i.e. doesn't contain just the defaults. */
+svn_boolean_t svn_fs_fs__id_txn_used(const char * const *txn_id);
+
+/* Reset TXN_ID to the defaults. */
+void svn_fs_fs__id_txn_reset(const char **txn_id);
+
/* Convert the transaction id in *TXN_ID into a textual representation
* allocated in POOL. */
const char *svn_fs_fs__id_txn_unparse(const char * const *txn_id,
Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/low_level.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/low_level.c?rev=1506257&r1=1506256&r2=1506257&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/low_level.c (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/low_level.c Tue Jul 23 20:23:26 2013
@@ -537,6 +537,9 @@ svn_fs_fs__parse_representation(represen
rep->revision = SVN_STR_TO_REV(str);
+ /* initialize transaction info (never stored) */
+ svn_fs_fs__id_txn_reset(&rep->txn_id);
+
/* while in transactions, it is legal to simply write "-1" */
str = svn_cstring_tokenize(" ", &string);
if (str == NULL)
@@ -791,7 +794,7 @@ svn_fs_fs__unparse_representation(repres
svn_boolean_t may_be_corrupt,
apr_pool_t *pool)
{
- if (rep->txn_id && mutable_rep_truncated)
+ if (svn_fs_fs__id_txn_used(&rep->txn_id) && mutable_rep_truncated)
return svn_stringbuf_ncreate("-1", 2, pool);
#define DISPLAY_MAYBE_NULL_CHECKSUM(checksum) \
Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/rep-cache.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/rep-cache.c?rev=1506257&r1=1506256&r2=1506257&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/rep-cache.c (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/rep-cache.c Tue Jul 23 20:23:26 2013
@@ -193,6 +193,7 @@ svn_fs_fs__walk_rep_reference(svn_fs_t *
/* Construct a representation_t. */
rep = apr_pcalloc(iterpool, sizeof(*rep));
+ svn_fs_fs__id_txn_reset(&rep->txn_id);
sha1_digest = svn_sqlite__column_text(stmt, 0, iterpool);
err = svn_checksum_parse_hex(&rep->sha1_checksum,
svn_checksum_sha1, sha1_digest,
@@ -250,6 +251,7 @@ svn_fs_fs__get_rep_reference(representat
if (have_row)
{
*rep = apr_pcalloc(pool, sizeof(**rep));
+ svn_fs_fs__id_txn_reset(&(*rep)->txn_id);
(*rep)->sha1_checksum = svn_checksum_dup(checksum, pool);
(*rep)->revision = svn_sqlite__column_revnum(stmt, 0);
(*rep)->offset = svn_sqlite__column_int64(stmt, 1);
Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/transaction.c?rev=1506257&r1=1506256&r2=1506257&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/transaction.c Tue Jul 23 20:23:26 2013
@@ -154,7 +154,7 @@ get_shared_txn(svn_fs_t *fs,
fs_fs_shared_txn_data_t *txn;
for (txn = ffsd->txns; txn; txn = txn->next)
- if (strcmp(txn->txn_id, txn_id) == 0)
+ if (svn_fs_fs__id_part_eq(txn->txn_id, txn_id))
break;
if (txn || !create_new)
@@ -200,7 +200,7 @@ free_shared_txn(svn_fs_t *fs, const char
fs_fs_shared_txn_data_t *txn, *prev = NULL;
for (txn = ffsd->txns; txn; prev = txn, txn = txn->next)
- if (strcmp(txn->txn_id, txn_id) == 0)
+ if (svn_fs_fs__id_part_eq(txn->txn_id, txn_id))
break;
if (!txn)
@@ -1092,7 +1092,7 @@ get_txn_proplist(apr_hash_t *proplist,
/* Check for issue #3696. (When we find and fix the cause, we can change
* this to an assertion.) */
- if (txn_id == NULL)
+ if (!txn_id || !svn_fs_fs__id_txn_used(&txn_id))
return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
_("Internal error: a null transaction id was "
"passed to get_txn_proplist()"));
@@ -1389,7 +1389,7 @@ svn_fs_fs__abort_txn(svn_fs_txn_t *txn,
static svn_boolean_t
is_txn_rep(const representation_t *rep)
{
- return rep->txn_id != NULL;
+ return svn_fs_fs__id_txn_used(&rep->txn_id);
}
/* Mark the TXN_ID member of REP as "unused".
@@ -1397,7 +1397,7 @@ is_txn_rep(const representation_t *rep)
static void
reset_txn_in_rep(representation_t *rep)
{
- rep->txn_id = NULL;
+ svn_fs_fs__id_txn_reset(&rep->txn_id);
}
svn_error_t *
Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/tree.c?rev=1506257&r1=1506256&r2=1506257&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/tree.c Tue Jul 23 20:23:26 2013
@@ -125,8 +125,10 @@ static svn_fs_root_t *make_revision_root
apr_pool_t *pool);
static svn_error_t *make_txn_root(svn_fs_root_t **root_p,
- svn_fs_t *fs, const char *txn,
- svn_revnum_t base_rev, apr_uint32_t flags,
+ svn_fs_t *fs,
+ const char *txn,
+ svn_revnum_t base_rev,
+ apr_uint32_t flags,
apr_pool_t *pool);
@@ -833,7 +835,7 @@ get_copy_inheritance(copy_id_inherit_t *
the same, then the child is already on the same branch as the
parent, and should use the same mutability copy ID that the
parent will use. */
- if (svn_fs_fs__key_compare(child_copy_id, parent_copy_id) == 0)
+ if (svn_fs_fs__id_part_eq(child_copy_id, parent_copy_id))
return SVN_NO_ERROR;
/* If the child is on the same branch that the parent is on, the
@@ -1175,8 +1177,8 @@ make_path_mutable(svn_fs_root_t *root,
child_id = svn_fs_fs__dag_get_id(parent_path->node);
copyroot_id = svn_fs_fs__dag_get_id(copyroot_node);
- if (strcmp(svn_fs_fs__id_node_id(child_id),
- svn_fs_fs__id_node_id(copyroot_id)) != 0)
+ if (!svn_fs_fs__id_part_eq(svn_fs_fs__id_node_id(child_id),
+ svn_fs_fs__id_node_id(copyroot_id)))
is_parent_copyroot = TRUE;
/* Now make this node mutable. */
@@ -1863,14 +1865,14 @@ merge(svn_stringbuf_t *conflict_p,
/* If either SOURCE-ENTRY or TARGET-ENTRY is not a direct
modification of ANCESTOR-ENTRY, declare a conflict. */
- if (strcmp(svn_fs_fs__id_node_id(s_entry->id),
- svn_fs_fs__id_node_id(a_entry->id)) != 0
- || strcmp(svn_fs_fs__id_copy_id(s_entry->id),
- svn_fs_fs__id_copy_id(a_entry->id)) != 0
- || strcmp(svn_fs_fs__id_node_id(t_entry->id),
- svn_fs_fs__id_node_id(a_entry->id)) != 0
- || strcmp(svn_fs_fs__id_copy_id(t_entry->id),
- svn_fs_fs__id_copy_id(a_entry->id)) != 0)
+ if (!svn_fs_fs__id_part_eq(svn_fs_fs__id_node_id(s_entry->id),
+ svn_fs_fs__id_node_id(a_entry->id))
+ || !svn_fs_fs__id_part_eq(svn_fs_fs__id_copy_id(s_entry->id),
+ svn_fs_fs__id_copy_id(a_entry->id))
+ || !svn_fs_fs__id_part_eq(svn_fs_fs__id_node_id(t_entry->id),
+ svn_fs_fs__id_node_id(a_entry->id))
+ || !svn_fs_fs__id_part_eq(svn_fs_fs__id_copy_id(t_entry->id),
+ svn_fs_fs__id_copy_id(a_entry->id)))
return conflict_err(conflict_p,
svn_fspath__join(target_path,
a_entry->name,