Hi All,
Find the attached patch.
With regards
Kamesh Jayachandran
[[[
Patch by: Kamesh Jayachandran <kamesh@collab.net>
Refactor 'mergeinfo indexing code'.
* subversion/libsvn_fs_fs/fs_fs.c
(do_merge_info_indexing): New function.
Cleans up the earlier failed commit mergeinfo records.
Adds the mergeinfo if exists.
(commit_body): uses 'do_merge_info_indexing'.
]]]
Index: subversion/libsvn_fs_fs/fs_fs.c
===================================================================
--- subversion/libsvn_fs_fs/fs_fs.c (revision 20872)
+++ subversion/libsvn_fs_fs/fs_fs.c (working copy)
@@ -4113,6 +4113,46 @@
svn_fs_txn_t *txn;
};
+/* Clean the mergeinfo index for earlier failed commit having the
+ rev num as NEW_REV. If the current commit has 'merge info' record the
+ same. */
+static svn_error_t *
+do_merge_info_indexing(struct commit_baton *cb, svn_revnum_t new_rev,
+ svn_boolean_t contains_merge_info, apr_pool_t *pool)
+{
+ const char *deletestring;
+ fs_txn_data_t *ftd = cb->txn->fsap_data;
+
+ SQLITE_ERR(sqlite3_open(path_mergeinfo_db(cb->fs, pool),
+ &ftd->mtd), ftd->mtd);
+#ifdef SQLITE3_DEBUG
+ sqlite3_trace (ftd->mtd, sqlite_tracer, ftd->mtd);
+#endif
+ SVN_ERR(fs_sqlite_exec(ftd->mtd, "begin transaction;", NULL, NULL));
+ deletestring = apr_psprintf(pool,
+ "delete from mergeinfo_changed where revision = %ld;",
+ new_rev);
+ SVN_ERR(fs_sqlite_exec(ftd->mtd, deletestring, NULL, NULL));
+ deletestring = apr_psprintf(pool,
+ "delete from mergeinfo where revision = %ld;",
+ new_rev);
+ SVN_ERR(fs_sqlite_exec(ftd->mtd, deletestring, NULL, NULL));
+
+ if (contains_merge_info)
+ {
+ SVN_ERR(update_mergeinfo_index(cb->txn, new_rev, pool));
+ }
+
+ /* This is moved here from commit_txn, because we don't want to
+ write the final current file if the sqlite commit fails.
+ On the other hand, if we commit the transaction and end up failing
+ the current file, we just end up with inaccessible data in the
+ database, not a real problem. */
+ SVN_ERR(fs_sqlite_exec(ftd->mtd, "commit transaction;", NULL, NULL));
+ SQLITE_ERR(sqlite3_close(ftd->mtd), ftd->mtd);
+ return SVN_NO_ERROR;
+}
+
/* The work-horse for svn_fs_fs__commit, called with the FS write lock.
This implements the svn_fs_fs__with_write_lock() 'body' callback
type. BATON is a 'struct commit_baton *'. */
@@ -4232,57 +4272,8 @@
old_rev_filename, pool));
/* Do mergeinfo indexing. */
- if (contains_merge_info)
- {
- const char *deletestring;
-
- SQLITE_ERR(sqlite3_open(path_mergeinfo_db(cb->fs, pool),
- &ftd->mtd), ftd->mtd);
-#ifdef SQLITE3_DEBUG
- sqlite3_trace (ftd->mtd, sqlite_tracer, ftd->mtd);
-#endif
- SVN_ERR(fs_sqlite_exec(ftd->mtd, "begin transaction;", NULL, NULL));
- deletestring = apr_psprintf(pool,
- "delete from mergeinfo_changed where revision = %ld;",
- new_rev);
- SVN_ERR(fs_sqlite_exec(ftd->mtd, deletestring, NULL, NULL));
- deletestring = apr_psprintf(pool,
- "delete from mergeinfo where revision = %ld;",
- new_rev);
- SVN_ERR(fs_sqlite_exec(ftd->mtd, deletestring, NULL, NULL));
- SVN_ERR(update_mergeinfo_index(cb->txn, new_rev, pool));
-
- /* This is moved here from commit_txn, because we don't want to
- write the final current file if the sqlite commit fails.
- On the other hand, if we commit the transaction and end up failing
- the current file, we just end up with inaccessible data in the
- database, not a real problem. */
- SVN_ERR(fs_sqlite_exec(ftd->mtd, "commit transaction;", NULL, NULL));
- SQLITE_ERR(sqlite3_close(ftd->mtd), ftd->mtd);
- }
- else
- {
- const char *deletestring;
-
- SQLITE_ERR(sqlite3_open(path_mergeinfo_db(cb->fs, pool),
- &ftd->mtd), ftd->mtd);
-#ifdef SQLITE3_DEBUG
- sqlite3_trace (ftd->mtd, sqlite_tracer, ftd->mtd);
-#endif
- SVN_ERR(fs_sqlite_exec(ftd->mtd, "begin transaction;", NULL, NULL));
- deletestring = apr_psprintf(pool,
- "delete from mergeinfo_changed where revision = %ld;",
- new_rev);
- SVN_ERR(fs_sqlite_exec(ftd->mtd, deletestring, NULL, NULL));
- deletestring = apr_psprintf(pool,
- "delete from mergeinfo where revision = %ld;",
- new_rev);
- SVN_ERR(fs_sqlite_exec(ftd->mtd, deletestring, NULL, NULL));
- SVN_ERR(fs_sqlite_exec(ftd->mtd, "commit transaction;", NULL, NULL));
- SQLITE_ERR(sqlite3_close(ftd->mtd), ftd->mtd);
- }
+ SVN_ERR(do_merge_info_indexing(cb, new_rev, contains_merge_info, pool));
-
/* Update the 'current' file. */
SVN_ERR(write_final_current(cb->fs, cb->txn->id, new_rev, start_node_id,
start_copy_id, pool));
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jul 27 00:17:52 2006