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/01/28 09:41:14 UTC

svn commit: r1727276 - in /subversion/trunk/subversion: libsvn_client/resolved.c svn/conflict-callbacks.c

Author: stsp
Date: Thu Jan 28 08:41:14 2016
New Revision: 1727276

URL: http://svn.apache.org/viewvc?rev=1727276&view=rev
Log:
Make libsvn_client describe all currently available tree conflict options.

* subversion/libsvn_client/resolved.c
  (tree_conflict_options): Remove this static table of options, now unused.
  (svn_client_conflict_tree_get_resolution_options): Build an array of options
   and include the special options for update-move-away and edit-deleted-dir
   cases if appropriate. The result corresponds to what 'svn' already offers.

* subversion/svn/conflict-callbacks.c
  (tree_conflict_options_update_moved_away,
   tree_conflict_options_update_edit_deleted_dir): Set long option descriptions
   to NULL so descriptions provided by libsvn_client are used instead.

Modified:
    subversion/trunk/subversion/libsvn_client/resolved.c
    subversion/trunk/subversion/svn/conflict-callbacks.c

Modified: subversion/trunk/subversion/libsvn_client/resolved.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/resolved.c?rev=1727276&r1=1727275&r2=1727276&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/resolved.c (original)
+++ subversion/trunk/subversion/libsvn_client/resolved.c Thu Jan 28 08:41:14 2016
@@ -906,27 +906,6 @@ static const svn_client_conflict_option_
 
 };
 
