You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2016/06/13 14:32:27 UTC

svn commit: r1748244 - /subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c

Author: stsp
Date: Mon Jun 13 14:32:27 2016
New Revision: 1748244

URL: http://svn.apache.org/viewvc?rev=1748244&view=rev
Log:
Add another reggression test for the conflict resolver.

* subversion/tests/libsvn_client/conflicts-test.c
  (test_option_merge_incoming_move_file_text_merge): Adjust docstring.
  (create_wc_with_incoming_delete_update_conflict): New test for the
   'incoming file move vs local file edit upon update' case.
  (test_funcs): Add new test.

Modified:
    subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c

Modified: subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c?rev=1748244&r1=1748243&r2=1748244&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c Mon Jun 13 14:32:27 2016
@@ -1388,7 +1388,7 @@ test_option_merge_incoming_delete_accept
   return SVN_NO_ERROR;
 }
 
-/* Test 'incoming move file text merge' option. */
+/* Test 'incoming move file text merge' option for merge. */
 static svn_error_t *
 test_option_merge_incoming_move_file_text_merge(
   const svn_test_opts_t *opts, apr_pool_t *pool)
@@ -1487,6 +1487,114 @@ test_option_merge_incoming_move_file_tex
   return SVN_NO_ERROR;
 }
 
+/* A helper function which prepares a working copy for the tests below. */
+static svn_error_t *
+create_wc_with_incoming_delete_update_conflict(svn_test__sandbox_t *b,
+                                               svn_boolean_t move)
+{
+  const char *deleted_path;
+
+  SVN_ERR(sbox_add_and_commit_greek_tree(b));
+
+  if (move)
+    {
+      const char *move_target_path;
+
+      /* Move a file on the trunk. */
+      deleted_path = svn_relpath_join(trunk_path, deleted_file_name, b->pool);
+      move_target_path = svn_relpath_join(trunk_path, new_file_name, b->pool);
+      SVN_ERR(sbox_wc_move(b, deleted_path, move_target_path));
+      SVN_ERR(sbox_wc_commit(b, ""));
+    }
+  else
+    {
+      /* Delete a file on the trunk. */
+      deleted_path = svn_relpath_join(trunk_path, deleted_file_name, b->pool);
+      SVN_ERR(sbox_wc_delete(b, deleted_path));
+      SVN_ERR(sbox_wc_commit(b, ""));
+    }
+
+  /* Update into the past. */
+  SVN_ERR(sbox_wc_update(b, "", 1));
+
+  /* Modify a file in the working copy. */
+  deleted_path = svn_relpath_join(trunk_path, deleted_file_name, b->pool);
+  SVN_ERR(sbox_file_write(b, deleted_path, modified_file_on_branch_content));
+
+  /* Update to HEAD.
+   * This should raise an "incoming delete vs local edit" tree conflict. */
+  SVN_ERR(sbox_wc_update(b, "", SVN_INVALID_REVNUM));
+
+  return SVN_NO_ERROR;
+}
+
+/* Test 'incoming move file text merge' option for update. */
+static svn_error_t *
+test_option_update_incoming_move_file_text_merge(
+  const svn_test_opts_t *opts, apr_pool_t *pool)
+{
+  svn_test__sandbox_t *b = apr_palloc(pool, sizeof(*b));
+  svn_client_ctx_t *ctx;
+  const char *deleted_path;
+  const char *new_file_path;
+  svn_client_conflict_t *conflict;
+  struct status_baton sb;
+  struct svn_client_status_t *status;
+  svn_opt_revision_t opt_rev;
+  svn_node_kind_t node_kind;
+  svn_stream_t *stream;
+  svn_stringbuf_t *buf;
+
+  SVN_ERR(svn_test__sandbox_create(b, "update_incoming_move_file_text_merge",
+                                   opts, pool));
+
+  SVN_ERR(create_wc_with_incoming_delete_update_conflict(b, TRUE));
+
+  /* Resolve the tree conflict. */
+  SVN_ERR(svn_test__create_client_ctx(&ctx, b, b->pool));
+  deleted_path = svn_relpath_join(trunk_path, deleted_file_name, b->pool);
+  SVN_ERR(svn_client_conflict_get(&conflict, sbox_wc_path(b, deleted_path),
+                                  ctx, b->pool, b->pool));
+  SVN_ERR(svn_client_conflict_tree_get_details(conflict, b->pool));
+  SVN_ERR(svn_client_conflict_tree_resolve_by_id(
+            conflict, svn_client_conflict_option_incoming_move_file_text_merge,
+            b->pool));
+
+  /* Ensure that the deleted file is gone. */
+  SVN_ERR(svn_io_check_path(sbox_wc_path(b, deleted_path), &node_kind,
+                            b->pool));
+  SVN_TEST_ASSERT(node_kind == svn_node_none);
+
+  /* Ensure that the moved file has the expected status. */
+  opt_rev.kind = svn_opt_revision_working;
+  sb.result_pool = b->pool;
+  new_file_path = svn_relpath_join(trunk_path, new_file_name, b->pool);
+  SVN_ERR(svn_client_status6(NULL, ctx, sbox_wc_path(b, new_file_path),
+                             &opt_rev, svn_depth_unknown, TRUE, TRUE,
+                             TRUE, TRUE, FALSE, TRUE, NULL,
+                             status_func, &sb, b->pool));
+  status = sb.status;
+  SVN_TEST_ASSERT(status->kind == svn_node_file);
+  SVN_TEST_ASSERT(status->versioned);
+  SVN_TEST_ASSERT(!status->conflicted);
+  SVN_TEST_ASSERT(status->node_status == svn_wc_status_modified);
+  SVN_TEST_ASSERT(status->text_status == svn_wc_status_modified);
+  SVN_TEST_ASSERT(status->prop_status == svn_wc_status_none);
+  SVN_TEST_ASSERT(!status->copied);
+  SVN_TEST_ASSERT(!status->switched);
+  SVN_TEST_ASSERT(!status->file_external);
+  SVN_TEST_ASSERT(status->moved_from_abspath == NULL);
+  SVN_TEST_ASSERT(status->moved_to_abspath == NULL);
+
+  /* Ensure that the moved file has the expected content. */
+  SVN_ERR(svn_stream_open_readonly(&stream, sbox_wc_path(b, new_file_path),
+                                   b->pool, b->pool));
+  SVN_ERR(svn_stringbuf_from_stream(&buf, stream, 0, b->pool));
+  SVN_ERR(svn_stream_close(stream));
+  SVN_TEST_STRING_ASSERT(buf->data, modified_file_on_branch_content);
+
+  return SVN_NO_ERROR;
+}
 /* ========================================================================== */
 
 
@@ -1523,6 +1631,8 @@ static struct svn_test_descriptor_t test
                        "test merge incoming delete accept"),
     SVN_TEST_OPTS_PASS(test_option_merge_incoming_move_file_text_merge,
                        "test merge incoming move file text merge"),
+    SVN_TEST_OPTS_PASS(test_option_update_incoming_move_file_text_merge,
+                       "test update incoming move file text merge"),
     SVN_TEST_NULL
   };