Author: stefan2
Date: Sat Oct 18 23:29:26 2014
New Revision: 1632863
URL: http://svn.apache.org/r1632863
Log:
Prepare the 'svnfsfs load-index' code for being split up into UI,
FSFS internal logic and a private interface in between.
This patch introduces the interface structure but does not move
any code around. We only have to factor the actual FS access
into a separate function.
* subversion/svnfsfs/load-index-cmd.c
(svn_fs_fs__load_index): New function, code taken from load_index().
(load_index): Call the new function.
Modified:
subversion/trunk/subversion/svnfsfs/load-index-cmd.c
Modified: subversion/trunk/subversion/svnfsfs/load-index-cmd.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/svnfsfs/load-index-cmd.c?rev=1632863&r1=1632862&r2=1632863&view=diff
==============================================================================
--- subversion/trunk/subversion/svnfsfs/load-index-cmd.c (original)
+++ subversion/trunk/subversion/svnfsfs/load-index-cmd.c Sat Oct 18 23:29:26
2014
@@ -123,6 +123,51 @@ parse_index_line(svn_fs_fs__p2l_entry_t
return SVN_NO_ERROR;
}
+/* Rewrite the respective index information of the rev / pack file in FS
+ * containing REVISION and use the svn_fs_fs__p2l_entry_t * array ENTRIES
+ * as the new index contents. Allocate temporaries from SCRATCH_POOL. */
+static svn_error_t *
+svn_fs_fs__load_index(svn_fs_t *fs,
+ svn_revnum_t revision,
+ apr_array_header_t *entries,
+ apr_pool_t *scratch_pool)
+{
+ apr_pool_t *iterpool = svn_pool_create(scratch_pool);
+
+ /* Treat an empty array as a no-op instead error. */
+ if (entries->nelts != 0)
+ {
+ const char *l2p_proto_index;
+ const char *p2l_proto_index;
+ svn_fs_fs__revision_file_t *rev_file;
+
+ /* Open rev / pack file & trim indexes + footer off it. */
+ SVN_ERR(svn_fs_fs__open_pack_or_rev_file_writable(&rev_file, fs,
+ revision, iterpool,
+ iterpool));
+ SVN_ERR(svn_fs_fs__auto_read_footer(rev_file));
+ SVN_ERR(svn_io_file_trunc(rev_file->file, rev_file->l2p_offset,
+ iterpool));
+
+ /* Create proto index files for the new index data
+ * (will be cleaned up automatically with iterpool). */
+ SVN_ERR(svn_fs_fs__p2l_index_from_p2l_entries(&p2l_proto_index, fs,
+ rev_file, entries,
+ iterpool, iterpool));
+ SVN_ERR(svn_fs_fs__l2p_index_from_p2l_entries(&l2p_proto_index, fs,
+ entries, iterpool,
+ iterpool));
+
+ /* Combine rev data with new index data. */
+ SVN_ERR(svn_fs_fs__add_index_data(fs, rev_file->file, l2p_proto_index,
+ p2l_proto_index, revision, iterpool));
+ }
+
+ svn_pool_destroy(iterpool);
+
+ return SVN_NO_ERROR;
+}
+
/* Parse the space separated P2L index table from INPUT, one entry per line.
* Rewrite the respective index files in PATH. Allocate from POOL. */
static svn_error_t *
@@ -175,38 +220,10 @@ load_index(const char *path,
if (! svn_fs_fs__use_log_addressing(fs, revision))
return svn_error_create(SVN_ERR_FS_UNSUPPORTED_FORMAT, NULL, NULL);
}
-
- }
-
- /* Treat an empty array as a no-op instead error. */
- if (entries->nelts != 0)
- {
- const char *l2p_proto_index;
- const char *p2l_proto_index;
- svn_fs_fs__revision_file_t *rev_file;
-
- /* Open rev / pack file & trim indexes + footer off it. */
- SVN_ERR(svn_fs_fs__open_pack_or_rev_file_writable(&rev_file, fs,
- revision, iterpool,
- iterpool));
- SVN_ERR(svn_fs_fs__auto_read_footer(rev_file));
- SVN_ERR(svn_io_file_trunc(rev_file->file, rev_file->l2p_offset,
- iterpool));
-
- /* Create proto index files for the new index data
- * (will be cleaned up automatically with iterpool). */
- SVN_ERR(svn_fs_fs__p2l_index_from_p2l_entries(&p2l_proto_index, fs,
- rev_file, entries,
- iterpool, iterpool));
- SVN_ERR(svn_fs_fs__l2p_index_from_p2l_entries(&l2p_proto_index, fs,
- entries, iterpool,
- iterpool));
-
- /* Combine rev data with new index data. */
- SVN_ERR(svn_fs_fs__add_index_data(fs, rev_file->file, l2p_proto_index,
- p2l_proto_index, revision, iterpool));
}
+ /* Rewrite the indexes. */
+ SVN_ERR(svn_fs_fs__load_index(fs, revision, entries, iterpool));
svn_pool_destroy(iterpool);
return SVN_NO_ERROR;