subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1781855 - /subversion/trunk/subversion/libsvn_client/conflicts.c
Date Mon, 06 Feb 2017 09:35:25 GMT
Author: stsp
Date: Mon Feb  6 09:35:25 2017
New Revision: 1781855

URL: http://svn.apache.org/viewvc?rev=1781855&view=rev
Log:
Introduce a new helper function in the conflict resolver.

* subversion/libsvn_client/conflicts.c
  (get_moved_to_repos_relpath): New helper function which encapsulates the
   process of finding the currently selected repository-side move target path.
  (describe_incoming_deletion_upon_update,
  (describe_incoming_deletion_upon_switch,
  (describe_incoming_deletion_upon_merge): Use the new helper function instead
   of inlining its implementation several times.

Modified:
    subversion/trunk/subversion/libsvn_client/conflicts.c

Modified: subversion/trunk/subversion/libsvn_client/conflicts.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/conflicts.c?rev=1781855&r1=1781854&r2=1781855&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/conflicts.c (original)
+++ subversion/trunk/subversion/libsvn_client/conflicts.c Mon Feb  6 09:35:25 2017
@@ -2655,6 +2655,21 @@ struct conflict_tree_incoming_delete_det
   int wc_move_target_idx;
 };
 
+/* Get the currently selected repository-side move target path.
+ * If none was selected yet, determine and return a default one. */
+static const char *
+get_moved_to_repos_relpath(
+  struct conflict_tree_incoming_delete_details *details)
+{
+  struct repos_move_info *move;
+
+  if (details->move_target_repos_relpath)
+    return details->move_target_repos_relpath;
+
+  move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
+  return move->moved_to_repos_relpath;
+}
+
 static const char *
 describe_incoming_deletion_upon_update(
   struct conflict_tree_incoming_delete_details *details,
@@ -2678,17 +2693,13 @@ describe_incoming_deletion_upon_update(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced directory was moved to "
-                               "'^/%s'."), description, moved_to_repos_relpath);
+                               "'^/%s'."), description,
+                               get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -2719,7 +2730,7 @@ describe_incoming_deletion_upon_update(
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced file was moved to '^/%s'."),
-                             description, moved_to_repos_relpath);
+                             description, get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -2737,17 +2748,12 @@ describe_incoming_deletion_upon_update(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced item was moved to '^/%s'."),
-                             description, moved_to_repos_relpath);
+                             description, get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -2770,17 +2776,13 @@ describe_incoming_deletion_upon_update(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced directory was moved to "
-                               "'^/%s'."), description, moved_to_repos_relpath);
+                               "'^/%s'."), description,
+                               get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -2800,17 +2802,12 @@ describe_incoming_deletion_upon_update(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced file was moved to '^/%s'."),
-                             description, moved_to_repos_relpath);
+                             description, get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -2828,17 +2825,12 @@ describe_incoming_deletion_upon_update(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced item was moved to '^/%s'."),
-                             description, moved_to_repos_relpath);
+                             description, get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -2855,18 +2847,14 @@ describe_incoming_deletion_upon_update(
             {
               const char *description;
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("Directory updated from r%ld to r%ld was "
                                "moved to '^/%s' by %s in r%ld."),
-                             old_rev, new_rev, moved_to_repos_relpath,
+                             old_rev, new_rev,
+                             get_moved_to_repos_relpath(details),
                              details->rev_author, details->deleted_rev);
               return append_moved_to_chain_description(description,
                                                        move->next,
@@ -2887,18 +2875,13 @@ describe_incoming_deletion_upon_update(
             {
               struct repos_move_info *move;
               const char *description;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("File updated from r%ld to r%ld was moved "
                                "to '^/%s' by %s in r%ld."), old_rev, new_rev,
-                             moved_to_repos_relpath,
+                             get_moved_to_repos_relpath(details),
                              details->rev_author, details->deleted_rev);
               return append_moved_to_chain_description(description,
                                                        move->next,
@@ -2917,18 +2900,13 @@ describe_incoming_deletion_upon_update(
             {
               const char *description;
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description = 
                 apr_psprintf(result_pool,
                              _("Item updated from r%ld to r%ld was moved "
                                "to '^/%s' by %s in r%ld."), old_rev, new_rev,
-                             moved_to_repos_relpath,
+                             get_moved_to_repos_relpath(details),
                              details->rev_author, details->deleted_rev);
               return append_moved_to_chain_description(description,
                                                        move->next,
@@ -3050,18 +3028,13 @@ describe_incoming_deletion_upon_switch(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced directory was moved "
                                "to '^/%s'."), description,
-                             moved_to_repos_relpath);
+                             get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -3084,17 +3057,12 @@ describe_incoming_deletion_upon_switch(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced file was moved to '^/%s'."),
-                             description, moved_to_repos_relpath);
+                             description, get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -3115,17 +3083,12 @@ describe_incoming_deletion_upon_switch(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced item was moved to '^/%s'."),
-                             description, moved_to_repos_relpath);
+                             description, get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -3150,17 +3113,13 @@ describe_incoming_deletion_upon_switch(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced directory was moved to "
-                               "'^/%s'."), description, moved_to_repos_relpath);
+                               "'^/%s'."), description,
+                             get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -3182,17 +3141,12 @@ describe_incoming_deletion_upon_switch(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced file was moved to '^/%s'."),
-                             description, moved_to_repos_relpath);
+                             description, get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -3213,17 +3167,12 @@ describe_incoming_deletion_upon_switch(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced item was moved to '^/%s'."),
-                             description, moved_to_repos_relpath);
+                             description, get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -3240,20 +3189,16 @@ describe_incoming_deletion_upon_switch(
             {
               struct repos_move_info *move;
               const char *description;
-              const char *moved_to_repos_relpath;
               
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("Directory switched from\n"
                                "'^/%s@%ld'\nto\n'^/%s@%ld'\n"
                                "was moved to '^/%s' by %s in r%ld."),
                              old_repos_relpath, old_rev,
-                             new_repos_relpath, new_rev, moved_to_repos_relpath,
+                             new_repos_relpath, new_rev,
+                             get_moved_to_repos_relpath(details),
                              details->rev_author, details->deleted_rev);
               return append_moved_to_chain_description(description,
                                                        move->next,
@@ -3276,13 +3221,8 @@ describe_incoming_deletion_upon_switch(
             {
               struct repos_move_info *move;
               const char *description;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("File switched from\n"
@@ -3290,7 +3230,7 @@ describe_incoming_deletion_upon_switch(
                                "moved to '^/%s' by %s in r%ld."),
                              old_repos_relpath, old_rev,
                              new_repos_relpath, new_rev,
-                             moved_to_repos_relpath,
+                             get_moved_to_repos_relpath(details),
                              details->rev_author, details->deleted_rev);
               return append_moved_to_chain_description(description,
                                                        move->next,
@@ -3312,13 +3252,8 @@ describe_incoming_deletion_upon_switch(
             {
               struct repos_move_info *move;
               const char *description;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("Item switched from\n"
@@ -3326,7 +3261,7 @@ describe_incoming_deletion_upon_switch(
                                "moved to '^/%s' by %s in r%ld."),
                              old_repos_relpath, old_rev,
                              new_repos_relpath, new_rev,
-                             moved_to_repos_relpath,
+                             get_moved_to_repos_relpath(details),
                              details->rev_author, details->deleted_rev);
               return append_moved_to_chain_description(description,
                                                        move->next,
@@ -3476,18 +3411,13 @@ describe_incoming_deletion_upon_merge(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced directory was moved to "
                                "'^/%s'."), description,
-                             moved_to_repos_relpath);
+                             get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -3510,17 +3440,12 @@ describe_incoming_deletion_upon_merge(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced file was moved to '^/%s'."),
-                             description, moved_to_repos_relpath);
+                             description, get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -3553,17 +3478,13 @@ describe_incoming_deletion_upon_merge(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced directory was moved to "
-                               "'^/%s'."), description, moved_to_repos_relpath);
+                               "'^/%s'."), description,
+                               get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -3585,17 +3506,12 @@ describe_incoming_deletion_upon_merge(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced file was moved to '^/%s'."),
-                             description, moved_to_repos_relpath);
+                             description, get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -3616,17 +3532,12 @@ describe_incoming_deletion_upon_merge(
           if (details->moves)
             {
               struct repos_move_info *move;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("%s\nThe replaced item was moved to '^/%s'."),
-                             description, moved_to_repos_relpath);
+                             description, get_moved_to_repos_relpath(details));
               return append_moved_to_chain_description(description,
                                                        move->next,
                                                        result_pool,
@@ -3643,13 +3554,8 @@ describe_incoming_deletion_upon_merge(
             {
               struct repos_move_info *move;
               const char *description;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("Directory merged from\n"
@@ -3657,7 +3563,7 @@ describe_incoming_deletion_upon_merge(
                                "moved to '^/%s' by %s in r%ld."),
                              old_repos_relpath, old_rev,
                              new_repos_relpath, new_rev,
-                             moved_to_repos_relpath,
+                             get_moved_to_repos_relpath(details),
                              details->rev_author, details->deleted_rev);
               return append_moved_to_chain_description(description,
                                                        move->next,
@@ -3680,13 +3586,8 @@ describe_incoming_deletion_upon_merge(
             {
               struct repos_move_info *move;
               const char *description;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("File merged from\n"
@@ -3694,7 +3595,7 @@ describe_incoming_deletion_upon_merge(
                                "moved to '^/%s' by %s in r%ld."),
                              old_repos_relpath, old_rev,
                              new_repos_relpath, new_rev,
-                             moved_to_repos_relpath,
+                             get_moved_to_repos_relpath(details),
                              details->rev_author, details->deleted_rev);
               return append_moved_to_chain_description(description,
                                                        move->next,
@@ -3716,13 +3617,8 @@ describe_incoming_deletion_upon_merge(
             {
               struct repos_move_info *move;
               const char *description;
-              const char *moved_to_repos_relpath;
 
               move = APR_ARRAY_IDX(details->moves, 0, struct repos_move_info *);
-              if (details->move_target_repos_relpath)
-                moved_to_repos_relpath = details->move_target_repos_relpath;
-              else
-                moved_to_repos_relpath = move->moved_to_repos_relpath;
               description =
                 apr_psprintf(result_pool,
                              _("Item merged from\n"
@@ -3730,7 +3626,7 @@ describe_incoming_deletion_upon_merge(
                                "moved to '^/%s' by %s in r%ld."),
                              old_repos_relpath, old_rev,
                              new_repos_relpath, new_rev,
-                             moved_to_repos_relpath,
+                             get_moved_to_repos_relpath(details),
                              details->rev_author, details->deleted_rev);
               return append_moved_to_chain_description(description,
                                                        move->next,



Mime
View raw message