You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2010/06/23 18:29:31 UTC

svn commit: r957263 - /subversion/trunk/subversion/libsvn_wc/merge.c

Author: julianfoad
Date: Wed Jun 23 16:29:31 2010
New Revision: 957263

URL: http://svn.apache.org/viewvc?rev=957263&view=rev
Log:
Clean up naming and documentation in WC merge functions.  No functional
change.

* subversion/libsvn_wc/merge.c
  (save_merge_result): Rename TARGET_ABSPATH to VERSIONED_ABSPATH. Rename
    RESULT_TARGET to SOURCE because it is the source and not the target of
    this operation. Rename a local variable. Re-write doc string.
  (eval_conflict_func_result): Replace (RESULT->choice, RESULT->merged_file,
    RESULT_TARGET) with (CHOICE, MERGED_FILE) and let the caller pass the
    correct merged file. Rename ADM_ABSPATH to WRI_ABSPATH. Rename OPTIONS
    to DIFF3_OPTIONS. Re-write the doc string.
  (maybe_resolve_conflicts): Adjust the call to eval_conflict_func_result().
    Add the first smidgen of a doc string.
  (merge_text_file): Tweak comments.

Modified:
    subversion/trunk/subversion/libsvn_wc/merge.c

Modified: subversion/trunk/subversion/libsvn_wc/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/merge.c?rev=957263&r1=957262&r2=957263&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/merge.c (original)
+++ subversion/trunk/subversion/libsvn_wc/merge.c Wed Jun 23 16:29:31 2010
@@ -405,28 +405,29 @@ do_text_merge_external(svn_boolean_t *co
   return SVN_NO_ERROR;
 }
 
