subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1693631 - in /subversion/trunk/subversion: include/svn_client.h libsvn_client/resolved.c
Date Fri, 31 Jul 2015 17:22:01 GMT
Author: stsp
Date: Fri Jul 31 17:22:00 2015
New Revision: 1693631

URL: http://svn.apache.org/r1693631
Log:
Add another convenience API function involving conflict option IDs.

This function makes it trivial to find an option object among the
set of possible resolution options. It's a simple search through an
array but why make things hard for clients...

* subversion/include/svn_client.h
  (svn_client_conflict_option_find_by_id): Declare.

* subversion/libsvn_client/resolved.c
  (match_resolution_option): Replace this helper function with...
  (svn_client_conflict_option_find_by_id): ... this implementation of new API.
  (svn_client_conflict_text_resolve_by_id,
   svn_client_conflict_prop_resolve_by_id,
   svn_client_conflict_tree_resolve_by_id): Update callers.

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=1693631&r1=1693630&r2=1693631&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Fri Jul 31 17:22:00 2015
@@ -4414,6 +4414,19 @@ svn_client_conflict_option_set_merged_pr
   const svn_string_t *merged_propval);
 
 /**
+ * Given an @a option_id, try to find the corresponding option in @a options,
+ * which is an array of svn_client_conflict_option_t * elements.
+ *
+ * Return NULL if no corresponding option can be be found.
+ *
+ * @since New in 1.10.
+ */
+svn_client_conflict_option_t *
+svn_client_conflict_option_find_by_id(
+  apr_array_header_t *options,
+  svn_client_conflict_option_id_t option_id);
+
+/**
  * Return a conflict for the conflicted path @a local_abspath.
  * 
  * @since New in 1.10.

Modified: subversion/trunk/subversion/libsvn_client/resolved.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/resolved.c?rev=1693631&r1=1693630&r2=1693631&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/resolved.c (original)
+++ subversion/trunk/subversion/libsvn_client/resolved.c Fri Jul 31 17:22:00 2015
@@ -859,41 +859,25 @@ 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)
+svn_client_conflict_option_t *
+svn_client_conflict_option_find_by_id(apr_array_header_t *options,
+                                      svn_client_conflict_option_id_t option_id)
 {
   int i;
 
-  *option = NULL;
-  for (i = 0; i < resolution_options->nelts; i++)
+  for (i = 0; i < 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 = APR_ARRAY_IDX(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 (this_option_id == option_id)
+        return this_option;
     }
 
-  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;
+  return NULL;
 }
 
 svn_error_t *
@@ -908,9 +892,15 @@ svn_client_conflict_text_resolve_by_id(
   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));
+  option = svn_client_conflict_option_find_by_id(resolution_options,
+                                                 option_id);
+  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'"),
+                               option_id,
+                               svn_dirent_local_style(conflict->local_abspath,
+                                                      scratch_pool));
   SVN_ERR(svn_client_conflict_text_resolve(conflict, option, scratch_pool));
 
   return SVN_NO_ERROR;
@@ -948,9 +938,15 @@ svn_client_conflict_prop_resolve_by_id(
   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));
+  option = svn_client_conflict_option_find_by_id(resolution_options,
+                                                 option_id);
+  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'"),
+                               option_id,
+                               svn_dirent_local_style(conflict->local_abspath,
+                                                      scratch_pool));
   SVN_ERR(svn_client_conflict_prop_resolve(conflict, propname, option,
                                            scratch_pool));
 
@@ -993,9 +989,15 @@ svn_client_conflict_tree_resolve_by_id(
   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));
+  option = svn_client_conflict_option_find_by_id(resolution_options,
+                                                 option_id);
+  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'"),
+                               option_id,
+                               svn_dirent_local_style(conflict->local_abspath,
+                                                      scratch_pool));
   SVN_ERR(svn_client_conflict_tree_resolve(conflict, option, scratch_pool));
 
   return SVN_NO_ERROR;



Mime
View raw message