subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r932248 - /subversion/trunk/subversion/libsvn_wc/merge.c
Date Fri, 09 Apr 2010 05:03:17 GMT
Author: gstein
Date: Fri Apr  9 05:03:16 2010
New Revision: 932248

URL: http://svn.apache.org/viewvc?rev=932248&view=rev
Log:
Broad sweep of renaming variables, indicating that most paths are now
absolute. Also normalize on TARGET_ABSPATH (tho most other code uses
LOCAL_ABSPATH for this name, the concept of "merge target" lends some
value to the TARGET_ABSPATH name).

* subversion/libsvn_wc/merge.c:
  (detranslate_wc_file): rename MERGE_ABSPATH to TARGET_ABSPATH
  (eval_conflict_func_result): LEFT -> LEFT_ABSPATH. RIGHT -> RIGHT_ABSPATH.
    MERGE_TARGET -> TARGET_ABSPATH.
  (preserve_pre_merge_files): update some comments to correct naming
  (setup_text_conflict_desc): update param names and references.
  (maybe_resolve_conflicts): update param names and references. remove the
    conversions to absolute, since we already have them
  (merge_binary_file): update param names and references. remove
    conversion to absolute of MERGE_ABSPATH, and just use the
    TARGET_ABSPATH parameter.
  (svn_wc_merge4): assert abspath conditions on the parameters. especially
    as this is a public API!

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=932248&r1=932247&r2=932248&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/merge.c (original)
+++ subversion/trunk/subversion/libsvn_wc/merge.c Fri Apr  9 05:03:16 2010
@@ -118,7 +118,7 @@ get_prop(const apr_array_header_t *prop_
 static svn_error_t *
 detranslate_wc_file(const char **detranslated_abspath,
                     svn_wc__db_t *db,
-                    const char *merge_abspath,
+                    const char *target_abspath,
                     svn_boolean_t force_copy,
                     const apr_array_header_t *prop_diff,
                     const char *source_abspath,
@@ -133,7 +133,7 @@ detranslate_wc_file(const char **detrans
   svn_boolean_t special;
 
   /* Decide if the merge target currently is a text or binary file. */
-  SVN_ERR(svn_wc__marked_as_binary(&is_binary, merge_abspath, db,
+  SVN_ERR(svn_wc__marked_as_binary(&is_binary, target_abspath, db,
                                    scratch_pool));
 
   /* See if we need to do a straight copy:
@@ -156,16 +156,16 @@ detranslate_wc_file(const char **detrans
     {
       /* Old props indicate texty, new props indicate binary:
          detranslate keywords and old eol-style */
-      SVN_ERR(svn_wc__get_keywords(&keywords, db, merge_abspath, NULL,
+      SVN_ERR(svn_wc__get_keywords(&keywords, db, target_abspath, NULL,
                                    scratch_pool, scratch_pool));
-      SVN_ERR(svn_wc__get_special(&special, db, merge_abspath, scratch_pool));
+      SVN_ERR(svn_wc__get_special(&special, db, target_abspath, scratch_pool));
     }
   else
     {
       /* New props indicate texty, regardless of old props */
 
       /* In case the file used to be special, detranslate specially */
-      SVN_ERR(svn_wc__get_special(&special, db, merge_abspath, scratch_pool));
+      SVN_ERR(svn_wc__get_special(&special, db, target_abspath, scratch_pool));
 
       if (special)
         {
@@ -182,7 +182,7 @@ detranslate_wc_file(const char **detrans
               svn_subst_eol_style_from_value(&style, &eol, prop->value->data);
             }
           else if (!is_binary)
-            SVN_ERR(svn_wc__get_eol_style(&style, &eol, db, merge_abspath,
+            SVN_ERR(svn_wc__get_eol_style(&style, &eol, db, target_abspath,
                                           scratch_pool, scratch_pool));
           else
             {
@@ -193,7 +193,7 @@ detranslate_wc_file(const char **detrans
           /* In case there were keywords, detranslate with keywords
              (iff we were texty) */
           if (!is_binary)
-            SVN_ERR(svn_wc__get_keywords(&keywords, db, merge_abspath, NULL,
+            SVN_ERR(svn_wc__get_keywords(&keywords, db, target_abspath, NULL,
                                          scratch_pool, scratch_pool));
           else
             keywords = NULL;
@@ -435,9 +435,9 @@ eval_conflict_func_result(enum svn_wc_me
                           svn_wc_conflict_result_t *result,
                           svn_stringbuf_t **log_accum,
                           svn_wc__db_t *db,
-                          const char *left,
-                          const char *right,
-                          const char *merge_target,
+                          const char *left_abspath,
+                          const char *right_abspath,
+                          const char *target_abspath,
                           const char *copyfrom_text,
                           const char *adm_abspath,
                           const char *result_target,
@@ -452,14 +452,16 @@ eval_conflict_func_result(enum svn_wc_me
       case svn_wc_conflict_choose_base:
         {
           SVN_ERR(svn_wc__loggy_copy(log_accum, adm_abspath,
-                                     left, merge_target, pool, pool));
+                                     left_abspath, target_abspath,
+                                     pool, pool));
           *merge_outcome = svn_wc_merge_merged;
           return SVN_NO_ERROR;
         }
       case svn_wc_conflict_choose_theirs_full:
         {
           SVN_ERR(svn_wc__loggy_copy(log_accum, adm_abspath,
-                                     right, merge_target, pool, pool));
+                                     right_abspath, target_abspath,
+                                     pool, pool));
           *merge_outcome = svn_wc_merge_merged;
           return SVN_NO_ERROR;
         }
@@ -489,12 +491,13 @@ eval_conflict_func_result(enum svn_wc_me
                                          svn_io_file_del_none, pool, pool));
 
           SVN_ERR(svn_diff_file_diff3_2(&diff,
-                                        left, detranslated_target, right,
+                                        left_abspath,
+                                        detranslated_target, right_abspath,
                                         options, pool));
           SVN_ERR(svn_diff_file_output_merge2(chosen_stream, diff,
-                                              left,
+                                              left_abspath,
                                               detranslated_target,
-                                              right,
+                                              right_abspath,
                                               /* markers ignored */
                                               NULL, NULL,
                                               NULL, NULL,
@@ -502,7 +505,7 @@ eval_conflict_func_result(enum svn_wc_me
                                               pool));
           SVN_ERR(svn_stream_close(chosen_stream));
           SVN_ERR(svn_wc__loggy_copy(log_accum, adm_abspath,
-                                     chosen_path, merge_target, pool, pool));
+                                     chosen_path, target_abspath, pool, pool));
           *merge_outcome = svn_wc_merge_merged;
           return SVN_NO_ERROR;
         }
@@ -521,7 +524,7 @@ eval_conflict_func_result(enum svn_wc_me
                                      result->merged_file
                                        ? result->merged_file
                                        : result_target,
-                                     merge_target,
+                                     target_abspath,
                                      pool, pool));
           *merge_outcome = svn_wc_merge_merged;
           return SVN_NO_ERROR;
@@ -535,8 +538,8 @@ eval_conflict_func_result(enum svn_wc_me
           if (copyfrom_text)
             {
               SVN_ERR(svn_wc__loggy_copy(log_accum, adm_abspath,
-                                     copyfrom_text, merge_target,
-                                     pool, pool));
+                                         copyfrom_text, target_abspath,
+                                         pool, pool));
             }
 
           /* Assume conflict remains. */
@@ -641,7 +644,7 @@ preserve_pre_merge_files(svn_stringbuf_t
      are written, so everything should be fine.  Really.  */
 
   /* Create LEFT and RIGHT backup files, in expanded form.
-     We use merge_target's current properties to do the translation. */
+     We use TARGET_ABSPATH's current properties to do the translation. */
   /* Derive the basenames of the 3 backup files. */
   SVN_WC__FLUSH_LOG_ACCUM(db, dir_abspath, *log_accum, pool);
   SVN_ERR(svn_wc__loggy_translated_file(db, dir_abspath,
@@ -651,7 +654,7 @@ preserve_pre_merge_files(svn_stringbuf_t
                                         right_copy, tmp_right,
                                         target_abspath, pool));
 
-  /* Back up MERGE_TARGET through detranslation/retranslation:
+  /* Back up TARGET_ABSPATH through detranslation/retranslation:
      the new translation properties may not match the current ones */
   SVN_ERR(svn_wc__internal_translated_file(
            &detranslated_target_copy, target_abspath, db, target_abspath,
@@ -665,7 +668,7 @@ preserve_pre_merge_files(svn_stringbuf_t
   tmp_entry.conflict_new = svn_dirent_is_child(dir_abspath, right_copy, pool);
   tmp_entry.conflict_wrk = svn_dirent_basename(target_copy, pool);
 
-  /* Mark merge_target's entry as "Conflicted", and start tracking
+  /* Mark TARGET_ABSPATH's entry as "Conflicted", and start tracking
      the backup files in the entry as well. */
   SVN_ERR(svn_wc__loggy_entry_modify(log_accum, dir_abspath,
                                      target_abspath, &tmp_entry,
@@ -679,9 +682,9 @@ preserve_pre_merge_files(svn_stringbuf_t
 
 /* Helper for maybe_resolve_conflicts() below. */
 static const svn_wc_conflict_description_t *
-setup_text_conflict_desc(const char *left,
-                         const char *right,
-                         const char *merge_abspath,
+setup_text_conflict_desc(const char *left_abspath,
+                         const char *right_abspath,
+                         const char *target_abspath,
                          const svn_wc_conflict_version_t *left_version,
                          const svn_wc_conflict_version_t *right_version,
                          const char *result_target,
@@ -692,12 +695,12 @@ setup_text_conflict_desc(const char *lef
 {
   svn_wc_conflict_description2_t *cdesc;
 
-  cdesc = svn_wc_conflict_description_create_text2(merge_abspath, pool);
+  cdesc = svn_wc_conflict_description_create_text2(target_abspath, pool);
   cdesc->is_binary = FALSE;
   cdesc->mime_type = (mimeprop && mimeprop->value)
                      ? mimeprop->value->data : NULL,
-  cdesc->base_file = left;
-  cdesc->their_file = right;
+  cdesc->base_file = left_abspath;
+  cdesc->their_file = right_abspath;
   cdesc->my_file = detranslated_target;
   cdesc->merged_file = result_target;
 
@@ -711,9 +714,9 @@ setup_text_conflict_desc(const char *lef
 static svn_error_t*
 maybe_resolve_conflicts(svn_stringbuf_t **log_accum,
                         svn_wc__db_t *db,
-                        const char *left,
-                        const char *right,
-                        const char *merge_target,
+                        const char *left_abspath,
+                        const char *right_abspath,
+                        const char *target_abspath,
                         const char *copyfrom_text,
                         const char *left_label,
                         const char *right_label,
@@ -732,11 +735,7 @@ maybe_resolve_conflicts(svn_stringbuf_t 
                         apr_pool_t *pool)
 {
   svn_wc_conflict_result_t *result = NULL;
-  const char *left_abspath, *right_abspath, *target_abspath, *dir_abspath;
-
-  SVN_ERR(svn_dirent_get_absolute(&left_abspath, left, pool));
-  SVN_ERR(svn_dirent_get_absolute(&right_abspath, right, pool));
-  SVN_ERR(svn_dirent_get_absolute(&target_abspath, merge_target, pool));
+  const char *dir_abspath;
 
   dir_abspath = svn_dirent_dirname(target_abspath, pool);
 
@@ -785,9 +784,9 @@ maybe_resolve_conflicts(svn_stringbuf_t 
                                     result,
                                     log_accum,
                                     db,
-                                    left,
-                                    right,
-                                    merge_target,
+                                    left_abspath,
+                                    right_abspath,
+                                    target_abspath,
                                     copyfrom_text,
                                     dir_abspath,
                                     result_target,
@@ -940,9 +939,12 @@ merge_text_file(svn_stringbuf_t **log_ac
     }
 
   if (*merge_outcome != svn_wc_merge_unchanged && ! dry_run)
-    /* replace MERGE_TARGET with the new merged file, expanding. */
-    SVN_ERR(svn_wc__loggy_copy(log_accum, dir_abspath,
-                               result_target, target_abspath, pool, pool));
+    {
+      /* replace TARGET_ABSPATH with the new merged file, expanding. */
+      SVN_ERR(svn_wc__loggy_copy(log_accum, dir_abspath,
+                                 result_target, target_abspath, pool, pool));
+    }
+
   return SVN_NO_ERROR;
 }
 
@@ -952,9 +954,9 @@ static svn_error_t*
 merge_binary_file(svn_stringbuf_t **log_accum,
                   enum svn_wc_merge_outcome_t *merge_outcome,
                   svn_wc__db_t *db,
-                  const char *left,
-                  const char *right,
-                  const char *merge_target,
+                  const char *left_abspath,
+                  const char *right_abspath,
+                  const char *target_abspath,
                   const char *left_label,
                   const char *right_label,
                   const char *target_label,
@@ -972,13 +974,12 @@ merge_binary_file(svn_stringbuf_t **log_
      keywords and eol stuff?   */
   const char *left_copy, *right_copy;
   const char *left_base, *right_base;
-  const char *merge_abspath;
   const char *merge_dirpath, *merge_filename;
   svn_wc_entry_t tmp_entry;
 
-  SVN_ERR(svn_dirent_get_absolute(&merge_abspath, merge_target, pool));
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(target_abspath));
 
-  svn_dirent_split(merge_abspath, &merge_dirpath, &merge_filename, pool);
+  svn_dirent_split(target_abspath, &merge_dirpath, &merge_filename, pool);
 
   /* Give the conflict resolution callback a chance to clean
      up the conflict before we mark the file 'conflicted' */
@@ -987,7 +988,8 @@ merge_binary_file(svn_stringbuf_t **log_
       svn_wc_conflict_result_t *result = NULL;
       const svn_wc_conflict_description_t *cdesc;
 
-      cdesc = setup_text_conflict_desc(left, right, merge_abspath,
+      cdesc = setup_text_conflict_desc(left_abspath, right_abspath,
+                                       target_abspath,
                                        left_version, right_version,
                                        NULL /* result_target */,
                                        detranslated_target_abspath,
@@ -1006,16 +1008,18 @@ merge_binary_file(svn_stringbuf_t **log_
           case svn_wc_conflict_choose_base:
             {
               SVN_ERR(svn_wc__loggy_copy(log_accum,
-                                     merge_dirpath,
-                                     left, merge_target, pool, pool));
+                                         merge_dirpath,
+                                         left_abspath, target_abspath,
+                                         pool, pool));
               *merge_outcome = svn_wc_merge_merged;
               return SVN_NO_ERROR;
             }
           case svn_wc_conflict_choose_theirs_full:
             {
               SVN_ERR(svn_wc__loggy_copy(log_accum,
-                                     merge_dirpath,
-                                     right, merge_target, pool, pool));
+                                         merge_dirpath,
+                                         right_abspath, target_abspath,
+                                         pool, pool));
               *merge_outcome = svn_wc_merge_merged;
               return SVN_NO_ERROR;
             }
@@ -1043,7 +1047,7 @@ merge_binary_file(svn_stringbuf_t **log_
                 {
                   SVN_ERR(svn_wc__loggy_copy(log_accum,
                                      merge_dirpath,
-                                     result->merged_file, merge_target,
+                                     result->merged_file, target_abspath,
                                      pool, pool));
                   *merge_outcome = svn_wc_merge_merged;
                   return SVN_NO_ERROR;
@@ -1075,11 +1079,11 @@ merge_binary_file(svn_stringbuf_t **log_
                                      pool, pool));
 
   /* create the backup files */
-  SVN_ERR(svn_io_copy_file(left, left_copy, TRUE, pool));
-  SVN_ERR(svn_io_copy_file(right, right_copy, TRUE, pool));
+  SVN_ERR(svn_io_copy_file(left_abspath, left_copy, TRUE, pool));
+  SVN_ERR(svn_io_copy_file(right_abspath, right_copy, TRUE, pool));
 
   /* Was the merge target detranslated? */
-  if (strcmp(merge_abspath, detranslated_target_abspath) != 0)
+  if (strcmp(target_abspath, detranslated_target_abspath) != 0)
     {
       /* Create a .mine file too */
       const char *mine_copy;
@@ -1107,13 +1111,13 @@ merge_binary_file(svn_stringbuf_t **log_
   left_base = svn_dirent_basename(left_copy, pool);
   right_base = svn_dirent_basename(right_copy, pool);
 
-  /* Mark merge_target's entry as "Conflicted", and start tracking
+  /* Mark target_abspath's entry as "Conflicted", and start tracking
      the backup files in the entry as well. */
   tmp_entry.conflict_old = left_base;
   tmp_entry.conflict_new = right_base;
   SVN_ERR(svn_wc__loggy_entry_modify(
             log_accum,
-            merge_dirpath, merge_target,
+            merge_dirpath, target_abspath,
             &tmp_entry,
             SVN_WC__ENTRY_MODIFY_CONFLICT_OLD
               | SVN_WC__ENTRY_MODIFY_CONFLICT_NEW
@@ -1158,7 +1162,8 @@ svn_wc__internal_merge(svn_stringbuf_t *
   SVN_ERR_ASSERT(svn_dirent_is_absolute(left_abspath));
   SVN_ERR_ASSERT(svn_dirent_is_absolute(right_abspath));
   SVN_ERR_ASSERT(svn_dirent_is_absolute(target_abspath));
-  SVN_ERR_ASSERT(copyfrom_abspath == NULL || svn_dirent_is_absolute(copyfrom_abspath));
+  SVN_ERR_ASSERT(copyfrom_abspath == NULL
+                 || svn_dirent_is_absolute(copyfrom_abspath));
 
   dir_abspath = svn_dirent_dirname(target_abspath, pool);
 
@@ -1305,6 +1310,10 @@ svn_wc_merge4(enum svn_wc_merge_outcome_
   svn_stringbuf_t *log_accum = NULL;
   const char *dir_abspath = svn_dirent_dirname(target_abspath, scratch_pool);
 
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(left_abspath));
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(right_abspath));
+  SVN_ERR_ASSERT(svn_dirent_is_absolute(target_abspath));
+
   /* Before we do any work, make sure we hold a write lock.  */
   if (!dry_run)
     SVN_ERR(svn_wc__write_check(wc_ctx->db, dir_abspath, scratch_pool));



Mime
View raw message