subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1413773 - in /subversion/trunk/subversion: include/private/svn_diff_private.h libsvn_client/diff.c libsvn_diff/diff.h libsvn_diff/diff_file.c svnlook/main.c
Date Mon, 26 Nov 2012 18:35:04 GMT
Author: julianfoad
Date: Mon Nov 26 18:35:03 2012
New Revision: 1413773

URL: http://svn.apache.org/viewvc?rev=1413773&view=rev
Log:
Factor out a tiny bit more of the unidiff output code.

* subversion/include/private/svn_diff_private.h
  (SVN_DIFF__EQUAL_STRING, SVN_DIFF__UNDER_STRING): New string constants,
    factored out from two copies of 'equal_string' & 'under_string' below.
  (svn_diff__unidiff_write_header): Move from libsvn_diff/diff.h.

* subversion/libsvn_client/diff.c
  (equal_string, under_string): Remove.
  (display_prop_diffs, diff_content_changed, diff_file_deleted): Use
    SVN_DIFF__EQUAL_STRING, SVN_DIFF__UNDER_STRING and
    svn_diff__unidiff_write_header().

* subversion/libsvn_diff/diff_file.c
  Include svn_diff_private.h because we use svn_diff__unidiff_write_header().

* subversion/libsvn_diff/diff.h
  (svn_diff__unidiff_write_header): Move to svn_diff_private.h.

* subversion/svnlook/main.c
  (equal_string, under_string): Remove.
  (display_prop_diffs, print_diff_tree): Use SVN_DIFF__EQUAL_STRING,
    SVN_DIFF__UNDER_STRING and svn_diff__unidiff_write_header().

Modified:
    subversion/trunk/subversion/include/private/svn_diff_private.h
    subversion/trunk/subversion/libsvn_client/diff.c
    subversion/trunk/subversion/libsvn_diff/diff.h
    subversion/trunk/subversion/libsvn_diff/diff_file.c
    subversion/trunk/subversion/svnlook/main.c