-/* Resolver options for a tree conflict */
-static const svn_client_conflict_option_t tree_conflict_options[] =
-{
-  {
-    svn_client_conflict_option_postpone,
-    N_("skip this conflict and leave it unresolved"),
-    NULL,
-    resolve_tree_conflict
-  },
-
-  {
-    /* ### Use 'working text' for now since libsvn_wc does not know another
-     * ### choice to resolve to working yet. */
-    svn_client_conflict_option_working_text,
-    N_("accept current working copy state"),
-    NULL,
-    resolve_tree_conflict
-  },
-
-};
-
 static svn_error_t *
 assert_text_conflict(svn_client_conflict_t *conflict, apr_pool_t *scratch_pool)
 {
@@ -1032,17 +1011,56 @@ svn_client_conflict_tree_get_resolution_
                                                 apr_pool_t *result_pool,
                                                 apr_pool_t *scratch_pool)
 {
-  int i;
+  svn_client_conflict_option_t *option;
 
   SVN_ERR(assert_tree_conflict(conflict, scratch_pool));
 
-  *options = apr_array_make(result_pool, ARRAY_LEN(tree_conflict_options),
+  *options = apr_array_make(result_pool, 2,
                             sizeof(svn_client_conflict_option_t *));
-  for (i = 0; i < ARRAY_LEN(tree_conflict_options); i++)
+
+  /* Add postpone option. */
+  option = apr_pcalloc(result_pool, sizeof(*option));
+  option->id = svn_client_conflict_option_postpone;
+  option->description = N_("skip this conflict and leave it unresolved");
+  option->conflict = conflict;
+  option->do_resolve_func = resolve_tree_conflict;
+  APR_ARRAY_PUSH((*options), const svn_client_conflict_option_t *) = option;
+
+  /* Add an option which marks the conflict resolved. */
+  option = apr_pcalloc(result_pool, sizeof(*option));
+  option->id = svn_client_conflict_option_working_text;
+  option->description = N_("accept current working copy state");
+  /* Override ID and DESCRIPTION in case we can offer automated resolution: */
+  if (svn_client_conflict_get_operation(conflict) == svn_wc_operation_update ||
+      svn_client_conflict_get_operation(conflict) == svn_wc_operation_switch)
     {
-      APR_ARRAY_PUSH((*options), const svn_client_conflict_option_t *) =
-        &tree_conflict_options[i];
+      svn_wc_conflict_reason_t reason;
+
+      reason = svn_client_conflict_get_local_change(conflict);
+      if (reason == svn_wc_conflict_reason_moved_away)
+        {
+          option->id = svn_client_conflict_option_working_text_where_conflicted;
+          option->description =
+            N_("apply incoming changes to move destination");
+        }
+      else if (reason == svn_wc_conflict_reason_deleted ||
+               reason == svn_wc_conflict_reason_replaced)
+        {
+          if (svn_client_conflict_get_incoming_change(conflict) ==
+              svn_wc_conflict_action_edit &&
+              svn_client_conflict_tree_get_victim_node_kind(conflict) ==
+              svn_node_dir)
+            {
+              option->id =
+                svn_client_conflict_option_working_text_where_conflicted;
+              option->description =
+                N_("prepare for updating moved-away children, if any");
+            }
+        }
     }
+  option->conflict = conflict;
+  option->do_resolve_func = resolve_tree_conflict;
+  APR_ARRAY_PUSH((*options), const svn_client_conflict_option_t *) = option;
 
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/svn/conflict-callbacks.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/conflict-callbacks.c?rev=1727276&r1=1727275&r2=1727276&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/conflict-callbacks.c (original)
+++ subversion/trunk/subversion/svn/conflict-callbacks.c Thu Jan 28 08:41:14 2016
@@ -517,8 +517,7 @@ static const resolver_option_t tree_conf
 static const resolver_option_t tree_conflict_options_update_moved_away[] =
 {
   { "mc", N_("apply update to move destination (recommended)"),
-                                  N_("apply incoming update to move "
-                                     "destination"),
+                                  NULL,
                                   svn_client_conflict_option_working_text_where_conflicted,
                                   SVN_CL__ACCEPT_MINE_CONFLICT },
   { "p",  N_("postpone"),         NULL,
@@ -534,8 +533,7 @@ static const resolver_option_t tree_conf
 static const resolver_option_t tree_conflict_options_update_edit_deleted_dir[] =
 {
   { "mc", N_("prepare for updating moved-away children, if any (recommended)"),
-                                  N_("allow updating moved-away children "
-                                     "with 'svn resolve'"),
+                                  NULL,
                                   svn_client_conflict_option_working_text_where_conflicted,
                                   SVN_CL__ACCEPT_MINE_CONFLICT },
   { "p",  N_("postpone"),         NULL,



Re: svn commit: r1727276 - in /subversion/trunk/subversion: libsvn_client/resolved.c svn/conflict-callbacks.c

Posted by Stefan Sperling <st...@elego.de>.
On Thu, Jan 28, 2016 at 12:01:07PM +0100, Bert Huijben wrote:
> > +  /* Add postpone option. */
> > +  option = apr_pcalloc(result_pool, sizeof(*option));
> > +  option->id = svn_client_conflict_option_postpone;
> > +  option->description = N_("skip this conflict and leave it unresolved");
> 
> I think description should now use _() to localize the option here, instead of in the callee.
> 

Indeed, that was an oversight. I copied these strings from over from
'svn' where they were part of a static array. Fixed in r1727329.

Thanks!

RE: svn commit: r1727276 - in /subversion/trunk/subversion: libsvn_client/resolved.c svn/conflict-callbacks.c

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: stsp@apache.org [mailto:stsp@apache.org]
> Sent: donderdag 28 januari 2016 09:41
> To: commits@subversion.apache.org
> Subject: svn commit: r1727276 - in /subversion/trunk/subversion:
> libsvn_client/resolved.c svn/conflict-callbacks.c
> 
> Author: stsp
> Date: Thu Jan 28 08:41:14 2016
> New Revision: 1727276
> 
> URL: http://svn.apache.org/viewvc?rev=1727276&view=rev
> Log:
> Make libsvn_client describe all currently available tree conflict options.
> 
> * subversion/libsvn_client/resolved.c
>   (tree_conflict_options): Remove this static table of options, now unused.
>   (svn_client_conflict_tree_get_resolution_options): Build an array of options
>    and include the special options for update-move-away and edit-deleted-dir
>    cases if appropriate. The result corresponds to what 'svn' already offers.
> 
> * subversion/svn/conflict-callbacks.c
>   (tree_conflict_options_update_moved_away,
>    tree_conflict_options_update_edit_deleted_dir): Set long option
> descriptions
>    to NULL so descriptions provided by libsvn_client are used instead.
> 
> Modified:
>     subversion/trunk/subversion/libsvn_client/resolved.c
>     subversion/trunk/subversion/svn/conflict-callbacks.c
> 
> Modified: subversion/trunk/subversion/libsvn_client/resolved.c
> URL:
> http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/re
> solved.c?rev=1727276&r1=1727275&r2=1727276&view=diff
> ==========================================================
> ====================
> --- subversion/trunk/subversion/libsvn_client/resolved.c (original)
> +++ subversion/trunk/subversion/libsvn_client/resolved.c Thu Jan 28
> 08:41:14 2016
> @@ -906,27 +906,6 @@ static const svn_client_conflict_option_
> 
>  };
> 
> -/* Resolver options for a tree conflict */
> -static const svn_client_conflict_option_t tree_conflict_options[] =
> -{
> -  {
> -    svn_client_conflict_option_postpone,
> -    N_("skip this conflict and leave it unresolved"),
> -    NULL,
> -    resolve_tree_conflict
> -  },
> -
> -  {
> -    /* ### Use 'working text' for now since libsvn_wc does not know another
> -     * ### choice to resolve to working yet. */
> -    svn_client_conflict_option_working_text,
> -    N_("accept current working copy state"),
> -    NULL,
> -    resolve_tree_conflict
> -  },
> -
> -};
> -
>  static svn_error_t *
>  assert_text_conflict(svn_client_conflict_t *conflict, apr_pool_t
> *scratch_pool)
>  {
> @@ -1032,17 +1011,56 @@ svn_client_conflict_tree_get_resolution_
>                                                  apr_pool_t *result_pool,
>                                                  apr_pool_t *scratch_pool)
>  {
> -  int i;
> +  svn_client_conflict_option_t *option;
> 
>    SVN_ERR(assert_tree_conflict(conflict, scratch_pool));
> 
> -  *options = apr_array_make(result_pool,
> ARRAY_LEN(tree_conflict_options),
> +  *options = apr_array_make(result_pool, 2,
>                              sizeof(svn_client_conflict_option_t *));
> -  for (i = 0; i < ARRAY_LEN(tree_conflict_options); i++)
> +
> +  /* Add postpone option. */
> +  option = apr_pcalloc(result_pool, sizeof(*option));
> +  option->id = svn_client_conflict_option_postpone;
> +  option->description = N_("skip this conflict and leave it unresolved");

I think description should now use _() to localize the option here, instead of in the callee.

I was assuming the N_() in the array was that it wasn't evaluated there, but added to the localization strings anyway... to allow later code to use the localized variants via the api.

We currently don't provide access to our gettext instance via our api, so I have no idea how localization should work when we are used as a library and don't provide the localized values.

	Bert 



RE: svn commit: r1727276 - in /subversion/trunk/subversion: libsvn_client/resolved.c svn/conflict-callbacks.c

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: stsp@apache.org [mailto:stsp@apache.org]
> Sent: donderdag 28 januari 2016 09:41
> To: commits@subversion.apache.org
> Subject: svn commit: r1727276 - in /subversion/trunk/subversion:
> libsvn_client/resolved.c svn/conflict-callbacks.c
> 
> Author: stsp
> Date: Thu Jan 28 08:41:14 2016
> New Revision: 1727276
> 
> URL: http://svn.apache.org/viewvc?rev=1727276&view=rev
> Log:
> Make libsvn_client describe all currently available tree conflict options.
> 
> * subversion/libsvn_client/resolved.c
>   (tree_conflict_options): Remove this static table of options, now unused.
>   (svn_client_conflict_tree_get_resolution_options): Build an array of options
>    and include the special options for update-move-away and edit-deleted-dir
>    cases if appropriate. The result corresponds to what 'svn' already offers.
> 
> * subversion/svn/conflict-callbacks.c
>   (tree_conflict_options_update_moved_away,
>    tree_conflict_options_update_edit_deleted_dir): Set long option
> descriptions
>    to NULL so descriptions provided by libsvn_client are used instead.
> 
> Modified:
>     subversion/trunk/subversion/libsvn_client/resolved.c
>     subversion/trunk/subversion/svn/conflict-callbacks.c
> 
> Modified: subversion/trunk/subversion/libsvn_client/resolved.c
> URL:
> http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/re
> solved.c?rev=1727276&r1=1727275&r2=1727276&view=diff
> ==========================================================
> ====================
> --- subversion/trunk/subversion/libsvn_client/resolved.c (original)
> +++ subversion/trunk/subversion/libsvn_client/resolved.c Thu Jan 28
> 08:41:14 2016
> @@ -906,27 +906,6 @@ static const svn_client_conflict_option_
> 
>  };
> 
> -/* Resolver options for a tree conflict */
> -static const svn_client_conflict_option_t tree_conflict_options[] =
> -{
> -  {
> -    svn_client_conflict_option_postpone,
> -    N_("skip this conflict and leave it unresolved"),
> -    NULL,
> -    resolve_tree_conflict
> -  },
> -
> -  {
> -    /* ### Use 'working text' for now since libsvn_wc does not know another
> -     * ### choice to resolve to working yet. */
> -    svn_client_conflict_option_working_text,
> -    N_("accept current working copy state"),
> -    NULL,
> -    resolve_tree_conflict
> -  },
> -
> -};
> -
>  static svn_error_t *
>  assert_text_conflict(svn_client_conflict_t *conflict, apr_pool_t
> *scratch_pool)
>  {
> @@ -1032,17 +1011,56 @@ svn_client_conflict_tree_get_resolution_
>                                                  apr_pool_t *result_pool,
>                                                  apr_pool_t *scratch_pool)
>  {
> -  int i;
> +  svn_client_conflict_option_t *option;
> 
>    SVN_ERR(assert_tree_conflict(conflict, scratch_pool));
> 
> -  *options = apr_array_make(result_pool,
> ARRAY_LEN(tree_conflict_options),
> +  *options = apr_array_make(result_pool, 2,
>                              sizeof(svn_client_conflict_option_t *));
> -  for (i = 0; i < ARRAY_LEN(tree_conflict_options); i++)
> +
> +  /* Add postpone option. */
> +  option = apr_pcalloc(result_pool, sizeof(*option));
> +  option->id = svn_client_conflict_option_postpone;
> +  option->description = N_("skip this conflict and leave it unresolved");

I think description should now use _() to localize the option here, instead of in the callee.

I was assuming the N_() in the array was that it wasn't evaluated there, but added to the localization strings anyway... to allow later code to use the localized variants via the api.

We currently don't provide access to our gettext instance via our api, so I have no idea how localization should work when we are used as a library and don't provide the localized values.

	Bert