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/21 08:56:13 UTC

svn commit: r1749472 - in /subversion/trunk/subversion: include/svn_client.h libsvn_client/conflicts.c svn/conflict-callbacks.c tests/libsvn_client/conflicts-test.c tests/libsvn_wc/utils.c

Author: stsp
Date: Tue Jun 21 08:56:13 2016
New Revision: 1749472

URL: http://svn.apache.org/viewvc?rev=1749472&view=rev
Log:
Apply the 'incoming add ignore' conflict resolver option to update and switch,
and add a regression test for the update case.

It is currently impossible to create an add vs add update tree conflict with
the 'svn' command line client because it sets 'adds_as_modifications' to TRUE
when calling svn_client_update(). The new test relies on the fact that the test
suite sets it to FALSE instead.

* subversion/include/svn_client.h
  (svn_client_conflict_option_merge_incoming_add_ignore): Rename to ...
  (svn_client_conflict_option_incoming_add_ignore): ... this, because the option
   does not only apply to merge anymore.

* subversion/libsvn_client/conflicts.c
  (resolve_merge_incoming_add_ignore): Rename to ...
  (resolve_incoming_add_ignore): ... this.
  (configure_option_merge_incoming_add_ignore): Track renames. Allow this option
   for update and switch, too.

* subversion/svn/conflict-callbacks.c
  (builtin_resolver_options): Track renames.

* subversion/tests/libsvn_client/conflicts-test.c
  (test_option_merge_incoming_added_file_ignore,
   test_option_merge_incoming_added_dir_ignore): Track renames.
  (create_wc_with_file_add_vs_file_add_update_conflict): New helper function.
  (test_option_update_incoming_added_file_ignore): New test.
  (test_funcs): Adjust a docstring and add new test.

* subversion/tests/libsvn_wc/utils.c
  (sbox_wc_update_depth): Add a comment pointing out the dependency of the
   newly added test on this function passing FALSE for adds_as_modifications.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/libsvn_client/conflicts.c
    subversion/trunk/subversion/svn/conflict-callbacks.c
    subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c
    subversion/trunk/subversion/tests/libsvn_wc/utils.c

Modified: subversion/trunk/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1749472&r1=1749471&r2=1749472&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Tue Jun 21 08:56:13 2016
@@ -4406,8 +4406,8 @@ typedef enum svn_client_conflict_option_
   /* Options for local delete/replace vs incoming edit on update. */
   svn_client_conflict_option_update_any_moved_away_children,
 
-  /* Options for incoming add vs local 'obstruction' on merge. */
-  svn_client_conflict_option_merge_incoming_add_ignore,
+  /* Options for incoming add vs local 'obstruction'. */
+  svn_client_conflict_option_incoming_add_ignore,
 
   /* Options for incoming file add vs local file 'obstruction' on merge. */
   svn_client_conflict_option_merge_incoming_added_file_text_merge,

Modified: subversion/trunk/subversion/libsvn_client/conflicts.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/conflicts.c?rev=1749472&r1=1749471&r2=1749472&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/conflicts.c (original)
+++ subversion/trunk/subversion/libsvn_client/conflicts.c Tue Jun 21 08:56:13 2016
@@ -4802,9 +4802,9 @@ resolve_update_moved_away_node(svn_clien
 
 /* Implements conflict_option_resolve_func_t. */
 static svn_error_t *
-resolve_merge_incoming_add_ignore(svn_client_conflict_option_t *option,
-                                  svn_client_conflict_t *conflict,
-                                  apr_pool_t *scratch_pool)
+resolve_incoming_add_ignore(svn_client_conflict_option_t *option,
+                            svn_client_conflict_t *conflict,
+                            apr_pool_t *scratch_pool)
 {
   const char *local_abspath;
   const char *lock_abspath;
@@ -6530,17 +6530,16 @@ configure_option_merge_incoming_add_igno
             NULL, conflict, scratch_pool,
             scratch_pool));
 