Modified: subversion/trunk/subversion/include/private/svn_diff_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_diff_private.h?rev=1413773&r1=1413772&r2=1413773&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_diff_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_diff_private.h Mon Nov 26 18:35:03 2012
@@ -37,6 +37,16 @@ extern "C" {
 
 
 
+/* The separator string used below the "Index:" or similar line of
+ * Subversion's Unidiff-like diff format.  */
+#define SVN_DIFF__EQUAL_STRING \
+  "==================================================================="
+
+/* The separator string used below the "Properties on ..." line of
+ * Subversion's Unidiff-like diff format.  */
+#define SVN_DIFF__UNDER_STRING \
+  "___________________________________________________________________"
+
 /* The string used to mark a line in a hunk that doesn't end with a newline,
  * when diffing a file.  Intentionally not marked for translation, for wider
  * interoperability with patch(1) programs. */
@@ -48,6 +58,20 @@ extern "C" {
 #define SVN_DIFF__NO_NEWLINE_AT_END_OF_PROPERTY \
           "\\ No newline at end of property"
 
+/* Write a unidiff "---" and "+++" header to OUTPUT_STREAM.
+ *
+ * Write "---" followed by a space and OLD_HEADER and a newline,
+ * then "+++" followed by a space and NEW_HEADER and a newline.
+ *
+ * The text will be encoded into HEADER_ENCODING.
+ */
+svn_error_t *
+svn_diff__unidiff_write_header(svn_stream_t *output_stream,
+                               const char *header_encoding,
+                               const char *old_header,
+                               const char *new_header,
+                               apr_pool_t *scratch_pool);
+
 /* Display property changes in pseudo-Unidiff format.
  *
  * Write to @a outstream the changes described by @a propchanges based on

Modified: subversion/trunk/subversion/libsvn_client/diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/diff.c?rev=1413773&r1=1413772&r2=1413773&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/diff.c (original)
+++ subversion/trunk/subversion/libsvn_client/diff.c Mon Nov 26 18:35:03 2012
@@ -57,17 +57,6 @@
 #include "svn_private_config.h"
 
 
-/*
- * Constant separator strings
- */
-static const char equal_string[] =
-  "===================================================================";
-static const char under_string[] =
-  "___________________________________________________________________";
-
-
-/*-----------------------------------------------------------------*/
-
 /* Utilities */
 
 
@@ -482,8 +471,8 @@ display_prop_diffs(const apr_array_heade
 
       SVN_ERR(svn_stream_printf_from_utf8(outstream, encoding, pool,
                                           "Index: %s" APR_EOL_STR
-                                          "%s" APR_EOL_STR,
-                                          path, equal_string));
+                                          SVN_DIFF__EQUAL_STRING APR_EOL_STR,
+                                          path));
 
       if (use_git_diff_format)
         SVN_ERR(print_git_diff_header(outstream, &label1, &label2,
@@ -492,11 +481,10 @@ display_prop_diffs(const apr_array_heade
                                       SVN_INVALID_REVNUM,
                                       encoding, pool));
 
-      SVN_ERR(svn_stream_printf_from_utf8(outstream, encoding, pool,
-                                          "--- %s" APR_EOL_STR
-                                          "+++ %s" APR_EOL_STR,
-                                          label1,
-                                          label2));
+      /* --- label1
+       * +++ label2 */
+      SVN_ERR(svn_diff__unidiff_write_header(
+        outstream, encoding, label1, label2, pool));
     }
 
   SVN_ERR(svn_stream_printf_from_utf8(outstream, encoding, pool,
@@ -506,7 +494,7 @@ display_prop_diffs(const apr_array_heade
                                       APR_EOL_STR));
 
   SVN_ERR(svn_stream_printf_from_utf8(outstream, encoding, pool,
-                                      "%s" APR_EOL_STR, under_string));
+                                      SVN_DIFF__UNDER_STRING APR_EOL_STR));
 
   SVN_ERR(svn_diff__display_prop_diffs(
             outstream, encoding, propchanges, original_props,
@@ -757,7 +745,9 @@ diff_content_changed(const char *path,
       /* Print out the diff header. */
       SVN_ERR(svn_stream_printf_from_utf8(outstream,
                diff_cmd_baton->header_encoding, subpool,
-               "Index: %s" APR_EOL_STR "%s" APR_EOL_STR, path, equal_string));
+               "Index: %s" APR_EOL_STR
+               SVN_DIFF__EQUAL_STRING APR_EOL_STR,
+               path));
 
       /* ### Print git diff headers. */
 
@@ -805,7 +795,9 @@ diff_content_changed(const char *path,
       /* Print out the diff header. */
       SVN_ERR(svn_stream_printf_from_utf8(outstream,
                diff_cmd_baton->header_encoding, subpool,
-               "Index: %s" APR_EOL_STR "%s" APR_EOL_STR, path, equal_string));
+               "Index: %s" APR_EOL_STR
+               SVN_DIFF__EQUAL_STRING APR_EOL_STR,
+               path));
 
       /* ### Do we want to add git diff headers here too? I'd say no. The
        * ### 'Index' and '===' line is something subversion has added. The rest
@@ -860,8 +852,9 @@ diff_content_changed(const char *path,
           /* Print out the diff header. */
           SVN_ERR(svn_stream_printf_from_utf8(outstream,
                    diff_cmd_baton->header_encoding, subpool,
-                   "Index: %s" APR_EOL_STR "%s" APR_EOL_STR,
-                   path, equal_string));
+                   "Index: %s" APR_EOL_STR
+                   SVN_DIFF__EQUAL_STRING APR_EOL_STR,
+                   path));
 
           if (diff_cmd_baton->use_git_diff_format)
             {
@@ -1068,8 +1061,9 @@ diff_file_deleted(svn_wc_notify_state_t 
     {
       SVN_ERR(svn_stream_printf_from_utf8(diff_cmd_baton->outstream,
                 diff_cmd_baton->header_encoding, scratch_pool,
-                "Index: %s (deleted)" APR_EOL_STR "%s" APR_EOL_STR,
-                path, equal_string));
+                "Index: %s (deleted)" APR_EOL_STR
+                SVN_DIFF__EQUAL_STRING APR_EOL_STR,
+                path));
     }
   else
     {

Modified: subversion/trunk/subversion/libsvn_diff/diff.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/diff.h?rev=1413773&r1=1413772&r2=1413773&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/diff.h (original)
+++ subversion/trunk/subversion/libsvn_diff/diff.h Mon Nov 26 18:35:03 2012
@@ -213,19 +213,5 @@ svn_diff__unified_write_hunk_header(svn_
                                     const char *hunk_extra_context,
                                     apr_pool_t *scratch_pool);
 
-/* Write a unidiff "---" and "+++" header to OUTPUT_STREAM.
- *
- * Write "---" followed by a space and OLD_HEADER and a newline,
- * then "+++" followed by a space and NEW_HEADER and a newline.
- *
- * The text will be encoded into HEADER_ENCODING.
- */
-svn_error_t *
-svn_diff__unidiff_write_header(svn_stream_t *output_stream,
-                               const char *header_encoding,
-                               const char *old_header,
-                               const char *new_header,
-                               apr_pool_t *scratch_pool);
-
 
 #endif /* DIFF_H */

Modified: subversion/trunk/subversion/libsvn_diff/diff_file.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/diff_file.c?rev=1413773&r1=1413772&r2=1413773&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/diff_file.c (original)
+++ subversion/trunk/subversion/libsvn_diff/diff_file.c Mon Nov 26 18:35:03 2012
@@ -48,6 +48,7 @@
 #include "private/svn_eol_private.h"
 #include "private/svn_dep_compat.h"
 #include "private/svn_adler32.h"
+#include "private/svn_diff_private.h"
 
 /* A token, i.e. a line read from a file. */
 typedef struct svn_diff__file_token_t

Modified: subversion/trunk/subversion/svnlook/main.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnlook/main.c?rev=1413773&r1=1413772&r2=1413773&view=diff
==============================================================================
--- subversion/trunk/subversion/svnlook/main.c (original)
+++ subversion/trunk/subversion/svnlook/main.c Mon Nov 26 18:35:03 2012
@@ -784,14 +784,6 @@ generate_label(const char **label,
   return SVN_NO_ERROR;
 }
 
-/*
- * Constant diff output separator strings
- */
-static const char equal_string[] =
-  "===================================================================";
-static const char under_string[] =
-  "___________________________________________________________________";
-
 
 /* Helper function to display differences in properties of a file */
 static svn_error_t *
@@ -810,7 +802,7 @@ display_prop_diffs(svn_stream_t *outstre
                                       APR_EOL_STR));
 
   SVN_ERR(svn_stream_printf_from_utf8(outstream, encoding, pool,
-                                      "%s" APR_EOL_STR, under_string));
+                                      SVN_DIFF__UNDER_STRING APR_EOL_STR));
 
   SVN_ERR(check_cancel(NULL));
 
