subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1758042 - /subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c
Date Sat, 27 Aug 2016 14:10:16 GMT
Author: stsp
Date: Sat Aug 27 14:10:16 2016
New Revision: 1758042

URL: http://svn.apache.org/viewvc?rev=1758042&view=rev
Log:
Extend resolver regression test to illustrate broken behaviour when
merging into copied directories which are part of an incoming move.

When merging an incoming dir move from trunk to branch, if children were added
on the trunk, these children trunk are present in the working copy but with
wrong URLs and they are missing from the resulting merge commit.

* subversion/tests/libsvn_client/conflicts-test.c
  (info_baton, info_func): New helper callback.
  (new_file_name_branch): New global.
  (create_wc_with_incoming_delete_dir_conflict): Create a file on the trunk,
   inside the directory which is about to be deleted/moved.
  (create_wc_with_incoming_delete_dir_conflict): Extend by adding dir/file on
   the trunk before moving dir -> dir2.
  (test_merge_incoming_move_dir3): Verify expected status of file added on
   trunk before dir was moved. Also, commit the merge result and ensure that
   both the file added on branch and the file added on trunk are present.

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=1758042&r1=1758041&r2=1758042&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_client/conflicts-test.c Sat Aug 27 14:10:16 2016
@@ -52,6 +52,25 @@ status_func(void *baton, const char *pat
   return SVN_NO_ERROR;
 }
 