-  if (operation == svn_wc_operation_merge &&
-      incoming_change == svn_wc_conflict_action_add &&
-      local_change == svn_wc_conflict_reason_obstructed)
+  if (incoming_change == svn_wc_conflict_action_add &&
+      (local_change == svn_wc_conflict_reason_obstructed ||
+       local_change == svn_wc_conflict_reason_added))
     {
       svn_client_conflict_option_t *option;
       const char *wcroot_abspath;
 
       option = apr_pcalloc(options->pool, sizeof(*option));
       option->pool = options->pool;
-      option->id =
-        svn_client_conflict_option_merge_incoming_add_ignore;
+      option->id = svn_client_conflict_option_incoming_add_ignore;
       SVN_ERR(svn_wc__get_wcroot(&wcroot_abspath, conflict->ctx->wc_ctx,
                                  conflict->local_abspath, scratch_pool,
                                  scratch_pool));
@@ -6548,7 +6547,7 @@ configure_option_merge_incoming_add_igno
         apr_psprintf(options->pool, _("ignore and do not add '^/%s@%ld' here"),
           incoming_new_repos_relpath, incoming_new_pegrev);
       option->conflict = conflict;
-      option->do_resolve_func = resolve_merge_incoming_add_ignore;
+      option->do_resolve_func = resolve_incoming_add_ignore;
       APR_ARRAY_PUSH(options, const svn_client_conflict_option_t *) = option;
     }
 

Modified: subversion/trunk/subversion/svn/conflict-callbacks.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/conflict-callbacks.c?rev=1749472&r1=1749471&r2=1749472&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/conflict-callbacks.c (original)
+++ subversion/trunk/subversion/svn/conflict-callbacks.c Tue Jun 21 08:56:13 2016
@@ -419,9 +419,9 @@ static const resolver_option_t builtin_r
   { "u", N_("update any moved-away children"), NULL,
     svn_client_conflict_option_update_any_moved_away_children },
 
-  /* Options for incoming add vs local add upon merge. */
+  /* Options for incoming add vs local add. */
   { "i", N_("ignore incoming addition"), NULL,
-    svn_client_conflict_option_merge_incoming_add_ignore },
+    svn_client_conflict_option_incoming_add_ignore },
 
   /* Options for incoming file add vs local file add upon merge. */
   { "m", N_("merge the files"), NULL,

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=1749472&r1=1749471&r2=1749472&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c Tue Jun 21 08:56:13 2016
@@ -186,9 +186,7 @@ test_option_merge_incoming_added_file_ig
   SVN_ERR(svn_client_conflict_get(&conflict, sbox_wc_path(b, new_file_path),
                                   ctx, b->pool, b->pool));
   SVN_ERR(svn_client_conflict_tree_resolve_by_id(
-            conflict,
-            svn_client_conflict_option_merge_incoming_add_ignore,
-            b->pool));
+            conflict, svn_client_conflict_option_incoming_add_ignore, b->pool));
 
   /* Ensure that the file has the expected status. */
   opt_rev.kind = svn_opt_revision_working;
@@ -454,6 +452,152 @@ test_option_merge_incoming_added_file_re
   return SVN_NO_ERROR;
 }
 
