Author: rhuijben
Date: Thu Feb 26 00:03:21 2015
New Revision: 1662332

URL: http://svn.apache.org/r1662332
Log:
Simplify a few more code paths using the smarter Sqlite macros introduced
some time ago.

* subversion/libsvn_wc/upgrade.c
  (upgrade_working_copy_baton_t,
   upgrade_working_copy_txn): Remove helpers, as we can just...
  (svn_wc_upgrade): ... use SVN_SQLITE__WITH_LOCK() and call the function
    directly.

* subversion/libsvn_wc/wc_db.c
  (svn_wc__db_txn_callback_t): Move callback type here.
  (with_finalization): Write out some portions of SVN_SQLITE__WITH_LOCK(),
    in a function that has initimite knowledge anyway, to avoid keeping
    further unused code alive.

* subversion/libsvn_wc/wc_db_private.h
  (svn_wc__db_txn_callback_t): Remove type.
  (svn_wc__db_with_txn): Remove function.

* subversion/libsvn_wc/wc_db_util.c
  (db_txn_callback_t,
   txn_baton_t): Remove type.
  (run_txn,
   svn_wc__db_with_txn): Remove function.

* subversion/tests/cmdline/entries-dump.c
  (tree_dump_txn): Remove function.
  (tree_dump): Directly call svn_wc__internal_walk_children().

Modified:
    subversion/trunk/subversion/libsvn_wc/upgrade.c
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db_private.h
    subversion/trunk/subversion/libsvn_wc/wc_db_util.c
    subversion/trunk/subversion/tests/cmdline/entries-dump.c

Modified: subversion/trunk/subversion/libsvn_wc/upgrade.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/upgrade.c?rev=1662332&r1=1662331&r2=1662332&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/upgrade.c (original)
+++ subversion/trunk/subversion/libsvn_wc/upgrade.c Thu Feb 26 00:03:21 2015
@@ -2366,40 +2366,6 @@ is_old_wcroot(const char *local_abspath,
     svn_dirent_local_style(parent_abspath, scratch_pool));
 }
 
