[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] [merge-tracking] Refactoring the merge info indexing code.

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2006-07-27 19:03:50 CEST

Thanks Madan.
Removed the redundant comment in preference to self documenting function
name.

[[[
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'.
]]]

Find the attached Patch.
With regards
Kamesh Jayachandran

Madan U Sreenivasan wrote:
> On Thu, 27 Jul 2006 13:37:56 +0530, Kamesh Jayachandran
> <kamesh@collab.net> wrote:
>
>> Madan U Sreenivasan wrote:
>>> On Wed, 26 Jul 2006 15:16:35 +0530, Kamesh Jayachandran
>>> <kamesh@collab.net> wrote:
>
> [snip]
>
>>> /* Do mergeinfo indexing. */
>>> - if (contains_merge_info)
>>>
>>> The comment is now redundant.
>> Do you mean '/* Do mergeinfo indexing. */'?
>> It is not part of the change just the context marker.
>
> Yes, and it is redundant now, as the next line is the function call to
> index_merge_info() - which is self explanatory.
>
> Regards,
> Madan U S
> www.symonds.net/~madan

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 *'. */
@@ -4231,58 +4271,8 @@
   SVN_ERR(svn_fs_fs__move_into_place(revprop_filename, final_revprop,
                                      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 Fri Jul 28 07:34:15 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.