You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2015/03/02 17:29:14 UTC

svn commit: r1663347 - in /subversion/trunk/subversion: libsvn_wc/conflicts.c tests/libsvn_wc/conflict-data-test.c tests/libsvn_wc/utils.c tests/libsvn_wc/utils.h

Author: rhuijben
Date: Mon Mar  2 16:29:14 2015
New Revision: 1663347

URL: http://svn.apache.org/r1663347
Log:
Following up on r1663338, enable resolving individual property conflicts
via svn_wc__resolve_conflicts(). This allows accessing a feature that was
already available when passing a callback, but not directly.

Use this to add a regression test for the problems fixed in r1663338.

* subversion/libsvn_wc/conflicts.c
  (svn_wc__resolve_conflicts): Remove limitation.

* subversion/tests/libsvn_wc/conflict-data-test.c
  (test_prop_conflict_resolving): New function
  (test_list): Add test_prop_conflict_resolving.

* subversion/tests/libsvn_wc/utils.c
  (sbox_wc_resolve_prop): New function.

* subversion/tests/libsvn_wc/utils.h
  (sbox_wc_resolve_prop): New function.

Modified:
    subversion/trunk/subversion/libsvn_wc/conflicts.c
    subversion/trunk/subversion/tests/libsvn_wc/conflict-data-test.c
    subversion/trunk/subversion/tests/libsvn_wc/utils.c
    subversion/trunk/subversion/tests/libsvn_wc/utils.h