+struct info_baton
+{
+  svn_client_info2_t *info;
+  apr_pool_t *result_pool;
+};
+
+/* Implements svn_client_info_receiver2_t */
+static svn_error_t *
+info_func(void *baton, const char *abspath_or_url,
+          const svn_client_info2_t *info,
+          apr_pool_t *scratch_pool)
+{
+  struct info_baton *ib = baton;
+
+  ib->info = svn_client_info2_dup(info, ib->result_pool);
+
+  return SVN_NO_ERROR;
+}
+
 /* 
  * The following tests verify resolution of "incoming file add vs.
  * local file obstruction upon merge" tree conflicts.
@@ -61,6 +80,7 @@ status_func(void *baton, const char *pat
 static const char *trunk_path = "A";
 static const char *branch_path = "A_branch";
 static const char *new_file_name = "newfile.txt";
+static const char *new_file_name_branch = "newfile-on-branch.txt";
 static const char *deleted_file_name = "mu";
 static const char *deleted_dir_name = "B";
 static const char *deleted_dir_child = "lambda";
@@ -2012,6 +2032,7 @@ create_wc_with_incoming_delete_dir_confl
   svn_opt_revision_t opt_rev;
   const char *deleted_path;
   const char *deleted_child_path;
+  const char *new_file_path;
 
   SVN_ERR(sbox_add_and_commit_greek_tree(b));
 
@@ -2019,6 +2040,17 @@ create_wc_with_incoming_delete_dir_confl
   SVN_ERR(sbox_wc_copy(b, trunk_path, branch_path));
   SVN_ERR(sbox_wc_commit(b, ""));
 
+  /* On the trunk, add a file inside the dir about to be moved/deleted. */
+  new_file_path = svn_relpath_join(trunk_path,
+                                   svn_relpath_join(deleted_dir_name,
+                                                    new_file_name, b->pool),
+                                   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_commit(b, ""));
+
+  SVN_ERR(sbox_wc_update(b, "", SVN_INVALID_REVNUM));
   if (move)
     {
       const char *move_target_path;
@@ -2043,7 +2075,7 @@ create_wc_with_incoming_delete_dir_confl
       
       new_child_path = svn_relpath_join(branch_path,
                                         svn_relpath_join(deleted_dir_name,
-                                                         new_file_name,
+                                                         new_file_name_branch,
                                                          b->pool),
                                         b->pool);
       /* Add new file on the branch. */
@@ -2290,8 +2322,10 @@ test_merge_incoming_move_dir3(const svn_
   const char *deleted_path;
   const char *moved_to_path;
   const char *child_path;
+  const char *child_url;
   svn_client_conflict_t *conflict;
   struct status_baton sb;
+  struct info_baton ib;
   struct svn_client_status_t *status;
   svn_stringbuf_t *buf;
   svn_stream_t *stream;
@@ -2356,10 +2390,10 @@ test_merge_incoming_move_dir3(const svn_
                          sbox_wc_path(b, deleted_path));
   SVN_TEST_ASSERT(status->moved_to_abspath == NULL);
 
-  /* Ensure that the added file has the expected content. */
+  /* Ensure that the file added on the branch has the expected content. */
   child_path = svn_relpath_join(branch_path,
                                 svn_relpath_join(new_dir_name,
-                                                 new_file_name,
+                                                 new_file_name_branch,
                                                  b->pool),
                                 b->pool);
   SVN_ERR(svn_stream_open_readonly(&stream, sbox_wc_path(b, child_path),
@@ -2368,7 +2402,39 @@ test_merge_incoming_move_dir3(const svn_
   SVN_ERR(svn_stream_close(stream));
   SVN_TEST_STRING_ASSERT(buf->data, added_file_on_branch_content);
 
-  /* Ensure that the added file has the expected status. */
+  /* Ensure that the file added on the branch has the expected status. */
+  sb.result_pool = b->pool;
+  opt_rev.kind = svn_opt_revision_working;
+  SVN_ERR(svn_client_status6(NULL, ctx, sbox_wc_path(b, child_path),
+                             &opt_rev, svn_depth_empty, 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_added);
+  SVN_TEST_ASSERT(status->text_status == svn_wc_status_normal);
+  SVN_TEST_ASSERT(status->prop_status == svn_wc_status_normal);
+  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 file added on the trunk has the expected content. */
+  child_path = svn_relpath_join(trunk_path,
+                                svn_relpath_join(new_dir_name,
+                                                 new_file_name,
+                                                 b->pool),
+                                b->pool);
+  SVN_ERR(svn_stream_open_readonly(&stream, sbox_wc_path(b, child_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, "This is a new file on the trunk\n");
+
+  /* Ensure that the file added on the trunk has the expected status. */
   sb.result_pool = b->pool;
   opt_rev.kind = svn_opt_revision_working;
   SVN_ERR(svn_client_status6(NULL, ctx, sbox_wc_path(b, child_path),
@@ -2388,6 +2454,26 @@ test_merge_incoming_move_dir3(const svn_
   SVN_TEST_ASSERT(status->moved_from_abspath == NULL);
   SVN_TEST_ASSERT(status->moved_to_abspath == NULL);
 
+  /* Commit and make sure both files are present in the resulting revision. */
+  SVN_ERR(sbox_wc_commit(b, ""));
+
+  ib.result_pool = b->pool;
+  opt_rev.kind = svn_opt_revision_head;
+
+  /* The file added on the branch should be present. */
+  child_url = apr_pstrcat(b->pool, b->repos_url, "/", branch_path, "/",
+                          new_dir_name, "/", new_file_name_branch, SVN_VA_NULL);
+  SVN_ERR(svn_client_info4(child_url, &opt_rev, &opt_rev, svn_depth_empty,
+                           TRUE, TRUE, TRUE, NULL,
+                           info_func, &ib, ctx, b->pool));
+
+  /* The file added on the trunk should be present. */
+  child_url = apr_pstrcat(b->pool, b->repos_url, "/", branch_path, "/",
+                          new_dir_name, "/", new_file_name, SVN_VA_NULL);
+  SVN_ERR(svn_client_info4(child_url, &opt_rev, &opt_rev, svn_depth_empty,
+                           TRUE, TRUE, TRUE, NULL,
+                           info_func, &ib, ctx, b->pool));
+
   return SVN_NO_ERROR;
 }
 



Mime
View raw message