Author: stsp
Date: Tue May 22 16:58:00 2012
New Revision: 1341560

URL: http://svn.apache.org/viewvc?rev=1341560&view=rev
Log:
Follow-up to r1341544: Normalise working files during 'svn diff r-N FILE' if
the file requires translation to repository-normal form.

This should hopefully fix diff_tests.py 10, "diff when property was changed
but text was not", on Windows.

* subversion/libsvn_client/diff.c
  (diff_repos_wc_file_target): Before diffing a file from the working copy
   perform translation if necessary.

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

Modified: subversion/trunk/subversion/libsvn_client/diff.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/diff.c?rev=1341560&r1=1341559&r2=1341560&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/diff.c (original)
+++ subversion/trunk/subversion/libsvn_client/diff.c Tue May 22 16:58:00 2012
@@ -2719,6 +2719,7 @@ diff_repos_wc_file_target(const char *ta
 {
   const char *file1_abspath;
   svn_stream_t *file1_content;
+  svn_stream_t *file2_content;
   apr_hash_t *file1_props = NULL;
   apr_hash_t *file2_props;
   svn_boolean_t is_copy = FALSE;
@@ -2746,7 +2747,6 @@ diff_repos_wc_file_target(const char *ta
   if (diff_with_base)
     {
       svn_stream_t *pristine_content;
-      svn_stream_t *file2_content;
 
       SVN_ERR(svn_wc_get_pristine_props(&file2_props, ctx->wc_ctx,
                                         file2_abspath, scratch_pool,
@@ -2769,8 +2769,47 @@ diff_repos_wc_file_target(const char *ta
                                scratch_pool));
     }
   else
-    SVN_ERR(svn_wc_prop_list2(&file2_props, ctx->wc_ctx, file2_abspath,
-                              scratch_pool, scratch_pool));
+    {
+      apr_hash_t *keywords = NULL;
+      svn_string_t *keywords_prop;
+      svn_subst_eol_style_t eol_style;
+      const char *eol_str;
+
+      SVN_ERR(svn_wc_prop_list2(&file2_props, ctx->wc_ctx, file2_abspath,
+                                scratch_pool, scratch_pool));
+
+      /* We might have to create a normalised version of the working file. */
+      svn_subst_eol_style_from_value(&eol_style, &eol_str,
+                                     apr_hash_get(file2_props,
+                                                  SVN_PROP_EOL_STYLE,
+                                                  APR_HASH_KEY_STRING));
+      keywords_prop = apr_hash_get(file2_props, SVN_PROP_KEYWORDS,
+                                   APR_HASH_KEY_STRING);
+      if (keywords_prop)
+        SVN_ERR(svn_subst_build_keywords2(&keywords, keywords_prop->data,
+                                          NULL, NULL, 0, NULL,
+                                          scratch_pool));
+      if (svn_subst_translation_required(eol_style, SVN_SUBST_NATIVE_EOL_STR,
+                                         keywords, FALSE, TRUE))
+        {
+          svn_stream_t *working_content;
+          svn_stream_t *normalized_content;
+
+          SVN_ERR(svn_stream_open_readonly(&working_content, file2_abspath,
+                                           scratch_pool, scratch_pool));
+
+          /* Create a temporary file and copy normalised data into it. */
+          SVN_ERR(svn_stream_open_unique(&file2_content, &file2_abspath, NULL,
+                                         svn_io_file_del_on_pool_cleanup,
+                                         scratch_pool, scratch_pool));
+          normalized_content = svn_subst_stream_translated(
+                                 file2_content, SVN_SUBST_NATIVE_EOL_STR,
+                                 TRUE, keywords, FALSE, scratch_pool);
+          SVN_ERR(svn_stream_copy3(working_content, normalized_content,
+                                   ctx->cancel_func, ctx->cancel_baton,
+                                   scratch_pool));
+        }
+    }
 
   if (kind1 == svn_node_file && !(show_copies_as_adds && is_copy))
     {


Reply via email to