+/* A helper function which prepares a working copy for the tests below. */
+static svn_error_t *
+create_wc_with_file_add_vs_file_add_update_conflict(svn_test__sandbox_t *b)
+{
+  static const char *new_file_path;
+  svn_client_ctx_t *ctx;
+  svn_opt_revision_t opt_rev;
+  svn_client_status_t *status;
+  struct status_baton sb;
+  svn_client_conflict_t *conflict;
+  svn_boolean_t tree_conflicted;
+
+  SVN_ERR(sbox_add_and_commit_greek_tree(b));
+
+  /* Add and commit a new file. */
+  new_file_path = svn_relpath_join(trunk_path, new_file_name, b->pool);
+  SVN_ERR(sbox_file_write(b, new_file_path,
+                          "This is a new file on the trunk\n"));
+  SVN_ERR(sbox_wc_add(b, new_file_path));
+  SVN_ERR(sbox_wc_propset(b, "prop", propval_trunk, new_file_path));
+  SVN_ERR(sbox_wc_commit(b, ""));
+
+  /* Back-date the WC. */
+  SVN_ERR(sbox_wc_update(b, "", 1));
+
+  /* Add a file which occupies the same path but has different content
+   * and properties. */
+  SVN_ERR(sbox_file_write(b, new_file_path,
+                          /* NB: Ensure that the file content's length differs!
+                           * Tests are run without sleep for timestamps. */
+                          "This is a new file on the branch\n"));
+  SVN_ERR(sbox_wc_add(b, new_file_path));
+  SVN_ERR(sbox_wc_propset(b, "prop", propval_branch, new_file_path));
+
+  /* Update the WC.
+   * This should raise an "incoming add vs local add" tree conflict because
+   * the sbox test code runs updates with 'adds_as_modifications == FALSE'. */
+  SVN_ERR(sbox_wc_update(b, "", SVN_INVALID_REVNUM));
+
+  /* Ensure that the file has the expected status. */
+  SVN_ERR(svn_test__create_client_ctx(&ctx, b, b->pool));
+  opt_rev.kind = svn_opt_revision_head;
+  sb.result_pool = 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_replaced);
+  SVN_TEST_ASSERT(status->text_status == svn_wc_status_modified);
+  SVN_TEST_ASSERT(status->prop_status == svn_wc_status_modified);
+  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);
+
+  SVN_ERR(svn_client_conflict_get(&conflict, sbox_wc_path(b, new_file_path),
+                                  ctx, b->pool, b->pool));
+
+  /* Ensure that the expected tree conflict is present. */
+  SVN_ERR(svn_client_conflict_get_conflicted(NULL, NULL, &tree_conflicted,
+                                             conflict, b->pool, b->pool));
+  SVN_TEST_ASSERT(tree_conflicted);
+  SVN_TEST_ASSERT(svn_client_conflict_get_local_change(conflict) ==
+                  svn_wc_conflict_reason_added);
+  SVN_TEST_ASSERT(svn_client_conflict_get_incoming_change(conflict) ==
+                  svn_wc_conflict_action_add);
+
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+test_option_update_incoming_added_file_ignore(const svn_test_opts_t *opts,
+                                              apr_pool_t *pool)
+{
+  svn_client_ctx_t *ctx;
+  svn_client_conflict_t *conflict;
+  const char *new_file_path;
+  svn_boolean_t text_conflicted;
+  apr_array_header_t *props_conflicted;
+  svn_boolean_t tree_conflicted;
+  struct status_baton sb;
+  struct svn_client_status_t *status;
+  svn_opt_revision_t opt_rev;
+  const svn_string_t *propval;
+
+  svn_test__sandbox_t *b = apr_palloc(pool, sizeof(*b));
+
+  SVN_ERR(svn_test__sandbox_create(b, "update_incoming_added_file_ignore",
+                                   opts, pool));
+
+  SVN_ERR(create_wc_with_file_add_vs_file_add_update_conflict(b));
+
+  /* Resolve the tree conflict. */
+  SVN_ERR(svn_test__create_client_ctx(&ctx, b, b->pool));
+  new_file_path = svn_relpath_join(trunk_path, new_file_name, b->pool);
+  SVN_ERR(svn_client_conflict_get(&conflict, sbox_wc_path(b, new_file_path),
+                                  ctx, b->pool, b->pool));
+  SVN_ERR(svn_client_conflict_tree_resolve_by_id(
+            conflict, svn_client_conflict_option_incoming_add_ignore, b->pool));
+
+  /* Ensure that the file has the expected status. */
+  opt_rev.kind = svn_opt_revision_head;
+  sb.result_pool = 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_replaced);
+  SVN_TEST_ASSERT(status->text_status == svn_wc_status_modified);
+  SVN_TEST_ASSERT(status->prop_status == svn_wc_status_modified);
+  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);
+
+  SVN_ERR(svn_client_conflict_get(&conflict, sbox_wc_path(b, new_file_path),
+                                  ctx, b->pool, b->pool));
+
+  /* The file should not be in conflict. */
+  SVN_ERR(svn_client_conflict_get_conflicted(&text_conflicted,
+                                             &props_conflicted,
+                                             &tree_conflicted,
+                                             conflict, b->pool, b->pool));
+  SVN_TEST_ASSERT(!text_conflicted &&
+                  props_conflicted->nelts == 0 &&
+                  !tree_conflicted);
+
+  /* Verify the merged property value. */
+  SVN_ERR(svn_wc_prop_get2(&propval, ctx->wc_ctx,
+                           sbox_wc_path(b, new_file_path),
+                           "prop", b->pool, b->pool));
+  SVN_TEST_STRING_ASSERT(propval->data, propval_branch);
+
+  return SVN_NO_ERROR;
+}
+
 /* 
  * The following tests verify resolution of "incoming dir add vs.
  * local dir obstruction upon merge" tree conflicts.
@@ -621,9 +765,7 @@ test_option_merge_incoming_added_dir_ign
   SVN_ERR(svn_client_conflict_get(&conflict, sbox_wc_path(b, new_dir_path),
                                   ctx, b->pool, b->pool));
   SVN_ERR(svn_client_conflict_tree_resolve_by_id(
-            conflict,
-            svn_client_conflict_option_merge_incoming_add_ignore,
-            b->pool));
+            conflict, svn_client_conflict_option_incoming_add_ignore, b->pool));
 
   /* Ensure that the directory has the expected status. */
   opt_rev.kind = svn_opt_revision_working;