-/* Return a work item to copy/translate the merge result, obtained during
-   interactive conflict resolution, to the file RESULT_TARGET. The merge
-   result is expected in the same directory as TARGET_ABSPATH, with the same
-   basename as TARGET_ABSPATH, with a ".edited" extension.
+/* Create a new file in the same directory as VERSIONED_ABSPATH, with the
+   same basename as VERSIONED_ABSPATH, with a ".edited" extension, and set
+   *WORK_ITEM to a new work item that will copy and translate from the file
+   SOURCE to that new file.  It will be translated from repository-normal
+   form to working-copy form according to the versioned properties of
+   VERSIONED_ABSPATH that are current when the work item is executed.
 
-   DB should have a write lock for the directory containing RESULT_TARGET.
+   DB should have a write lock for the directory containing SOURCE.
 
-   *WORK_ITEM will be allocated in RESULT_POOL. All temporary allocations
-   will be allocated in SCRATCH_POOL.  */
+   Allocate *WORK_ITEM in RESULT_POOL. */
 static svn_error_t*
 save_merge_result(svn_skel_t **work_item,
                   svn_wc__db_t *db,
-                  const char *target_abspath,
-                  const char *result_target,
+                  const char *versioned_abspath,
+                  const char *source,
                   apr_pool_t *result_pool,
                   apr_pool_t *scratch_pool)
 {
   const char *edited_copy_abspath;
   const char *dir_abspath;
-  const char *merge_filename;
+  const char *filename;
 
-  svn_dirent_split(target_abspath, &dir_abspath, &merge_filename,
+  svn_dirent_split(versioned_abspath, &dir_abspath, &filename,
                    scratch_pool);
 
   /* ### Should use preserved-conflict-file-exts. */
@@ -434,42 +435,46 @@ save_merge_result(svn_skel_t **work_item
   SVN_ERR(svn_io_open_uniquely_named(NULL,
                                      &edited_copy_abspath,
                                      dir_abspath,
-                                     merge_filename,
+                                     filename,
                                      ".edited",
                                      svn_io_file_del_none,
                                      scratch_pool, scratch_pool));
   SVN_ERR(svn_wc__loggy_translated_file(work_item,
                                         db, dir_abspath,
                                         edited_copy_abspath,
-                                        result_target,
-                                        target_abspath,
+                                        source,
+                                        versioned_abspath,
                                         result_pool));
 
   return SVN_NO_ERROR;
 }
 
-/* Deal with the RESULT of the conflict resolution callback.
- * LEFT, RIGHT, and MERGE_TARGET are the files involved in
- * the 3-way merge.  Store the result of the 3-way merge in
- * MERGE_OUTCOME.  If the callback did not provide the name to
- * a merged file, use RESULT_TARGET is a fallback.
- * DETRANSLATED_TARGET is the detranslated version of MERGE_TARGET
- * (see detranslate_wc_file() above).  OPTIONS are passed to the
- * diff3 implementation in case a 3-way  merge has to be carried out.
- * Do all allocations in POOL. */
+/* Deal with the result of the conflict resolution callback, as indicated by
+ * CHOICE.
+ *
+ * Set *WORK_ITEMS to new work items that will ...
+ * Set *MERGE_OUTCOME to the result of the 3-way merge.
+ *
+ * LEFT_ABSPATH, RIGHT_ABSPATH, and TARGET_ABSPATH are the input files to
+ * the 3-way merge, and MERGED_FILE is the merged result as generated by the
+ * internal or external merge or by the conflict resolution callback.
+ *
+ * DETRANSLATED_TARGET is the detranslated version of TARGET_ABSPATH
+ * (see detranslate_wc_file() above).  DIFF3_OPTIONS are passed to the
+ * diff3 implementation in case a 3-way merge has to be carried out. */
 static svn_error_t*
 eval_conflict_func_result(svn_skel_t **work_items,
                           enum svn_wc_merge_outcome_t *merge_outcome,
-                          svn_wc_conflict_result_t *result,
+                          svn_wc_conflict_choice_t choice,
                           svn_wc__db_t *db,
+                          const char *wri_abspath,
                           const char *left_abspath,
                           const char *right_abspath,
                           const char *target_abspath,
                           const char *copyfrom_text,
-                          const char *adm_abspath,
-                          const char *result_target,
+                          const char *merged_file,
                           const char *detranslated_target,
-                          svn_diff_file_options_t *options,
+                          svn_diff_file_options_t *diff3_options,
                           apr_pool_t *result_pool,
                           apr_pool_t *scratch_pool)
 {
@@ -479,7 +484,7 @@ eval_conflict_func_result(svn_skel_t **w
 
   *work_items = NULL;
 
-  switch (result->choice)
+  switch (choice)
     {
       /* If the callback wants to use one of the fulltexts
          to resolve the conflict, so be it.*/
@@ -510,11 +515,11 @@ eval_conflict_func_result(svn_skel_t **w
           svn_diff_t *diff;
           svn_diff_conflict_display_style_t style;
 
-          style = result->choice == svn_wc_conflict_choose_theirs_conflict
+          style = choice == svn_wc_conflict_choose_theirs_conflict
                     ? svn_diff_conflict_display_latest
                     : svn_diff_conflict_display_modified;
 
-          SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&temp_dir, db, adm_abspath,
+          SVN_ERR(svn_wc__db_temp_wcroot_tempdir(&temp_dir, db, wri_abspath,
                                                  pool, pool));
           SVN_ERR(svn_stream_open_unique(&chosen_stream, &chosen_path,
                                          temp_dir,
@@ -523,7 +528,7 @@ eval_conflict_func_result(svn_skel_t **w
           SVN_ERR(svn_diff_file_diff3_2(&diff,
                                         left_abspath,
                                         detranslated_target, right_abspath,
-                                        options, pool));
+                                        diff3_options, pool));
           SVN_ERR(svn_diff_file_output_merge2(chosen_stream, diff,
                                               left_abspath,
                                               detranslated_target,
@@ -549,10 +554,7 @@ eval_conflict_func_result(svn_skel_t **w
            good to use". */
       case svn_wc_conflict_choose_merged:
         {
-          /* Look for callback's own merged-file first:  */
-          install_from = (result->merged_file
-                            ? result->merged_file
-                            : result_target);
+          install_from = merged_file;
           *merge_outcome = svn_wc_merge_merged;
           break;
         }
@@ -772,6 +774,8 @@ setup_text_conflict_desc(const char *lef
 }
 
 /* XXX Insane amount of parameters... */
+/* RESULT_TARGET is the path to the merged file produced by the internal or
+   external 3-way merge. */
 static svn_error_t*
 maybe_resolve_conflicts(svn_skel_t **work_items,
                         svn_wc__db_t *db,
@@ -850,14 +854,15 @@ maybe_resolve_conflicts(svn_skel_t **wor
 
   SVN_ERR(eval_conflict_func_result(&work_item,
                                     merge_outcome,
-                                    result,
-                                    db,
+                                    result->choice,
+                                    db, dir_abspath,
                                     left_abspath,
                                     right_abspath,
                                     target_abspath,
                                     copyfrom_text,
-                                    dir_abspath,
-                                    result_target,
+                                    result->merged_file
+                                      ? result->merged_file
+                                      : result_target,
                                     detranslated_target,
                                     options,
                                     result_pool, scratch_pool));
@@ -939,7 +944,7 @@ merge_text_file(svn_skel_t **work_items,
   if (merge_options)
     SVN_ERR(svn_diff_file_options_parse(options, merge_options, pool));
 
-  /* Run an external merge if requested. */
+  /* Run the external or internal merge, as requested. */
   if (diff3_cmd)
       SVN_ERR(do_text_merge_external(&contains_conflicts,
                                      result_f,
@@ -964,7 +969,6 @@ merge_text_file(svn_skel_t **work_items,
                           options,
                           pool));
 
-  /* Close the output file */
   SVN_ERR(svn_io_file_close(result_f, pool));
 
   if (contains_conflicts && ! dry_run)