-/* Data for upgrade_working_copy_txn(). */
-typedef struct upgrade_working_copy_baton_t
-{
-  svn_wc__db_t *db;
-  const char *dir_abspath;
-  svn_wc_upgrade_get_repos_info_t repos_info_func;
-  void *repos_info_baton;
-  apr_hash_t *repos_cache;
-  const struct upgrade_data_t *data;
-  svn_cancel_func_t cancel_func;
-  void *cancel_baton;
-  svn_wc_notify_func2_t notify_func;
-  void *notify_baton;
-  apr_pool_t *result_pool;
-} upgrade_working_copy_baton_t;
-
-
-/* Helper for svn_wc_upgrade. Implements svn_sqlite__transaction_callback_t */
-static svn_error_t *
-upgrade_working_copy_txn(void *baton,
-                         svn_sqlite__db_t *sdb,
-                         apr_pool_t *scratch_pool)
-{
-  upgrade_working_copy_baton_t *b = baton;
-
-  /* Upgrade the pre-wcng into a wcng in a temporary location. */
-  return(upgrade_working_copy(NULL, b->db, b->dir_abspath,
-                              b->repos_info_func, b->repos_info_baton,
-                              b->repos_cache, b->data,
-                              b->cancel_func, b->cancel_baton,
-                              b->notify_func, b->notify_baton,
-                              b->result_pool, scratch_pool));
-}
-
 svn_error_t *
 svn_wc_upgrade(svn_wc_context_t *wc_ctx,
                const char *local_abspath,
@@ -2419,7 +2385,6 @@ svn_wc_upgrade(svn_wc_context_t *wc_ctx,
   svn_wc_entry_t *this_dir;
   apr_hash_t *entries;
   const char *root_adm_abspath;
-  upgrade_working_copy_baton_t cb_baton;
   svn_error_t *err;
   int result_format;
   svn_boolean_t bumped_format;
@@ -2517,22 +2482,14 @@ svn_wc_upgrade(svn_wc_context_t *wc_ctx,
   SVN_ERR(svn_wc__db_wclock_obtain(db, data.root_abspath, 0, FALSE,
                                    scratch_pool));
 
-  cb_baton.db = db;
-  cb_baton.dir_abspath = local_abspath;
-  cb_baton.repos_info_func = repos_info_func;
-  cb_baton.repos_info_baton = repos_info_baton;
-  cb_baton.repos_cache = repos_cache;
-  cb_baton.data = &data;
-  cb_baton.cancel_func = cancel_func;
-  cb_baton.cancel_baton = cancel_baton;
-  cb_baton.notify_func = notify_func;
-  cb_baton.notify_baton = notify_baton;
-  cb_baton.result_pool = scratch_pool;
-
-  SVN_ERR(svn_sqlite__with_lock(data.sdb,
-                                upgrade_working_copy_txn,
-                                &cb_baton,
-                                scratch_pool));
+  SVN_SQLITE__WITH_LOCK(
+    upgrade_working_copy(NULL, db, local_abspath,
+                         repos_info_func, repos_info_baton,
+                         repos_cache, &data,
+                         cancel_func, cancel_baton,
+                         notify_func, notify_baton,
+                         scratch_pool, scratch_pool),
+    data.sdb);
 
   /* A workqueue item to move the pristine dir into place */
   pristine_from = svn_wc__adm_child(data.root_abspath, 
PRISTINE_STORAGE_RELPATH,

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1662332&r1=1662331&r2=1662332&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Thu Feb 26 00:03:21 2015
@@ -3007,6 +3007,11 @@ svn_wc__db_depth_get_info(svn_wc__db_sta
   return svn_error_compose_create(err, svn_sqlite__reset(stmt));
 }
 
+/* A callback which supplies WCROOTs and LOCAL_RELPATHs. */
+typedef svn_error_t *(*svn_wc__db_txn_callback_t)(void *baton,
+                                          svn_wc__db_wcroot_t *wcroot,
+                                          const char *local_relpath,
+                                          apr_pool_t *scratch_pool);
 
 /* Baton for passing args to with_triggers(). */
 struct with_triggers_baton_t {
@@ -3083,8 +3088,13 @@ with_finalization(svn_wc__db_wcroot_t *w
   svn_error_t *err1;
   svn_error_t *err2;
 
-  err1 = svn_wc__db_with_txn(wcroot, local_relpath, txn_cb, txn_baton,
-                             scratch_pool);
+  err1 = svn_sqlite__begin_savepoint(wcroot->sdb);
+  if (!err1)
+    {
+      err1 = txn_cb(txn_baton, wcroot, local_relpath, scratch_pool);
+
+      err1 = svn_sqlite__finish_savepoint(wcroot->sdb, err1);
+    }
 
   if (err1 == NULL && notify_func != NULL)
     {

Modified: subversion/trunk/subversion/libsvn_wc/wc_db_private.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_private.h?rev=1662332&r1=1662331&r2=1662332&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_private.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_private.h Thu Feb 26 00:03:21 
2015
@@ -345,23 +345,6 @@ svn_wc__db_mark_conflict_internal(svn_wc
 
 /* Transaction handling */
 
-/* A callback which supplies WCROOTs and LOCAL_RELPATHs. */
-typedef svn_error_t *(*svn_wc__db_txn_callback_t)(void *baton,
-                                          svn_wc__db_wcroot_t *wcroot,
-                                          const char *local_relpath,
-                                          apr_pool_t *scratch_pool);
-
-
-/* Run CB_FUNC in a SQLite transaction with CB_BATON, using WCROOT and
-   LOCAL_RELPATH.  If callbacks require additional information, they may
-   provide it using CB_BATON. */
-svn_error_t *
-svn_wc__db_with_txn(svn_wc__db_wcroot_t *wcroot,
-                    const char *local_relpath,
-                    svn_wc__db_txn_callback_t cb_func,
-                    void *cb_baton,
-                    apr_pool_t *scratch_pool);
-
 /* Evaluate the expression EXPR within a transaction.
  *
  * Begin a transaction in WCROOT's DB; evaluate the expression EXPR, which 
would

Modified: subversion/trunk/subversion/libsvn_wc/wc_db_util.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db_util.c?rev=1662332&r1=1662331&r2=1662332&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db_util.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db_util.c Thu Feb 26 00:03:21 2015
@@ -152,63 +152,3 @@ svn_wc__db_util_open_db(svn_sqlite__db_t
   return SVN_NO_ERROR;
 }
 
-
-/* Some helpful transaction helpers.
-
-   Instead of directly using SQLite transactions, these wrappers
-   relieve the consumer from the need to wrap the wcroot and
-   local_relpath, which are almost always used within the transaction.
-
-   This also means if we later want to implement some wc_db-specific txn
-   handling, we have a convenient place to do it.
-   */
-
-/* A callback which supplies WCROOTs and LOCAL_RELPATHs. */
-typedef svn_error_t *(*db_txn_callback_t)(void *baton,
-                                          svn_wc__db_wcroot_t *wcroot,
-                                          const char *local_relpath,
-                                          apr_pool_t *scratch_pool);
-
-/* Baton for use with run_txn() and with_db_txn(). */
-struct txn_baton_t
-{
-  svn_wc__db_wcroot_t *wcroot;
-  const char *local_relpath;
-
-  db_txn_callback_t cb_func;
-  void *cb_baton;
-};
-
-
-/* Unwrap the sqlite transaction into a wc_db txn.
-   Implements svn_sqlite__transaction_callback_t. */
-static svn_error_t *
-run_txn(void *baton, svn_sqlite__db_t *db, apr_pool_t *scratch_pool)
-{
-  struct txn_baton_t *tb = baton;
-
-  return svn_error_trace(
-    tb->cb_func(tb->cb_baton, tb->wcroot, tb->local_relpath, scratch_pool));
-}
-
-
-/* Run CB_FUNC in a SQLite transaction with CB_BATON, using WCROOT and
-   LOCAL_RELPATH.  If callbacks require additional information, they may
-   provide it using CB_BATON. */
-svn_error_t *
-svn_wc__db_with_txn(svn_wc__db_wcroot_t *wcroot,
-                    const char *local_relpath,
-                    svn_wc__db_txn_callback_t cb_func,
-                    void *cb_baton,
-                    apr_pool_t *scratch_pool)
-{
-  struct txn_baton_t tb;
-
-  tb.wcroot = wcroot;
-  tb.local_relpath = local_relpath;
-  tb.cb_func = cb_func;
-  tb.cb_baton = cb_baton;
-
-  return svn_error_trace(
-    svn_sqlite__with_lock(wcroot->sdb, run_txn, &tb, scratch_pool));
-}

Modified: subversion/trunk/subversion/tests/cmdline/entries-dump.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/entries-dump.c?rev=1662332&r1=1662331&r2=1662332&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/entries-dump.c (original)
+++ subversion/trunk/subversion/tests/cmdline/entries-dump.c Thu Feb 26 
00:03:21 2015
@@ -288,19 +288,6 @@ tree_dump_dir(const char *local_abspath,
 }
 
 static svn_error_t *
-tree_dump_txn(void *baton, svn_sqlite__db_t *db, apr_pool_t *scratch_pool)
-{
-  struct directory_walk_baton *bt = baton;
-
-  SVN_ERR(svn_wc__internal_walk_children(bt->wc_ctx->db, bt->root_abspath, 
FALSE,
-                                         NULL, tree_dump_dir, bt,
-                                         svn_depth_infinity,
-                                         NULL, NULL, scratch_pool));
-
-  return SVN_NO_ERROR;
-}
-
-static svn_error_t *
 tree_dump(const char *path,
           apr_pool_t *scratch_pool)
 {
@@ -325,7 +312,12 @@ tree_dump(const char *path,
   SVN_ERR(svn_wc__db_temp_borrow_sdb(&sdb, bt.wc_ctx->db, bt.root_abspath,
                                      scratch_pool));
 
-  SVN_ERR(svn_sqlite__with_lock(sdb, tree_dump_txn, &bt, scratch_pool));
+  SVN_SQLITE__WITH_LOCK(
+      svn_wc__internal_walk_children(db, bt.root_abspath, FALSE,
+                                     NULL, tree_dump_dir, &bt,
+                                     svn_depth_infinity,
+                                     NULL, NULL, scratch_pool),
+      sdb);
 
   /* And close everything we've opened */
   SVN_ERR(svn_wc_context_destroy(bt.wc_ctx));


Reply via email to