@@ -1689,13 +1831,15 @@ static struct svn_test_descriptor_t test
   {
     SVN_TEST_NULL,
     SVN_TEST_OPTS_PASS(test_option_merge_incoming_added_file_ignore,
-                       "test incoming add file ignore"),
+                       "test merge incoming add file ignore"),
     SVN_TEST_OPTS_PASS(test_option_merge_incoming_added_file_text_merge,
                        "test incoming add file text merge"),
     SVN_TEST_OPTS_PASS(test_option_merge_incoming_added_file_replace,
                        "test incoming add file replace"),
     SVN_TEST_OPTS_PASS(test_option_merge_incoming_added_file_replace_and_merge,
                        "test incoming add file replace and merge"),
+    SVN_TEST_OPTS_PASS(test_option_update_incoming_added_file_ignore,
+                       "test update incoming add file ignore"),
     SVN_TEST_OPTS_PASS(test_option_merge_incoming_added_dir_ignore,
                        "test incoming add dir ignore"),
     SVN_TEST_OPTS_XFAIL(test_option_merge_incoming_added_dir_merge,

Modified: subversion/trunk/subversion/tests/libsvn_wc/utils.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/utils.c?rev=1749472&r1=1749471&r2=1749472&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/utils.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/utils.c Tue Jun 21 08:56:13 2016
@@ -530,6 +530,9 @@ sbox_wc_update_depth(svn_test__sandbox_t
   APR_ARRAY_PUSH(paths, const char *) = sbox_wc_path(b, path);
   SVN_ERR(svn_test__create_client_ctx(&ctx, b, b->pool));
 
+  /* Note: Tree conflict resolver tests for libsvn_client depend on this
+   * passing FALSE for adds_as_modifications so that tree conflicts are
+   * created in case of add vs add upon update. */
   return svn_client_update4(&result_revs, paths, &revision, depth,
                             sticky, FALSE, FALSE, FALSE, FALSE,
                             ctx, b->pool);