Author: dannas
Date: Sat Jul 10 17:41:00 2010
New Revision: 962895

URL: http://svn.apache.org/viewvc?rev=962895&view=rev
Log:
Make svnlook print diff header for paths with only prop modifications.

* subversion/svnlook/main.c
  (print_diff_tree): Print diff headers for property changes if they
    haven't been written previously.

* subversion/tests/cmdline/svnlook_tests.py
  (test_print_property_diffs,
   diff_ignore_eolstyle): Remove XFail marker. Since the headers differ
    between the 'svnlook diff' and 'svn diff' we only compare the paths.

Modified:
    subversion/trunk/subversion/svnlook/main.c
    subversion/trunk/subversion/tests/cmdline/svnlook_tests.py

Modified: subversion/trunk/subversion/svnlook/main.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svnlook/main.c?rev=962895&r1=962894&r2=962895&view=diff
==============================================================================
--- subversion/trunk/subversion/svnlook/main.c (original)
+++ subversion/trunk/subversion/svnlook/main.c Sat Jul 10 17:41:00 2010
@@ -902,6 +902,7 @@ print_diff_tree(svn_fs_root_t *root,
   svn_boolean_t orig_empty = FALSE;
   svn_boolean_t is_copy = FALSE;
   svn_boolean_t binary = FALSE;
+  svn_boolean_t diff_header_printed = FALSE;
   apr_pool_t *subpool;
   svn_stringbuf_t *header;
 
@@ -1074,6 +1075,7 @@ print_diff_tree(svn_fs_root_t *root,
                        svn_cmdline_output_encoding(pool), NULL, FALSE, pool));
               SVN_ERR(svn_stream_close(ostream));
               SVN_ERR(svn_cmdline_printf(pool, "\n"));
+              diff_header_printed = TRUE;
             }
           else if (! node->prop_mod &&
                   ((! c->no_diff_added && node->action == 'A') ||
@@ -1114,7 +1116,24 @@ print_diff_tree(svn_fs_root_t *root,
                              base_proptable, pool));
       SVN_ERR(svn_categorize_props(propchanges, NULL, NULL, &props, pool));
       if (props->nelts > 0)
-        SVN_ERR(display_prop_diffs(props, base_proptable, path, pool));
+        {
+          /* We print a diff header for the case when we only have property
+           * mods. */
+          if (! diff_header_printed)
+            {
+              const char *orig_label, *new_label;
+
+              SVN_ERR(generate_label(&orig_label, base_root, base_path,
+                                     pool));
+              SVN_ERR(generate_label(&new_label, root, path, pool));
+
+              SVN_ERR(svn_cmdline_printf(pool, "Index: %s\n", path));
+              SVN_ERR(svn_cmdline_printf(pool, "%s\n", equal_string));
+              SVN_ERR(svn_cmdline_printf(pool, "--- %s\n", orig_label));
+              SVN_ERR(svn_cmdline_printf(pool, "+++ %s\n", new_label));
+            }
+          SVN_ERR(display_prop_diffs(props, base_proptable, path, pool));
+        }
     }
 
   /* Return here if the node has no children. */

Modified: subversion/trunk/subversion/tests/cmdline/svnlook_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnlook_tests.py?rev=962895&r1=962894&r2=962895&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnlook_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnlook_tests.py Sat Jul 10 
17:41:00 2010
@@ -271,7 +271,15 @@ def test_print_property_diffs(sbox):
   for i in range(len(expected_output)):
     expected_output[i] = expected_output[i].replace(iota_path, 'iota')
 
-  svntest.verify.compare_and_display_lines('', '', expected_output, output)
+  # Check that the header filenames match.
+  if expected_output[2].split()[1] != output[2].split()[1]:
+    raise svntest.Failure
+  if expected_output[3].split()[1] != output[3].split()[1]:
+    raise svntest.Failure
+
+  svntest.verify.compare_and_display_lines('', '', 
+                                           expected_output[4:],
+                                           output[4:])
 
 #----------------------------------------------------------------------
 # Check that svnlook info repairs allows inconsistent line endings in logs.
@@ -524,7 +532,15 @@ def diff_ignore_eolstyle(sbox):
     for i in range(len(expected_output)):
       expected_output[i] = expected_output[i].replace(mu_path, 'A/mu')
 
-    svntest.verify.compare_and_display_lines('', '', expected_output, output)
+    # Check that the header filenames match.
+    if expected_output[2].split()[1] != output[2].split()[1]:
+      raise svntest.Failure
+    if expected_output[3].split()[1] != output[3].split()[1]:
+      raise svntest.Failure
+
+    svntest.verify.compare_and_display_lines('', '', 
+                                             expected_output[4:],
+                                             output[4:])
 
 
 #----------------------------------------------------------------------
@@ -675,13 +691,13 @@ fp.close()"""
 test_list = [ None,
               test_misc,
               delete_file_in_moved_dir,
-              XFail(test_print_property_diffs),
+              test_print_property_diffs,
               info_bad_newlines,
               changed_copy_info,
               tree_non_recursive,
               limit_history,
               diff_ignore_whitespace,
-              XFail(diff_ignore_eolstyle),
+              diff_ignore_eolstyle,
               diff_binary,
               test_filesize,
               test_txn_flag,


Reply via email to