You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2013/05/03 16:55:55 UTC

svn commit: r1478826 - in /subversion/trunk: CHANGES subversion/include/svn_config.h subversion/libsvn_subr/config_file.c subversion/svn/diff-cmd.c subversion/tests/cmdline/diff_tests.py

Author: cmpilato
Date: Fri May  3 14:55:55 2013
New Revision: 1478826

URL: http://svn.apache.org/r1478826
Log:
Implement a new 'diff-ignore-content-type' runtime configuration
variable which saves folks from having to include --force when trying
to see differences of binary files.  This is handy when Subversion is
configured via 'diff-cmd' to use an external diff tool that can handle
binary diffs.

NOTE: This option is parsed in 'svn' (not down in the client layer)
      and used to control an existing boolean function parameter.

* subversion/include/svn_config.h
  (SVN_CONFIG_OPTION_DIFF_IGNORE_CONTENT_TYPE): New configuration 
    token #define.

* subversion/svn/diff-cmd.c
  (svn_cl__diff): Check the runtime configuration area to see if diff
    operations should ignore the content-type of files.

* subversion/libsvn_subr/config_file.c
  (svn_config_ensure): Add runtime configuration file template matter
    for the new 'diff-ignore-content-type' option.

* subversion/tests/cmdline/diff_tests.py
  (diff_force): Tweak this test to try the new runtime config option
    as well as '--force', verifying that both allow the display of
    binary diffs.

* CHANGES
  Note this change.

Modified:
    subversion/trunk/CHANGES
    subversion/trunk/subversion/include/svn_config.h
    subversion/trunk/subversion/libsvn_subr/config_file.c
    subversion/trunk/subversion/svn/diff-cmd.c
    subversion/trunk/subversion/tests/cmdline/diff_tests.py

Modified: subversion/trunk/CHANGES
URL: http://svn.apache.org/viewvc/subversion/trunk/CHANGES?rev=1478826&r1=1478825&r2=1478826&view=diff
==============================================================================
--- subversion/trunk/CHANGES (original)
+++ subversion/trunk/CHANGES Fri May  3 14:55:55 2013
@@ -8,6 +8,7 @@ http://svn.apache.org/repos/asf/subversi
   - Major new features:
 
   - Minor new features and improvements:
+    * new 'diff-ignore-content-type' runtime configuration option.
 
   - Client-side bugfixes:
 

Modified: subversion/trunk/subversion/include/svn_config.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_config.h?rev=1478826&r1=1478825&r2=1478826&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_config.h (original)
+++ subversion/trunk/subversion/include/svn_config.h Fri May  3 14:55:55 2013
@@ -110,6 +110,8 @@ typedef struct svn_config_t svn_config_t
 #define SVN_CONFIG_OPTION_DIFF_CMD                  "diff-cmd"
 /** @since New in 1.7. */
 #define SVN_CONFIG_OPTION_DIFF_EXTENSIONS           "diff-extensions"
+/** @since New in 1.9. */
+#define SVN_CONFIG_OPTION_DIFF_IGNORE_CONTENT_TYPE  "diff-ignore-content-type"
 #define SVN_CONFIG_OPTION_DIFF3_CMD                 "diff3-cmd"
 #define SVN_CONFIG_OPTION_DIFF3_HAS_PROGRAM_ARG     "diff3-has-program-arg"
 #define SVN_CONFIG_OPTION_MERGE_TOOL_CMD            "merge-tool-cmd"

