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 2015/07/31 15:31:07 UTC

svn commit: r1693593 - in /subversion/trunk/subversion: include/svn_client.h libsvn_client/resolved.c

Author: stsp
Date: Fri Jul 31 13:31:07 2015
New Revision: 1693593

URL: http://svn.apache.org/r1693593
Log:
Add a convenience API which allows clients to resolve conflicts by
passing an option id rather than a pointer to an option object.

* subversion/include/svn_client.h
  (svn_client_conflict_tree_resolve_by_id,
   svn_client_conflict_prop_resolve_by_id,
   svn_client_conflict_text_resolve_by_id): Declare.

* subversion/libsvn_client/resolved.c
  (match_resolution_option): New helper function.
  (svn_client_conflict_tree_resolve_by_id,
   svn_client_conflict_prop_resolve_by_id,
   svn_client_conflict_text_resolve_by_id): Implement.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/libsvn_client/resolved.c

Modified: subversion/trunk/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1693593&r1=1693592&r2=1693593&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Fri Jul 31 13:31:07 2015
@@ -4672,6 +4672,19 @@ svn_client_conflict_tree_resolve(svn_cli
                                  apr_pool_t *scratch_pool);
 
 /**
+ * If the provided @a option_id is the ID of an option which resolves
+ * @a conflict, resolve the tree conflict using that option.
+ * Else, return an error.
+ *
+ * @since New in 1.10.
+ */
+svn_error_t *
+svn_client_conflict_tree_resolve_by_id(
+  svn_client_conflict_t *conflict,
+  svn_client_conflict_option_id_t option_id,
+  apr_pool_t *scratch_pool);
+
+/**
  * Return the ID of the option this tree @a conflict has been resolved to.
  * If the conflict has not been resolved yet, then return
  * @c svn_client_conflict_option_undefined.
@@ -4734,6 +4747,19 @@ svn_client_conflict_prop_resolve(svn_cli
                                  const char *propname,
                                  svn_client_conflict_option_t *option,
                                  apr_pool_t *scratch_pool);
+/**
+ * If the provided @a option_id is the ID of an option which resolves
+ * @a conflict, resolve the property conflict in property @a propname
+ * using that option. Else, return an error.
+ *
+ * @since New in 1.10.
+ */
+svn_error_t *
+svn_client_conflict_prop_resolve_by_id(
+  svn_client_conflict_t *conflict,
+  const char *propname,
+  svn_client_conflict_option_id_t option_id,
+  apr_pool_t *scratch_pool);
 
 /**
  * Return the ID of the option this property @a conflict in property
@@ -4786,6 +4812,19 @@ svn_client_conflict_text_resolve(svn_cli
                                  apr_pool_t *scratch_pool);
 
 /**
+ * If the provided @a option_id is the ID of an option which resolves
+ * @a conflict, resolve the text conflict using that option.
+ * Else, return an error.
+ *
+ * @since New in 1.10.
+ */
+svn_error_t *
+svn_client_conflict_text_resolve_by_id(
+  svn_client_conflict_t *conflict,
+  svn_client_conflict_option_id_t option_id,
+  apr_pool_t *scratch_pool);
+
+/**
  * Return the ID of the option this text @a conflict has been resolved to.
  * If the conflict has not been resolved yet, then return
  * @c svn_client_conflict_option_undefined.

Modified: subversion/trunk/subversion/libsvn_client/resolved.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/resolved.c?rev=1693593&r1=1693592&r2=1693593&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/resolved.c (original)
+++ subversion/trunk/subversion/libsvn_client/resolved.c Fri Jul 31 13:31:07 2015
@@ -847,6 +847,63 @@ svn_client_conflict_text_resolve(svn_cli
   return SVN_NO_ERROR;
 }
 
+/* Find an *OPTION in RESOLUTION_OPTIONS which matches the desired
+ * RESOLUTION option ID. If no matching option exists, raise an
+ * error using LOCAL_ABSPATH as part of the error message. */
+static svn_error_t *
+match_resolution_option(svn_client_conflict_option_t **option,
+                        apr_array_header_t *resolution_options,
+                        svn_client_conflict_option_id_t resolution,
+                        const char *local_abspath,
+                        apr_pool_t *scratch_pool)
+{
+  int i;
+
+  *option = NULL;
+  for (i = 0; i < resolution_options->nelts; i++)
+    {
+      svn_client_conflict_option_t *this_option;
+      svn_client_conflict_option_id_t this_option_id;
+      
+      this_option = APR_ARRAY_IDX(resolution_options, i,
+                                  svn_client_conflict_option_t *);
+      this_option_id = svn_client_conflict_option_get_id(this_option);
+
+      if (this_option_id == resolution)
+        *option = this_option;
+        break;
+    }
+
+  if (*option == NULL)
+    return svn_error_createf(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE, NULL,
+                               _("Inapplicable conflict resolution option "
+                                 "ID '%d' given for conflicted path '%s'"),
+                               resolution,
+                               svn_dirent_local_style(local_abspath,
+                                                      scratch_pool));
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_client_conflict_text_resolve_by_id(
+  svn_client_conflict_t *conflict,
+  svn_client_conflict_option_id_t option_id,
+  apr_pool_t *scratch_pool)
+{
+  apr_array_header_t *resolution_options;
+  svn_client_conflict_option_t *option;
+
+  SVN_ERR(svn_client_conflict_text_get_resolution_options(
+            &resolution_options, conflict,
+            scratch_pool, scratch_pool));
+  SVN_ERR(match_resolution_option(&option, resolution_options,
+                                  option_id, conflict->local_abspath,
+                                  scratch_pool));
+  SVN_ERR(svn_client_conflict_text_resolve(conflict, option, scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
 svn_client_conflict_option_id_t
 svn_client_conflict_text_get_resolution(const svn_client_conflict_t *conflict)
 {
@@ -866,6 +923,28 @@ svn_client_conflict_prop_resolve(svn_cli
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_client_conflict_prop_resolve_by_id(
+  svn_client_conflict_t *conflict,
+  const char *propname,
+  svn_client_conflict_option_id_t option_id,
+  apr_pool_t *scratch_pool)
+{
+  apr_array_header_t *resolution_options;
+  svn_client_conflict_option_t *option;
+
+  SVN_ERR(svn_client_conflict_prop_get_resolution_options(
+            &resolution_options, conflict,
+            scratch_pool, scratch_pool));
+  SVN_ERR(match_resolution_option(&option, resolution_options,
+                                  option_id, conflict->local_abspath,
+                                  scratch_pool));
+  SVN_ERR(svn_client_conflict_prop_resolve(conflict, propname, option,
+                                           scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
 svn_client_conflict_option_id_t
 svn_client_conflict_prop_get_resolution(const svn_client_conflict_t *conflict,
                                         const char *propname)
@@ -889,6 +968,26 @@ svn_client_conflict_tree_resolve(svn_cli
 
   return SVN_NO_ERROR;
 }
+
+svn_error_t *
+svn_client_conflict_tree_resolve_by_id(
+  svn_client_conflict_t *conflict,
+  svn_client_conflict_option_id_t option_id,
+  apr_pool_t *scratch_pool)
+{
+  apr_array_header_t *resolution_options;
+  svn_client_conflict_option_t *option;
+
+  SVN_ERR(svn_client_conflict_tree_get_resolution_options(
+            &resolution_options, conflict,
+            scratch_pool, scratch_pool));
+  SVN_ERR(match_resolution_option(&option, resolution_options,
+                                  option_id, conflict->local_abspath,
+                                  scratch_pool));
+  SVN_ERR(svn_client_conflict_tree_resolve(conflict, option, scratch_pool));
+
+  return SVN_NO_ERROR;
+}
 
 svn_client_conflict_option_id_t
 svn_client_conflict_tree_get_resolution(const svn_client_conflict_t *conflict)