You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2011/05/26 14:37:46 UTC

svn commit: r1127889 - /subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c

Author: julianfoad
Date: Thu May 26 12:37:46 2011
New Revision: 1127889

URL: http://svn.apache.org/viewvc?rev=1127889&view=rev
Log:
Code simplification.  No functional change.

* subversion/tests/libsvn_wc/op-depth-test.c
  (open_wc_db): Take the list of statements as a parameter, so it can be
    used more flexibly.
  (my_statements, STMT_SELECT_NODES_INFO): Move into ...
  (check_db_rows): ... here, and update the call to open_wc_db().
  (insert_dirs, insert_actual, check_db_actual): Use open_wc_db() instead of
    in-line code.

Modified:
    subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c

Modified: subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c?rev=1127889&r1=1127888&r2=1127889&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c Thu May 26 12:37:46 2011
@@ -66,17 +66,10 @@ strcmp_null(const char *s1, const char *
 /* ---------------------------------------------------------------------- */
 /* Reading the WC DB */
 
-static const char *const my_statements[] = {
-  "SELECT op_depth, presence, local_relpath, revision, repos_path "
-    "FROM nodes "
-    "WHERE local_relpath = ?1 OR local_relpath LIKE ?2",
-  NULL };
-
-#define STMT_SELECT_NODES_INFO 0
-
 static svn_error_t *
 open_wc_db(svn_sqlite__db_t **sdb,
            const char *wc_root_abspath,
+           const char *const *my_statements,
            apr_pool_t *result_pool,
            apr_pool_t *scratch_pool)
 {
@@ -416,6 +409,13 @@ check_db_rows(svn_test__sandbox_t *b,
   svn_sqlite__db_t *sdb;
   int i;
   svn_sqlite__stmt_t *stmt;
+  const char *const statements[] = {
+    "SELECT op_depth, presence, local_relpath, revision, repos_path "
+      "FROM nodes "
+      "WHERE local_relpath = ?1 OR local_relpath LIKE ?2",
+    NULL };
+#define STMT_SELECT_NODES_INFO 0
+
   svn_boolean_t have_row;
   apr_hash_t *found_hash = apr_hash_make(b->pool);
   apr_hash_t *expected_hash = apr_hash_make(b->pool);
@@ -423,7 +423,7 @@ check_db_rows(svn_test__sandbox_t *b,
     = { expected_hash, found_hash, b->pool, NULL };
 
   /* Fill ACTUAL_HASH with data from the WC DB. */
-  SVN_ERR(open_wc_db(&sdb, b->wc_abspath, b->pool, b->pool));
+  SVN_ERR(open_wc_db(&sdb, b->wc_abspath, statements, b->pool, b->pool));
   SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, STMT_SELECT_NODES_INFO));
   SVN_ERR(svn_sqlite__bindf(stmt, "ss", base_relpath,
                             (base_relpath[0]
@@ -1152,9 +1152,6 @@ insert_dirs(svn_test__sandbox_t *b,
 {
   svn_sqlite__db_t *sdb;
   svn_sqlite__stmt_t *stmt;
-  const char *dbpath = svn_dirent_join_many(b->pool,
-                                            b->wc_abspath, ".svn", "wc.db",
-                                            NULL);
   const char * const statements[] = {
     "DELETE FROM nodes;",
     "INSERT INTO nodes (local_relpath, op_depth, presence, repos_path,"
@@ -1166,9 +1163,7 @@ insert_dirs(svn_test__sandbox_t *b,
     NULL,
   };
 
-  SVN_ERR(svn_sqlite__open(&sdb, dbpath, svn_sqlite__mode_readwrite,
-                           statements, 0, NULL,
-                           b->pool, b->pool));
+  SVN_ERR(open_wc_db(&sdb, b->wc_abspath, statements, b->pool, b->pool));
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, 0));
   SVN_ERR(svn_sqlite__step_done(stmt));
@@ -1947,9 +1942,6 @@ insert_actual(svn_test__sandbox_t *b,
 {
   svn_sqlite__db_t *sdb;
   svn_sqlite__stmt_t *stmt;
-  const char *dbpath = svn_dirent_join_many(b->pool,
-                                            b->wc_abspath, ".svn", "wc.db",
-                                            NULL);
   const char * const statements[] = {
     "DELETE FROM actual_node;",
     "INSERT INTO actual_node (local_relpath, changelist, wc_id)"
@@ -1963,9 +1955,7 @@ insert_actual(svn_test__sandbox_t *b,
   if (!actual)
     return SVN_NO_ERROR;
 
-  SVN_ERR(svn_sqlite__open(&sdb, dbpath, svn_sqlite__mode_readwrite,
-                           statements, 0, NULL,
-                           b->pool, b->pool));
+  SVN_ERR(open_wc_db(&sdb, b->wc_abspath, statements, b->pool, b->pool));
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, 0));
   SVN_ERR(svn_sqlite__step_done(stmt));
@@ -2007,9 +1997,6 @@ check_db_actual(svn_test__sandbox_t* b, 
 {
   svn_sqlite__db_t *sdb;
   svn_sqlite__stmt_t *stmt;
-  const char *dbpath = svn_dirent_join_many(b->pool,
-                                            b->wc_abspath, ".svn", "wc.db",
-                                            NULL);
   const char * const statements[] = {
     "SELECT local_relpath FROM actual_node WHERE wc_id = 1;",
     NULL,
@@ -2027,9 +2014,7 @@ check_db_actual(svn_test__sandbox_t* b, 
       ++rows;
     }
 
-  SVN_ERR(svn_sqlite__open(&sdb, dbpath, svn_sqlite__mode_readwrite,
-                           statements, 0, NULL,
-                           b->pool, b->pool));
+  SVN_ERR(open_wc_db(&sdb, b->wc_abspath, statements, b->pool, b->pool));
 
   SVN_ERR(svn_sqlite__get_statement(&stmt, sdb, 0));
   SVN_ERR(svn_sqlite__step(&have_row, stmt));



Re: svn commit: r1127889 - /subversion/trunk/subversion/tests/libsvn_wc/op-depth-test.c

Posted by Greg Stein <gs...@gmail.com>.
On May 26, 2011 8:38 AM, <ju...@apache.org> wrote:
>...
> @@ -416,6 +409,13 @@ check_db_rows(svn_test__sandbox_t *b,
>   svn_sqlite__db_t *sdb;
>   int i;
>   svn_sqlite__stmt_t *stmt;
> +  const char *const statements[] = {
> +    "SELECT op_depth, presence, local_relpath, revision, repos_path "
> +      "FROM nodes "
> +      "WHERE local_relpath = ?1 OR local_relpath LIKE ?2",
> +    NULL };

That should be static. Probably the same for other functions, too.