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/06/24 14:53:06 UTC
svn commit: r1605071 - in /subversion/trunk/subversion/libsvn_fs_fs:
cached_data.c low_level.c low_level.h transaction.c
Author: stefan2
Date: Tue Jun 24 12:53:06 2014
New Revision: 1605071
URL: http://svn.apache.org/r1605071
Log:
Switch the remainder of the FSFS low-level interal API to the two-pool
paradigm.
* subversion/libsvn_fs_fs/low_level.h
(svn_fs_fs__parse_representation,
svn_fs_fs__unparse_representation): These functions create internal
temporary objects.
* subversion/libsvn_fs_fs/low_level.c
(svn_fs_fs__parse_representation): Use the new scratch pool for parsing
checksums.
(read_rep_offsets): Switch to two-pool paradigm as well and update it
as a caller of the above.
(svn_fs_fs__read_noderev): Update caller.
(svn_fs_fs__unparse_representation): Allocate temporary strings in scratch
pool.
(svn_fs_fs__write_noderev): Update caller.
* subversion/libsvn_fs_fs/cached_data.c
(create_rep_state): Update caller.
* subversion/libsvn_fs_fs/transaction.c
(store_sha1_rep_mapping,
get_shared_rep): Update callers.
Modified:
subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
subversion/trunk/subversion/libsvn_fs_fs/low_level.c
subversion/trunk/subversion/libsvn_fs_fs/low_level.h
subversion/trunk/subversion/libsvn_fs_fs/transaction.c
Modified: subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/cached_data.c?rev=1605071&r1=1605070&r2=1605071&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Tue Jun 24 12:53:06 2014
@@ -891,6 +891,7 @@ create_rep_state(rep_state_t **rep_state
if (err && err->apr_err == SVN_ERR_FS_CORRUPT)
{
fs_fs_data_t *ffd = fs->fsap_data;
+ const char *rep_str;
/* ### This always returns "-1" for transaction reps, because
### this particular bit of code doesn't know if the rep is
@@ -899,12 +900,14 @@ create_rep_state(rep_state_t **rep_state
### from the protorev file, though, so this is probably OK.
### And anyone going to debug corruption errors is probably
### going to jump straight to this comment anyway! */
+ rep_str = rep
+ ? svn_fs_fs__unparse_representation
+ (rep, ffd->format, TRUE, scratch_pool, scratch_pool)->data
+ : "(null)";
+
return svn_error_createf(SVN_ERR_FS_CORRUPT, err,
"Corrupt representation '%s'",
- rep
- ? svn_fs_fs__unparse_representation
- (rep, ffd->format, TRUE, scratch_pool)->data
- : "(null)");
+ rep_str);
}
/* ### Call representation_string() ? */
return svn_error_trace(err);
Modified: subversion/trunk/subversion/libsvn_fs_fs/low_level.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/low_level.c?rev=1605071&r1=1605070&r2=1605071&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/low_level.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/low_level.c Tue Jun 24 12:53:06 2014
@@ -629,7 +629,8 @@ read_header_block(apr_hash_t **headers,
svn_error_t *
svn_fs_fs__parse_representation(representation_t **rep_p,
svn_stringbuf_t *text,
- apr_pool_t *pool)
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
representation_t *rep;
char *str;
@@ -638,7 +639,7 @@ svn_fs_fs__parse_representation(represen
svn_checksum_t *checksum;
const char *end;
- rep = apr_pcalloc(pool, sizeof(*rep));
+ rep = apr_pcalloc(result_pool, sizeof(*rep));
*rep_p = rep;
str = svn_cstring_tokenize(" ", &string);
@@ -687,7 +688,8 @@ svn_fs_fs__parse_representation(represen
return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
_("Malformed text representation offset line in node-rev"));
- SVN_ERR(svn_checksum_parse_hex(&checksum, svn_checksum_md5, str, pool));
+ SVN_ERR(svn_checksum_parse_hex(&checksum, svn_checksum_md5, str,
+ scratch_pool));
memcpy(rep->md5_digest, checksum->digest, sizeof(rep->md5_digest));
/* The remaining fields are only used for formats >= 4, so check that. */
@@ -700,7 +702,8 @@ svn_fs_fs__parse_representation(represen
return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
_("Malformed text representation offset line in node-rev"));
- SVN_ERR(svn_checksum_parse_hex(&checksum, svn_checksum_sha1, str, pool));
+ SVN_ERR(svn_checksum_parse_hex(&checksum, svn_checksum_sha1, str,
+ scratch_pool));
rep->has_sha1 = checksum != NULL;
memcpy(rep->sha1_digest, checksum->digest, sizeof(rep->sha1_digest));
@@ -733,17 +736,22 @@ static svn_error_t *
read_rep_offsets(representation_t **rep_p,
char *string,
const svn_fs_id_t *noderev_id,
- apr_pool_t *pool)
+ 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, pool),
- pool);
+ svn_stringbuf_create_wrap(string,
+ scratch_pool),
+ result_pool,
+ scratch_pool);
if (err)
{
- const svn_string_t *id_unparsed = svn_fs_fs__id_unparse(noderev_id, pool);
+ const svn_string_t *id_unparsed;
const char *where;
- where = apr_psprintf(pool,
+
+ 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)");
@@ -812,7 +820,7 @@ svn_fs_fs__read_noderev(node_revision_t
if (value)
{
SVN_ERR(read_rep_offsets(&noderev->prop_rep, value,
- noderev->id, result_pool));
+ noderev->id, result_pool, scratch_pool));
}
/* Get the data location. */
@@ -820,7 +828,7 @@ svn_fs_fs__read_noderev(node_revision_t
if (value)
{
SVN_ERR(read_rep_offsets(&noderev->data_rep, value,
- noderev->id, result_pool));
+ noderev->id, result_pool, scratch_pool));
}
/* Get the created path. */
@@ -935,30 +943,34 @@ svn_stringbuf_t *
svn_fs_fs__unparse_representation(representation_t *rep,
int format,
svn_boolean_t mutable_rep_truncated,
- apr_pool_t *pool)
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
char buffer[SVN_INT64_BUFFER_SIZE];
if (svn_fs_fs__id_txn_used(&rep->txn_id) && mutable_rep_truncated)
- return svn_stringbuf_ncreate("-1", 2, pool);
+ return svn_stringbuf_ncreate("-1", 2, result_pool);
if (format < SVN_FS_FS__MIN_REP_SHARING_FORMAT || !rep->has_sha1)
return svn_stringbuf_createf
- (pool, "%ld %" APR_UINT64_T_FMT " %" SVN_FILESIZE_T_FMT
+ (result_pool, "%ld %" APR_UINT64_T_FMT " %" SVN_FILESIZE_T_FMT
" %" SVN_FILESIZE_T_FMT " %s",
rep->revision, rep->item_index, rep->size,
rep->expanded_size,
- format_digest(rep->md5_digest, svn_checksum_md5, FALSE, pool));
+ format_digest(rep->md5_digest, svn_checksum_md5, FALSE,
+ scratch_pool));
svn__ui64tobase36(buffer, rep->uniquifier.number);
return svn_stringbuf_createf
- (pool, "%ld %" APR_UINT64_T_FMT " %" SVN_FILESIZE_T_FMT
+ (result_pool, "%ld %" APR_UINT64_T_FMT " %" SVN_FILESIZE_T_FMT
" %" SVN_FILESIZE_T_FMT " %s %s %s/_%s",
rep->revision, rep->item_index, rep->size,
rep->expanded_size,
- format_digest(rep->md5_digest, svn_checksum_md5, FALSE, pool),
+ format_digest(rep->md5_digest, svn_checksum_md5,
+ FALSE, scratch_pool),
format_digest(rep->sha1_digest, svn_checksum_sha1,
- !rep->has_sha1, pool),
- svn_fs_fs__id_txn_unparse(&rep->uniquifier.noderev_txn_id, pool),
+ !rep->has_sha1, scratch_pool),
+ svn_fs_fs__id_txn_unparse(&rep->uniquifier.noderev_txn_id,
+ scratch_pool),
buffer);
}
@@ -992,13 +1004,13 @@ svn_fs_fs__write_noderev(svn_stream_t *o
(noderev->data_rep,
format,
noderev->kind == svn_node_dir,
- scratch_pool)->data));
+ 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)->data));
+ TRUE, scratch_pool, scratch_pool)->data));
SVN_ERR(svn_stream_printf(outfile, scratch_pool, HEADER_CPATH ": %s\n",
noderev->created_path));
Modified: subversion/trunk/subversion/libsvn_fs_fs/low_level.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/low_level.h?rev=1605071&r1=1605070&r2=1605071&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/low_level.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/low_level.h Tue Jun 24 12:53:06 2014
@@ -142,23 +142,26 @@ svn_fs_fs__write_noderev(svn_stream_t *o
apr_pool_t *scratch_pool);
/* Parse the description of a representation from TEXT and store it
- into *REP_P. Allocate *REP_P in POOL. */
+ into *REP_P. TEXT will be invalidated by this call. Allocate *REP_P in
+ RESULT_POOL and use SCRATCH_POOL for temporaries. */
svn_error_t *
svn_fs_fs__parse_representation(representation_t **rep_p,
svn_stringbuf_t *text,
- apr_pool_t *pool);
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
/* Return a formatted string, compatible with filesystem format FORMAT,
that represents the location of representation REP. If
MUTABLE_REP_TRUNCATED is given, the rep is for props or dir contents,
and only a "-1" revision number will be given for a mutable rep.
If MAY_BE_CORRUPT is true, guard for NULL when constructing the string.
- Perform the allocation from POOL. */
+ Allocate the result in RESULT_POOL and temporaries in SCRATCH_POOL. */
svn_stringbuf_t *
svn_fs_fs__unparse_representation(representation_t *rep,
int format,
svn_boolean_t mutable_rep_truncated,
- apr_pool_t *pool);
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
/* This type enumerates all forms of representations that we support. */
typedef enum svn_fs_fs__rep_type_t
Modified: subversion/trunk/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/transaction.c?rev=1605071&r1=1605070&r2=1605071&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/transaction.c Tue Jun 24 12:53:06 2014
@@ -565,7 +565,7 @@ store_sha1_rep_mapping(svn_fs_t *fs,
= svn_fs_fs__unparse_representation(noderev->data_rep,
ffd->format,
(noderev->kind == svn_node_dir),
- scratch_pool);
+ scratch_pool, scratch_pool);
SVN_ERR(svn_io_file_open(&rep_file, file_name,
APR_WRITE | APR_CREATE | APR_TRUNCATE
| APR_BUFFERED, APR_OS_DEFAULT, scratch_pool));
@@ -2213,7 +2213,7 @@ get_shared_rep(representation_t **old_re
SVN_ERR(svn_stringbuf_from_file2(&rep_string, file_name,
scratch_pool));
SVN_ERR(svn_fs_fs__parse_representation(old_rep, rep_string,
- result_pool));
+ result_pool, scratch_pool));
}
}