@@ -948,8 +940,7 @@ print_diff_tree(svn_stream_t *out_stream
 
   if (do_diff && (! c->properties_only))
     {
-      svn_stringbuf_appendcstr(header, equal_string);
-      svn_stringbuf_appendcstr(header, "\n");
+      svn_stringbuf_appendcstr(header, SVN_DIFF__EQUAL_STRING "\n");
 
       if (binary)
         {
@@ -1121,11 +1112,11 @@ print_diff_tree(svn_stream_t *out_stream
               SVN_ERR(svn_stream_printf_from_utf8(out_stream, encoding, pool,
                                                   "Index: %s\n", path));
               SVN_ERR(svn_stream_printf_from_utf8(out_stream, encoding, pool,
-                                                  "%s\n", equal_string));
-              SVN_ERR(svn_stream_printf_from_utf8(out_stream, encoding, pool,
-                                                  "--- %s\n", orig_label));
-              SVN_ERR(svn_stream_printf_from_utf8(out_stream, encoding, pool,
-                                                  "+++ %s\n", new_label));
+                                                  SVN_DIFF__EQUAL_STRING "\n"));
+              /* --- <label1>
+               * +++ <label2> */
+              SVN_ERR(svn_diff__unidiff_write_header(
+                        out_stream, encoding, orig_label, new_label, pool));
             }
           SVN_ERR(display_prop_diffs(out_stream, encoding,
                                      props, base_proptable, path, pool));



Mime
View raw message