Modified: subversion/trunk/subversion/libsvn_subr/config_file.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/config_file.c?rev=1478826&r1=1478825&r2=1478826&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/config_file.c (original)
+++ subversion/trunk/subversion/libsvn_subr/config_file.c Fri May  3 14:55:55 2013
@@ -1152,6 +1152,16 @@ svn_config_ensure(const char *config_dir
         "### ra_local (the file:// scheme). The value represents the number" NL
         "### of MB used by the cache."                                       NL
         "# memory-cache-size = 16"                                           NL
+        "### Set diff-ignore-content-type to 'yes' to cause 'svn diff' to"   NL
+        "### attempt to show differences of all modified files regardless"   NL
+        "### of their MIME content type.  By default, Subversion will only"  NL
+        "### attempt to show differences for files believed to have human-"  NL
+        "### readable (non-binary) content.  This option is especially"      NL
+        "### useful when Subversion is configured (via the 'diff-cmd'"       NL
+        "### option) to employ an external differencing tool which is able"  NL
+        "### to show meaningful differences for binary file formats.  [New"  NL
+        "### in 1.9]"                                                        NL
+        "# diff-ignore-content-type = no"                                    NL
         ""                                                                   NL
         "### Section for configuring automatic properties."                  NL
         "[auto-props]"                                                       NL

Modified: subversion/trunk/subversion/svn/diff-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/diff-cmd.c?rev=1478826&r1=1478825&r2=1478826&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/diff-cmd.c (original)
+++ subversion/trunk/subversion/svn/diff-cmd.c Fri May  3 14:55:55 2013
@@ -37,6 +37,7 @@
 #include "svn_types.h"
 #include "svn_cmdline.h"
 #include "svn_xml.h"
+#include "svn_hash.h"
 #include "cl.h"
 
 #include "svn_private_config.h"
@@ -179,6 +180,7 @@ svn_cl__diff(apr_getopt_t *os,
   const char *old_target, *new_target;
   apr_pool_t *iterpool;
   svn_boolean_t pegged_diff = FALSE;
+  svn_boolean_t ignore_content_type;
   svn_boolean_t show_copies_as_adds =
     opt_state->diff.patch_compatible || opt_state->diff.show_copies_as_adds;
   svn_boolean_t ignore_properties =
@@ -337,6 +339,21 @@ svn_cl__diff(apr_getopt_t *os,
 
     }
 
+  /* Should we ignore the content-type when deciding what to diff? */
+  if (opt_state->force)
+    {
+      ignore_content_type = TRUE;
+    }
+  else
+    {
+      SVN_ERR(svn_config_get_bool(svn_hash_gets(ctx->config,
+                                                SVN_CONFIG_CATEGORY_CONFIG),
+                                  &ignore_content_type,
+                                  SVN_CONFIG_SECTION_MISCELLANY,
+                                  SVN_CONFIG_OPTION_DIFF_IGNORE_CONTENT_TYPE,
+                                  FALSE));
+    }
+
   svn_opt_push_implicit_dot_target(targets, pool);
 
   iterpool = svn_pool_create(pool);
@@ -399,7 +416,7 @@ svn_cl__diff(apr_getopt_t *os,
                      opt_state->diff.no_diff_added,
                      opt_state->diff.no_diff_deleted,
                      show_copies_as_adds,
-                     opt_state->force,
+                     ignore_content_type,
                      ignore_properties,
                      opt_state->diff.properties_only,
                      opt_state->diff.use_git_diff_format,
@@ -450,7 +467,7 @@ svn_cl__diff(apr_getopt_t *os,
                      opt_state->diff.no_diff_added,
                      opt_state->diff.no_diff_deleted,
                      show_copies_as_adds,
-                     opt_state->force,
+                     ignore_content_type,
                      ignore_properties,
                      opt_state->diff.properties_only,
                      opt_state->diff.use_git_diff_format,

Modified: subversion/trunk/subversion/tests/cmdline/diff_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/diff_tests.py?rev=1478826&r1=1478825&r2=1478826&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/diff_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/diff_tests.py Fri May  3 14:55:55 2013
@@ -1899,7 +1899,7 @@ def diff_keywords(sbox):
 
 
 def diff_force(sbox):
-  "show diffs for binary files with --force"
+  "show diffs for binary files"
 
   sbox.build()
   wc_dir = sbox.wc_dir
@@ -1943,34 +1943,20 @@ def diff_force(sbox):
   svntest.actions.run_and_verify_commit(wc_dir, expected_output,
                                         expected_status, None, wc_dir)
 
-  # Check that we get diff when the first, the second and both files are
-  # marked as binary.
+  # Check that we get diff when the first, the second and both files
+  # are marked as binary.  First we'll use --force.  Then we'll use
+  # the configuration option 'diff-ignore-content-type'.
 
   re_nodisplay = re.compile('^Cannot display:')
 
-  exit_code, stdout, stderr = svntest.main.run_svn(None,
-                                                   'diff', '-r1:2', iota_path,
-                                                   '--force')
-
-  for line in stdout:
-    if (re_nodisplay.match(line)):
-      raise svntest.Failure
-
-  exit_code, stdout, stderr = svntest.main.run_svn(None,
-                                                   'diff', '-r2:1', iota_path,
-                                                   '--force')
-
-  for line in stdout:
-    if (re_nodisplay.match(line)):
-      raise svntest.Failure
-
-  exit_code, stdout, stderr = svntest.main.run_svn(None,
-                                                   'diff', '-r2:3', iota_path,
-                                                   '--force')
-
-  for line in stdout:
-    if (re_nodisplay.match(line)):
-      raise svntest.Failure
+  for opt in ['--force',
+              '--config-option=config:miscellany:diff-ignore-content-type=yes']:
+    for range in ['-r1:2', '-r2:1', '-r2:3']:
+      exit_code, stdout, stderr = svntest.main.run_svn(None, 'diff', range,
+                                                       iota_path, opt)
+      for line in stdout:
+        if (re_nodisplay.match(line)):
+          raise svntest.Failure
 
 #----------------------------------------------------------------------
 # Regression test for issue #2333: Renaming a directory should produce