Modified: subversion/trunk/subversion/libsvn_wc/conflicts.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/conflicts.c?rev=1663347&r1=1663346&r2=1663347&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/conflicts.c (original)
+++ subversion/trunk/subversion/libsvn_wc/conflicts.c Mon Mar  2 16:29:14 2015
@@ -3094,13 +3094,6 @@ svn_wc__resolve_conflicts(svn_wc_context
   apr_pool_t *iterpool = NULL;
   svn_error_t *err;
 
-  /* ### the underlying code does NOT support resolving individual
-     ### properties. bail out if the caller tries it.  */
-  if (resolve_prop != NULL && *resolve_prop != '\0')
-    return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
-                            U_("Resolving a single property is not (yet) "
-                               "supported."));
-
   /* ### Just a versioned check? */
   /* Conflicted is set to allow invoking on actual only nodes */
   SVN_ERR(svn_wc__db_read_info(NULL, &kind, NULL, NULL, NULL, NULL, NULL,

Modified: subversion/trunk/subversion/tests/libsvn_wc/conflict-data-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/conflict-data-test.c?rev=1663347&r1=1663346&r2=1663347&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/conflict-data-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/conflict-data-test.c Mon Mar  2 16:29:14 2015
@@ -809,6 +809,108 @@ test_prop_conflicts(const svn_test_opts_
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+test_prop_conflict_resolving(const svn_test_opts_t *opts,
+                             apr_pool_t *pool)
+{
+  svn_test__sandbox_t b;
+  svn_skel_t *conflict;
+  const char *A_abspath;
+  const char *marker_abspath;
+  apr_hash_t *conflicted_props;
+  apr_hash_t *props;
+  const char *value;
+
+  SVN_ERR(svn_test__sandbox_create(&b, "test_prop_resolving", opts, pool));
+  SVN_ERR(sbox_wc_mkdir(&b, "A"));
+
+  SVN_ERR(sbox_wc_propset(&b, "prop-1", "r1", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-2", "r1", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-3", "r1", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-4", "r1", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-5", "r1", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-6", "r1", "A"));
+
+  SVN_ERR(sbox_wc_commit(&b, ""));
+  SVN_ERR(sbox_wc_propset(&b, "prop-1", "r2", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-2", "r2", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-3", "r2", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-4", NULL, "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-5", NULL, "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-7", "r2", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-8", "r2", "A"));
+  SVN_ERR(sbox_wc_commit(&b, ""));
+
+  SVN_ERR(sbox_wc_propset(&b, "prop-1", "mod", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-2", "mod", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-3", "mod", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-4", "mod", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-5", "mod", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-6", "mod", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-7", "mod", "A"));
+  SVN_ERR(sbox_wc_propset(&b, "prop-8", "mod", "A"));
+
+  SVN_ERR(sbox_wc_update(&b, "", 1));
+
+  A_abspath = sbox_wc_path(&b, "A");
+  SVN_ERR(svn_wc__db_read_conflict(&conflict, NULL,
+                                   b.wc_ctx->db, A_abspath,
+                                   pool, pool));
+
+  /* We have tree conflicts... */
+  SVN_TEST_ASSERT(conflict != NULL);
+
+  SVN_ERR(svn_wc__conflict_read_prop_conflict(&marker_abspath,
+                                              NULL, NULL, NULL,
+                                              &conflicted_props,
+                                              b.wc_ctx->db, A_abspath,
+                                              conflict,
+                                              pool, pool));
+
+  SVN_TEST_ASSERT(conflicted_props != NULL);
+  /* All properties but r6 are conflicted */
+  SVN_TEST_ASSERT(apr_hash_count(conflicted_props) == 7);
+  SVN_TEST_ASSERT(! svn_hash_gets(conflicted_props, "prop-6"));
+
+  /* Let's resolve a few conflicts */
+  SVN_ERR(sbox_wc_resolve_prop(&b, "A", "prop-1",
+                               svn_wc_conflict_choose_mine_conflict));
+  SVN_ERR(sbox_wc_resolve_prop(&b, "A", "prop-2",
+                               svn_wc_conflict_choose_theirs_conflict));
+  SVN_ERR(sbox_wc_resolve_prop(&b, "A", "prop-3",
+                               svn_wc_conflict_choose_merged));
+
+  SVN_ERR(svn_wc__db_read_conflict(&conflict, NULL,
+                                   b.wc_ctx->db, A_abspath,
+                                   pool, pool));
+
+  /* We have tree conflicts... */
+  SVN_TEST_ASSERT(conflict != NULL);
+
+  SVN_ERR(svn_wc__conflict_read_prop_conflict(&marker_abspath,
+                                              NULL, NULL, NULL,
+                                              &conflicted_props,
+                                              b.wc_ctx->db, A_abspath,
+                                              conflict,
+                                              pool, pool));
+
+  SVN_TEST_ASSERT(conflicted_props != NULL);
+  SVN_TEST_ASSERT(apr_hash_count(conflicted_props) == 4);
+
+  SVN_ERR(svn_wc__db_read_props(&props, b.wc_ctx->db, A_abspath,
+                                pool, pool));
+
+  value = svn_prop_get_value(props, "prop-1");
+  SVN_TEST_STRING_ASSERT(value, "mod");
+  value = svn_prop_get_value(props, "prop-2");
+  SVN_TEST_STRING_ASSERT(value, "r1");
+  value = svn_prop_get_value(props, "prop-3");
+  SVN_TEST_STRING_ASSERT(value, "mod");
+  
+  return SVN_NO_ERROR;
+}
+
+
 /* The test table.  */
 
 static int max_threads = 1;
@@ -830,6 +932,8 @@ static struct svn_test_descriptor_t test
                        "read and write a tree conflict"),
     SVN_TEST_OPTS_PASS(test_prop_conflicts,
                        "test prop conflicts"),
+    SVN_TEST_OPTS_PASS(test_prop_conflict_resolving,
+                       "test property conflict resolving"),
     SVN_TEST_NULL
   };
 

Modified: subversion/trunk/subversion/tests/libsvn_wc/utils.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/utils.c?rev=1663347&r1=1663346&r2=1663347&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/utils.c (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/utils.c Mon Mar  2 16:29:14 2015
@@ -599,6 +599,35 @@ sbox_wc_resolve(svn_test__sandbox_t *b,
 }
 
 svn_error_t *
+sbox_wc_resolve_prop(svn_test__sandbox_t *b, const char *path,
+                     const char *propname,
+                     svn_wc_conflict_choice_t conflict_choice)
+{
+  const char *lock_abspath;
+  svn_error_t *err;
+
+  SVN_ERR(svn_wc__acquire_write_lock_for_resolve(&lock_abspath, b->wc_ctx,
+                                                 sbox_wc_path(b, path),
+                                                 b->pool, b->pool));
+  err = svn_wc__resolve_conflicts(b->wc_ctx, sbox_wc_path(b, path),
+                                  svn_depth_empty,
+                                  FALSE,
+                                  propname,
+                                  FALSE,
+                                  conflict_choice,
+                                  NULL, NULL, /* conflict func */
+                                  NULL, NULL, /* cancellation */
+                                  NULL, NULL, /* notification */
+                                  b->pool);
+
+  err = svn_error_compose_create(err, svn_wc__release_write_lock(b->wc_ctx,
+                                                                 lock_abspath,
+                                                                 b->pool));
+  return err;
+}
+
+
+svn_error_t *
 sbox_wc_move(svn_test__sandbox_t *b, const char *src, const char *dst)
 {
   svn_client_ctx_t *ctx;

Modified: subversion/trunk/subversion/tests/libsvn_wc/utils.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_wc/utils.h?rev=1663347&r1=1663346&r2=1663347&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_wc/utils.h (original)
+++ subversion/trunk/subversion/tests/libsvn_wc/utils.h Mon Mar  2 16:29:14 2015
@@ -166,6 +166,12 @@ sbox_wc_resolve(svn_test__sandbox_t *b,
 
 /* */
 svn_error_t *
+sbox_wc_resolve_prop(svn_test__sandbox_t *b, const char *path,
+                     const char *propname,
+                     svn_wc_conflict_choice_t conflict_choice);
+
+/* */
+svn_error_t *
 sbox_wc_move(svn_test__sandbox_t *b, const char *src, const char *dst);
 
 /* Set property NAME to VALUE on PATH. If VALUE=NULL, delete the property. */