You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by iv...@apache.org on 2015/12/11 07:57:56 UTC
svn commit: r1719269 - in /subversion/trunk/subversion: include/svn_io.h
libsvn_fs_fs/cached_data.c libsvn_fs_fs/index.c libsvn_fs_fs/pack.c
libsvn_fs_fs/transaction.c libsvn_fs_fs/util.c libsvn_fs_fs/util.h
libsvn_fs_fs/verify.c libsvn_subr/io.c
Author: ivan
Date: Fri Dec 11 06:57:56 2015
New Revision: 1719269
URL: http://svn.apache.org/viewvc?rev=1719269&view=rev
Log:
Promote libsvn_fs_fs private helper svn_fs_fs__get_file_offset() to public
libsvn_subr function svn_io_file_get_offset().
* subversion/libsvn_fs_fs/util.c
* subversion/libsvn_fs_fs/util.h
(svn_fs_fs__get_file_offset): Move/rename to ...
* subversion/include/svn_io.h
* subversion/libsvn_subr/io.c
(svn_io_file_get_offset): ... here.
* subversion/libsvn_fs_fs/cached_data.c
* subversion/libsvn_fs_fs/index.c
* subversion/libsvn_fs_fs/pack.c
* subversion/libsvn_fs_fs/transaction.c
* subversion/libsvn_fs_fs/verify.c
(get_file_offset, stream_error_create, copy_item_to_temp, copy_rep_to_temp,
copy_node_to_temp, rep_write_get_baton, rep_write_contents_close,
write_container_rep, write_container_delta_rep, write_final_rev,
write_final_changed_path_info, commit_body, expect_buffer_nul): Replace
calls to svn_fs_fs__get_file_offset() within svn_io_file_get_offset().
Modified:
subversion/trunk/subversion/include/svn_io.h
subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
subversion/trunk/subversion/libsvn_fs_fs/index.c
subversion/trunk/subversion/libsvn_fs_fs/pack.c
subversion/trunk/subversion/libsvn_fs_fs/transaction.c
subversion/trunk/subversion/libsvn_fs_fs/util.c
subversion/trunk/subversion/libsvn_fs_fs/util.h
subversion/trunk/subversion/libsvn_fs_fs/verify.c
subversion/trunk/subversion/libsvn_subr/io.c
Modified: subversion/trunk/subversion/include/svn_io.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_io.h?rev=1719269&r1=1719268&r2=1719269&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_io.h (original)
+++ subversion/trunk/subversion/include/svn_io.h Fri Dec 11 06:57:56 2015
@@ -2235,6 +2235,16 @@ svn_error_t *
svn_io_file_size_get(svn_filesize_t *filesize_p, apr_file_t *file,
apr_pool_t *pool);
+/* Fetch the current offset of @a file into @a *offset_p. Use @a pool for
+ * temporary allocations.
+ *
+ * @since New in 1.10
+ */
+svn_error_t *
+svn_io_file_get_offset(apr_off_t *offset_p,
+ apr_file_t *file,
+ apr_pool_t *pool);
+
/** Wrapper for apr_file_read(). */
svn_error_t *
svn_io_file_read(apr_file_t *file,
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=1719269&r1=1719268&r2=1719269&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Fri Dec 11 06:57:56 2015
@@ -746,15 +746,15 @@ typedef struct rep_state_t
int chunk_index; /* number of the window to read */
} rep_state_t;
-/* Simple wrapper around svn_fs_fs__get_file_offset to simplify callers. */
+/* Simple wrapper around svn_io_file_get_offset to simplify callers. */
static svn_error_t *
get_file_offset(apr_off_t *offset,
rep_state_t *rs,
apr_pool_t *pool)
{
- return svn_error_trace(svn_fs_fs__get_file_offset(offset,
- rs->sfile->rfile->file,
- pool));
+ return svn_error_trace(svn_io_file_get_offset(offset,
+ rs->sfile->rfile->file,
+ pool));
}
/* Simple wrapper around svn_io_file_aligned_seek to simplify callers. */
Modified: subversion/trunk/subversion/libsvn_fs_fs/index.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/index.c?rev=1719269&r1=1719268&r2=1719269&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/index.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/index.c Fri Dec 11 06:57:56 2015
@@ -231,7 +231,7 @@ stream_error_create(svn_fs_fs__packed_nu
apr_off_t offset;
SVN_ERR(svn_io_file_name_get(&file_name, stream->file,
stream->pool));
- SVN_ERR(svn_fs_fs__get_file_offset(&offset, stream->file, stream->pool));
+ SVN_ERR(svn_io_file_get_offset(&offset, stream->file, stream->pool));
return svn_error_createf(err, NULL, message, file_name,
apr_psprintf(stream->pool,
Modified: subversion/trunk/subversion/libsvn_fs_fs/pack.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/pack.c?rev=1719269&r1=1719268&r2=1719269&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/pack.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/pack.c Fri Dec 11 06:57:56 2015
@@ -481,7 +481,7 @@ copy_item_to_temp(pack_context_t *contex
svn_fs_fs__p2l_entry_t *new_entry
= apr_pmemdup(context->info_pool, entry, sizeof(*entry));
- SVN_ERR(svn_fs_fs__get_file_offset(&new_entry->offset, temp_file, pool));
+ SVN_ERR(svn_io_file_get_offset(&new_entry->offset, temp_file, pool));
APR_ARRAY_PUSH(entries, svn_fs_fs__p2l_entry_t *) = new_entry;
SVN_ERR(copy_file_data(context, temp_file, rev_file, entry->size, pool));
@@ -568,7 +568,7 @@ copy_rep_to_temp(pack_context_t *context
/* create a copy of ENTRY, make it point to the copy destination and
* store it in CONTEXT */
entry = apr_pmemdup(context->info_pool, entry, sizeof(*entry));
- SVN_ERR(svn_fs_fs__get_file_offset(&entry->offset, context->reps_file, pool));
+ SVN_ERR(svn_io_file_get_offset(&entry->offset, context->reps_file, pool));
add_item_rep_mapping(context, entry);
/* read & parse the representation header */
@@ -719,8 +719,8 @@ copy_node_to_temp(pack_context_t *contex
/* create a copy of ENTRY, make it point to the copy destination and
* store it in CONTEXT */
entry = apr_pmemdup(context->info_pool, entry, sizeof(*entry));
- SVN_ERR(svn_fs_fs__get_file_offset(&entry->offset, context->reps_file,
- pool));
+ SVN_ERR(svn_io_file_get_offset(&entry->offset, context->reps_file,
+ pool));
add_item_rep_mapping(context, entry);
/* copy the noderev to our temp file */
Modified: subversion/trunk/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/transaction.c?rev=1719269&r1=1719268&r2=1719269&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/transaction.c Fri Dec 11 06:57:56 2015
@@ -2179,7 +2179,7 @@ rep_write_get_baton(struct rep_write_bat
b->scratch_pool),
b->scratch_pool);
- SVN_ERR(svn_fs_fs__get_file_offset(&b->rep_offset, file, b->scratch_pool));
+ SVN_ERR(svn_io_file_get_offset(&b->rep_offset, file, b->scratch_pool));
/* Get the base for this delta. */
SVN_ERR(choose_delta_base(&base_rep, fs, noderev, FALSE, b->scratch_pool));
@@ -2202,8 +2202,8 @@ rep_write_get_baton(struct rep_write_bat
b->scratch_pool));
/* Now determine the offset of the actual svndiff data. */
- SVN_ERR(svn_fs_fs__get_file_offset(&b->delta_start, file,
- b->scratch_pool));
+ SVN_ERR(svn_io_file_get_offset(&b->delta_start, file,
+ b->scratch_pool));
/* Cleanup in case something goes wrong. */
apr_pool_cleanup_register(b->scratch_pool, b, rep_write_cleanup,
@@ -2412,7 +2412,7 @@ rep_write_contents_close(void *baton)
SVN_ERR(svn_stream_close(b->delta_stream));
/* Determine the length of the svndiff data. */
- SVN_ERR(svn_fs_fs__get_file_offset(&offset, b->file, b->scratch_pool));
+ SVN_ERR(svn_io_file_get_offset(&offset, b->file, b->scratch_pool));
rep->size = offset - b->delta_start;
/* Fill in the rest of the representation field. */
@@ -2459,7 +2459,7 @@ rep_write_contents_close(void *baton)
svn_fs_fs__p2l_entry_t entry;
entry.offset = b->rep_offset;
- SVN_ERR(svn_fs_fs__get_file_offset(&offset, b->file, b->scratch_pool));
+ SVN_ERR(svn_io_file_get_offset(&offset, b->file, b->scratch_pool));
entry.size = offset - b->rep_offset;
entry.type = SVN_FS_FS__ITEM_TYPE_FILE_REP;
entry.item.revision = SVN_INVALID_REVNUM;
@@ -2672,7 +2672,7 @@ write_container_rep(representation_t *re
representation_t *old_rep;
apr_off_t offset = 0;
- SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, scratch_pool));
+ SVN_ERR(svn_io_file_get_offset(&offset, file, scratch_pool));
whb = apr_pcalloc(scratch_pool, sizeof(*whb));
@@ -2720,7 +2720,7 @@ write_container_rep(representation_t *re
offset, scratch_pool));
entry.offset = offset;
- SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, scratch_pool));
+ SVN_ERR(svn_io_file_get_offset(&offset, file, scratch_pool));
entry.size = offset - entry.offset;
entry.type = item_type;
entry.item.revision = SVN_INVALID_REVNUM;
@@ -2787,7 +2787,7 @@ write_container_delta_rep(representation
SVN_ERR(choose_delta_base(&base_rep, fs, noderev, is_props, scratch_pool));
SVN_ERR(svn_fs_fs__get_contents(&source, fs, base_rep, FALSE, scratch_pool));
- SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, scratch_pool));
+ SVN_ERR(svn_io_file_get_offset(&offset, file, scratch_pool));
/* Write out the rep header. */
if (base_rep)
@@ -2807,7 +2807,7 @@ write_container_delta_rep(representation
scratch_pool),
scratch_pool);
SVN_ERR(svn_fs_fs__write_rep_header(&header, file_stream, scratch_pool));
- SVN_ERR(svn_fs_fs__get_file_offset(&delta_start, file, scratch_pool));
+ SVN_ERR(svn_io_file_get_offset(&delta_start, file, scratch_pool));
/* Prepare to write the svndiff data. */
svn_txdelta_to_svndiff3(&diff_wh,
@@ -2854,14 +2854,14 @@ write_container_delta_rep(representation
svn_fs_fs__p2l_entry_t entry;
/* Write out our cosmetic end marker. */
- SVN_ERR(svn_fs_fs__get_file_offset(&rep_end, file, scratch_pool));
+ SVN_ERR(svn_io_file_get_offset(&rep_end, file, scratch_pool));
SVN_ERR(svn_stream_puts(file_stream, "ENDREP\n"));
SVN_ERR(allocate_item_index(&rep->item_index, fs, &rep->txn_id,
offset, scratch_pool));
entry.offset = offset;
- SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, scratch_pool));
+ SVN_ERR(svn_io_file_get_offset(&offset, file, scratch_pool));
entry.size = offset - entry.offset;
entry.type = item_type;
entry.item.revision = SVN_INVALID_REVNUM;
@@ -3148,7 +3148,7 @@ write_final_rev(const svn_fs_id_t **new_
noderev->copyroot_rev = rev;
/* root nodes have a fixed ID in log addressing mode */
- SVN_ERR(svn_fs_fs__get_file_offset(&my_offset, file, pool));
+ SVN_ERR(svn_io_file_get_offset(&my_offset, file, pool));
if (svn_fs_fs__use_log_addressing(fs) && at_root)
{
/* reference the root noderev from the log-to-phys index */
@@ -3221,7 +3221,7 @@ write_final_rev(const svn_fs_id_t **new_
rev_item.revision = SVN_INVALID_REVNUM;
entry.offset = my_offset;
- SVN_ERR(svn_fs_fs__get_file_offset(&my_offset, file, pool));
+ SVN_ERR(svn_io_file_get_offset(&my_offset, file, pool));
entry.size = my_offset - entry.offset;
entry.type = SVN_FS_FS__ITEM_TYPE_NODEREV;
entry.item = rev_item;
@@ -3254,7 +3254,7 @@ write_final_changed_path_info(apr_off_t
svn_stream_t *stream;
svn_checksum_ctx_t *fnv1a_checksum_ctx;
- SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, pool));
+ SVN_ERR(svn_io_file_get_offset(&offset, file, pool));
/* write to target file & calculate checksum */
stream = fnv1a_wrap_stream(&fnv1a_checksum_ctx,
@@ -3270,7 +3270,7 @@ write_final_changed_path_info(apr_off_t
svn_fs_fs__p2l_entry_t entry;
entry.offset = offset;
- SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, pool));
+ SVN_ERR(svn_io_file_get_offset(&offset, file, pool));
entry.size = offset - entry.offset;
entry.type = SVN_FS_FS__ITEM_TYPE_CHANGES;
entry.item.revision = SVN_INVALID_REVNUM;
@@ -3642,7 +3642,7 @@ commit_body(void *baton, apr_pool_t *poo
/* Get a write handle on the proto revision file. */
SVN_ERR(get_writable_proto_rev(&proto_file, &proto_file_lockcookie,
cb->fs, txn_id, pool));
- SVN_ERR(svn_fs_fs__get_file_offset(&initial_offset, proto_file, pool));
+ SVN_ERR(svn_io_file_get_offset(&initial_offset, proto_file, pool));
/* Write out all the node-revisions and directory contents. */
root_id = svn_fs_fs__id_txn_create_root(txn_id, pool);
Modified: subversion/trunk/subversion/libsvn_fs_fs/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/util.c?rev=1719269&r1=1719268&r2=1719269&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/util.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/util.c Fri Dec 11 06:57:56 2015
@@ -566,22 +566,6 @@ svn_fs_fs__try_stringbuf_from_file(svn_s
}
svn_error_t *
-svn_fs_fs__get_file_offset(apr_off_t *offset_p,
- apr_file_t *file,
- apr_pool_t *pool)
-{
- apr_off_t offset;
-
- /* Note that, for buffered files, one (possibly surprising) side-effect
- of this call is to flush any unwritten data to disk. */
- offset = 0;
- SVN_ERR(svn_io_file_seek(file, APR_CUR, &offset, pool));
- *offset_p = offset;
-
- return SVN_NO_ERROR;
-}
-
-svn_error_t *
svn_fs_fs__read_content(svn_stringbuf_t **content,
const char *fname,
apr_pool_t *pool)
Modified: subversion/trunk/subversion/libsvn_fs_fs/util.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/util.h?rev=1719269&r1=1719268&r2=1719269&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/util.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/util.h Fri Dec 11 06:57:56 2015
@@ -363,12 +363,6 @@ svn_fs_fs__try_stringbuf_from_file(svn_s
svn_boolean_t last_attempt,
apr_pool_t *pool);
-/* Fetch the current offset of FILE into *OFFSET_P. */
-svn_error_t *
-svn_fs_fs__get_file_offset(apr_off_t *offset_p,
- apr_file_t *file,
- apr_pool_t *pool);
-
/* Read the file FNAME and store the contents in *BUF.
Allocations are performed in POOL. */
svn_error_t *
Modified: subversion/trunk/subversion/libsvn_fs_fs/verify.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/verify.c?rev=1719269&r1=1719268&r2=1719269&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/verify.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/verify.c Fri Dec 11 06:57:56 2015
@@ -480,7 +480,7 @@ expect_buffer_nul(apr_file_t *file,
apr_off_t offset;
SVN_ERR(svn_io_file_name_get(&file_name, file, pool));
- SVN_ERR(svn_fs_fs__get_file_offset(&offset, file, pool));
+ SVN_ERR(svn_io_file_get_offset(&offset, file, pool));
offset -= size - i;
return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
Modified: subversion/trunk/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=1719269&r1=1719268&r2=1719269&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Fri Dec 11 06:57:56 2015
@@ -3757,6 +3757,22 @@ svn_io_file_size_get(svn_filesize_t *fil
}
svn_error_t *
+svn_io_file_get_offset(apr_off_t *offset_p,
+ apr_file_t *file,
+ apr_pool_t *pool)
+{
+ apr_off_t offset;
+
+ /* Note that, for buffered files, one (possibly surprising) side-effect
+ of this call is to flush any unwritten data to disk. */
+ offset = 0;
+ SVN_ERR(svn_io_file_seek(file, APR_CUR, &offset, pool));
+ *offset_p = offset;
+
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
svn_io_file_read(apr_file_t *file, void *buf,
apr_size_t *nbytes, apr_pool_t *pool)
{