subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r958908 - in /subversion/trunk/subversion: libsvn_wc/lock.c tests/libsvn_client/client-test.c
Date Tue, 29 Jun 2010 10:03:23 GMT
Author: rhuijben
Date: Tue Jun 29 10:03:22 2010
New Revision: 958908

URL: http://svn.apache.org/viewvc?rev=958908&view=rev
Log:
Add a c test to verify that we keep svn_wc_add3() compatibility working
when we move our own code in libsvn_client to a better route.

* subversion/libsvn_wc/lock.c
  (adm_access_alloc): Allow obtaining an access baton with lock for a node
    that is already locked in the same svn_wc__db_t instance.

* subversion/tests/libsvn_client/client-test.c
  (test_wc_add_scenarios): New function: Testing svn_wc_add3() behavior,
    to make sure it will be compatible when we move features to deprecated.c.
  (test_funcs): Add test_wc_add_scenarios.

Modified:
    subversion/trunk/subversion/libsvn_wc/lock.c
    subversion/trunk/subversion/tests/libsvn_client/client-test.c

Modified: subversion/trunk/subversion/libsvn_wc/lock.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/lock.c?rev=958908&r1=958907&r2=958908&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/lock.c (original)
+++ subversion/trunk/subversion/libsvn_wc/lock.c Tue Jun 29 10:03:22 2010
@@ -309,7 +309,14 @@ adm_access_alloc(svn_wc_adm_access_t **a
 
   if (write_lock)
     {
-      SVN_ERR(svn_wc__db_wclock_set(db, lock->abspath, 0, scratch_pool));
+      svn_boolean_t owns_lock;
+
+      /* If the db already owns a lock, we can't add an extra lock record */
+      SVN_ERR(svn_wc__db_temp_own_lock(&owns_lock, db, path, scratch_pool));
+
+      if (!owns_lock)
+        SVN_ERR(svn_wc__db_wclock_set(db, lock->abspath, 0, scratch_pool));
+
       SVN_ERR(svn_wc__db_temp_mark_locked(db, lock->abspath, scratch_pool));
     }
 

Modified: subversion/trunk/subversion/tests/libsvn_client/client-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_client/client-test.c?rev=958908&r1=958907&r2=958908&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_client/client-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_client/client-test.c Tue Jun 29 10:03:22 2010
@@ -400,6 +400,139 @@ test_patch(const svn_test_opts_t *opts,
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+test_wc_add_scenarios(const svn_test_opts_t *opts,
+                      apr_pool_t *pool)
+{
+  svn_repos_t *repos;
+  svn_fs_t *fs;
+  svn_fs_txn_t *txn;
+  svn_fs_root_t *txn_root;
+  const char *repos_url;
+  const char *wc_path;
+  svn_revnum_t committed_rev;
+  svn_client_ctx_t *ctx;
+  svn_opt_revision_t rev, peg_rev;
+  const char *new_dir_path;
+  const char *ex_file_path;
+  const char *ex_dir_path;
+  const char *ex2_dir_path;
+
+  /* Create a filesytem and repository. */
+  SVN_ERR(svn_test__create_repos(&repos, "test-wc-add-repos",
+                                 opts, pool));
+  fs = svn_repos_fs(repos);
+
+  /* Prepare a txn to receive the greek tree. */
+  SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, 0, pool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
+  SVN_ERR(svn_test__create_greek_tree(txn_root, pool));
+  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &committed_rev, txn, pool));
+
+  SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, "test-wc-add-repos",
+                                           pool));
+
+  SVN_ERR(svn_dirent_get_absolute(&wc_path, "test-wc-add", pool));
+  SVN_ERR(svn_io_make_dir_recursively(wc_path, pool));
+  svn_test_add_dir_cleanup(wc_path);
+
+  rev.kind = svn_opt_revision_head;
+  peg_rev.kind = svn_opt_revision_unspecified;
+  SVN_ERR(svn_client_create_context(&ctx, pool));
+  /* Checkout greek tree as wc_path */
+  SVN_ERR(svn_client_checkout3(NULL, repos_url, wc_path, &peg_rev, &rev,
+                               svn_depth_infinity, FALSE, FALSE, ctx, pool));
+
+  /* Now checkout again as wc_path/NEW */
+  new_dir_path = svn_dirent_join(wc_path, "NEW", pool);
+  SVN_ERR(svn_client_checkout3(NULL, repos_url, new_dir_path, &peg_rev, &rev,
+                               svn_depth_infinity, FALSE, FALSE,
+                               ctx, pool));
+
+  ex_dir_path = svn_dirent_join(wc_path, "NEW_add", pool);
+  ex2_dir_path = svn_dirent_join(wc_path, "NEW_add2", pool);
+  SVN_ERR(svn_io_dir_make(ex_dir_path, APR_OS_DEFAULT, pool));
+  SVN_ERR(svn_io_dir_make(ex2_dir_path, APR_OS_DEFAULT, pool));
+
+  SVN_ERR(svn_io_open_uniquely_named(NULL, &ex_file_path, wc_path, "new_file",
+                                     NULL, svn_io_file_del_none, pool, pool));
+
+  /* Now use an access baton to do some add operations like an old client
+     might do */
+  {
+    svn_wc_adm_access_t *adm_access, *adm2;
+    svn_boolean_t locked;
+
+    SVN_ERR(svn_wc_adm_open3(&adm_access, NULL, wc_path, TRUE, -1, NULL, NULL,
+                             pool));
+
+    /* Fix up copy as add with history */
+    SVN_ERR(svn_wc_add3(new_dir_path, adm_access, svn_depth_infinity,
+                        repos_url, committed_rev, NULL, NULL, NULL, NULL,
+                        pool));
+
+    /* Verify if the paths are locked now */
+    SVN_ERR(svn_wc_locked(&locked, wc_path, pool));
+    SVN_TEST_ASSERT(locked && "wc_path locked");
+    SVN_ERR(svn_wc_locked(&locked, new_dir_path, pool));
+    SVN_TEST_ASSERT(locked && "new_path locked");
+
+    SVN_ERR(svn_wc_adm_retrieve(&adm2, adm_access, new_dir_path, pool));
+    SVN_TEST_ASSERT(adm2 != NULL && "available in set");
+
+    /* Add local (new) file */
+    SVN_ERR(svn_wc_add3(ex_file_path, adm_access, svn_depth_unknown, NULL,
+                        SVN_INVALID_REVNUM, NULL, NULL, NULL, NULL, pool));
+
+    /* Add local (new) directory */
+    SVN_ERR(svn_wc_add3(ex_dir_path, adm_access, svn_depth_infinity, NULL,
+                        SVN_INVALID_REVNUM, NULL, NULL, NULL, NULL, pool));
+
+    SVN_ERR(svn_wc_adm_retrieve(&adm2, adm_access, ex_dir_path, pool));
+    SVN_TEST_ASSERT(adm2 != NULL && "available in set");
+
+    /* Add empty directory with copy trail */
+    SVN_ERR(svn_wc_add3(ex2_dir_path, adm_access, svn_depth_infinity,
+                        repos_url, committed_rev, NULL, NULL, NULL, NULL,
+                        pool));
+
+    SVN_ERR(svn_wc_adm_retrieve(&adm2, adm_access, ex2_dir_path, pool));
+    SVN_TEST_ASSERT(adm2 != NULL && "available in set");
+
+    SVN_ERR(svn_wc_adm_close2(adm_access, pool));
+  }
+
+  /* Some simple status calls to verify that the paths are added */
+  {
+    svn_wc_status3_t *status;
+
+    SVN_ERR(svn_wc_status3(&status, ctx->wc_ctx, new_dir_path, pool, pool));
+
+    SVN_TEST_ASSERT(status->node_status == svn_wc_status_added
+                    && status->copied
+                    && !strcmp(status->repos_relpath, "NEW"));
+
+    SVN_ERR(svn_wc_status3(&status, ctx->wc_ctx, ex_file_path, pool, pool));
+
+    SVN_TEST_ASSERT(status->node_status == svn_wc_status_added
+                    && !status->copied);
+
+    SVN_ERR(svn_wc_status3(&status, ctx->wc_ctx, ex_dir_path, pool, pool));
+
+    SVN_TEST_ASSERT(status->node_status == svn_wc_status_added
+                    && !status->copied);
+
+    SVN_ERR(svn_wc_status3(&status, ctx->wc_ctx, ex2_dir_path, pool, pool));
+
+    SVN_TEST_ASSERT(status->node_status == svn_wc_status_added
+                    && status->copied);
+  }
+
+  /* ### Add a commit? */
+
+  return SVN_NO_ERROR;
+}
+
 /* ========================================================================== */
 
 struct svn_test_descriptor_t test_funcs[] =
@@ -410,5 +543,6 @@ struct svn_test_descriptor_t test_funcs[
     SVN_TEST_PASS2(test_args_to_target_array,
                    "test svn_client_args_to_target_array"),
     SVN_TEST_OPTS_PASS(test_patch, "test svn_client_patch"),
+    SVN_TEST_OPTS_PASS(test_wc_add_scenarios, "test svn_wc_add3 scenarios"),
     SVN_TEST_NULL
   };



Mime
View raw message